aboutsummaryrefslogtreecommitdiffhomepage
path: root/infra/build
diff options
context:
space:
mode:
authorGravatar kabeer27 <32016558+kabeer27@users.noreply.github.com>2020-07-08 07:19:59 +0000
committerGravatar GitHub <noreply@github.com>2020-07-08 17:19:59 +1000
commit600c51495857ff9d20d6cf683df6504b69a0f2a2 (patch)
treec7b72e2fd4a0ca835c8c9dc6d044ef6390815d2e /infra/build
parent0a712bb5d4a43124241a19b86049b8fdda2b7c80 (diff)
Renaming schedule variable to builds_per_day for new feature (#4091)
* Renaming schedule variable to builds_per_day for new feature * Minor formatting change Co-authored-by: Kabeer Seth <kabeerseth@google.com>
Diffstat (limited to 'infra/build')
-rw-r--r--infra/build/functions/sync/main.py6
-rw-r--r--infra/build/functions/sync/main_test.py9
2 files changed, 8 insertions, 7 deletions
diff --git a/infra/build/functions/sync/main.py b/infra/build/functions/sync/main.py
index ad57910d..3fea68b0 100644
--- a/infra/build/functions/sync/main.py
+++ b/infra/build/functions/sync/main.py
@@ -146,15 +146,15 @@ def get_schedule(project_contents):
if content_file.name != 'project.yaml':
continue
project_yaml = yaml.safe_load(content_file.decoded_content.decode('utf-8'))
- times_per_day = project_yaml.get('schedule', DEFAULT_BUILDS_PER_DAY)
- if not isinstance(times_per_day, int) or times_per_day not in range(
+ builds_per_day = project_yaml.get('builds_per_day', DEFAULT_BUILDS_PER_DAY)
+ if not isinstance(builds_per_day, int) or builds_per_day not in range(
1, MAX_BUILDS_PER_DAY + 1):
raise ProjectYamlError('Parameter is not an integer in range [1-4]')
# Starting at 6:00 am, next build schedules are added at 'interval' slots
# Example for interval 2, hours = [6, 18] and schedule = '0 6,18 * * *'
- interval = 24 // times_per_day
+ interval = 24 // builds_per_day
hours = []
for hour in range(6, 30, interval):
hours.append(hour % 24)
diff --git a/infra/build/functions/sync/main_test.py b/infra/build/functions/sync/main_test.py
index f49ea10e..b52a8a0c 100644
--- a/infra/build/functions/sync/main_test.py
+++ b/infra/build/functions/sync/main_test.py
@@ -238,8 +238,8 @@ class TestDataSync(unittest.TestCase):
Repository('project.yaml', 'file', 'projects/test1/project.yaml')
])
])
- repo.contents[0].contents[1].set_yaml_contents(b'schedule: 2')
- repo.contents[1].contents[1].set_yaml_contents(b'schedule: 3')
+ repo.contents[0].contents[1].set_yaml_contents(b'builds_per_day: 2')
+ repo.contents[1].contents[1].set_yaml_contents(b'builds_per_day: 3')
self.assertEqual(
get_projects(repo), {
@@ -301,7 +301,8 @@ class TestDataSync(unittest.TestCase):
Repository('project.yaml', 'file', 'projects/test0/project.yaml')
])
])
- repo.contents[0].contents[1].set_yaml_contents(b'schedule: some-string')
+ repo.contents[0].contents[1].set_yaml_contents(
+ b'builds_per_day: some-string')
self.assertEqual(get_projects(repo), {})
@@ -314,7 +315,7 @@ class TestDataSync(unittest.TestCase):
Repository('project.yaml', 'file', 'projects/test0/project.yaml')
])
])
- repo.contents[0].contents[1].set_yaml_contents(b'schedule: 5')
+ repo.contents[0].contents[1].set_yaml_contents(b'builds_per_day: 5')
self.assertEqual(get_projects(repo), {})