From cdfad21af8cc012aa561eb7e2681dd362e017d98 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 15 Apr 2018 18:24:13 +0300 Subject: Add: build_number to work resource --- ick2/workapi.py | 6 ++++-- ick2/workapi_tests.py | 3 +++ yarns/400-build.yarn | 13 +++++++++++++ yarns/500-build-fail.yarn | 1 + 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ick2/workapi.py b/ick2/workapi.py index 62581c7..a23f603 100644 --- a/ick2/workapi.py +++ b/ick2/workapi.py @@ -50,7 +50,8 @@ class WorkAPI(ick2.APIbase): pipeline['status'] = 'building' self._update_pipeline(project, pipeline) - build_id = self._start_build(project, pipeline, worker) + build_id, build_no = self._start_build( + project, pipeline, worker) self._start_log(build_id) build = self._get_build(build_id) actions = build['actions'] @@ -58,6 +59,7 @@ class WorkAPI(ick2.APIbase): doing = { 'build_id': build_id, + 'build_number': build_no, 'worker': worker, 'project': project['project'], 'pipeline': pipeline['pipeline'], @@ -129,7 +131,7 @@ class WorkAPI(ick2.APIbase): 'current_action': 0, } self._builds.add(build_id, build) - return build_id + return build_id, build_no def _get_build(self, build_id): return self._builds.get(build_id) diff --git a/ick2/workapi_tests.py b/ick2/workapi_tests.py index fdfc601..1ee4625 100644 --- a/ick2/workapi_tests.py +++ b/ick2/workapi_tests.py @@ -80,6 +80,7 @@ class WorkAPITests(unittest.TestCase): work = self.create_work_api() expected = { 'build_id': 'foo/1', + 'build_number': 1, 'worker': 'asterix', 'project': 'foo', 'pipeline': 'build', @@ -105,6 +106,7 @@ class WorkAPITests(unittest.TestCase): # Ask for some work. expected = { 'build_id': 'foo/1', + 'build_number': 1, 'worker': 'asterix', 'project': 'foo', 'pipeline': 'build', @@ -172,6 +174,7 @@ class WorkAPITests(unittest.TestCase): # Ask for some work. expected = { 'build_id': 'foo/1', + 'build_number': 1, 'worker': 'asterix', 'project': 'foo', 'pipeline': 'build', diff --git a/yarns/400-build.yarn b/yarns/400-build.yarn index bd44122..3ee30a6 100644 --- a/yarns/400-build.yarn +++ b/yarns/400-build.yarn @@ -118,6 +118,7 @@ the worker to construct a new workspace for the build. AND body matches ... { ... "build_id": "rome/1", + ... "build_number": 1, ... "log": "/logs/rome/1", ... "worker": "obelix", ... "project": "rome", @@ -135,6 +136,7 @@ the worker to construct a new workspace for the build. AND body matches ... { ... "build_id": "rome/1", + ... "build_number": 1, ... "log": "/logs/rome/1", ... "worker": "obelix", ... "project": "rome", @@ -163,6 +165,7 @@ User can now see pipeline is running and which worker is building it. ... "worker": "obelix", ... "doing": { ... "build_id": "rome/1", + ... "build_number": 1, ... "log": "/logs/rome/1", ... "worker": "obelix", ... "project": "rome", @@ -230,6 +233,7 @@ Worker requests more work, and gets the first actual build step. AND body matches ... { ... "build_id": "rome/1", + ... "build_number": 1, ... "log": "/logs/rome/1", ... "worker": "obelix", ... "project": "rome", @@ -266,6 +270,7 @@ didnt't finish. AND body matches ... { ... "build_id": "rome/1", + ... "build_number": 1, ... "log": "/logs/rome/1", ... "worker": "obelix", ... "project": "rome", @@ -341,6 +346,7 @@ Now there's another step to do. AND body matches ... { ... "build_id": "rome/1", + ... "build_number": 1, ... "log": "/logs/rome/1", ... "worker": "obelix", ... "project": "rome", @@ -362,6 +368,7 @@ User sees changed status. ... "worker": "obelix", ... "doing": { ... "build_id": "rome/1", + ... "build_number": 1, ... "worker": "obelix", ... "project": "rome", ... "pipeline": "construct", @@ -469,6 +476,7 @@ Start build again. This should become build number 2. AND body matches ... { ... "build_id": "rome/2", + ... "build_number": 2, ... "log": "/logs/rome/2", ... "worker": "obelix", ... "project": "rome", @@ -543,6 +551,7 @@ Start build again. This should become build number 2. AND body matches ... { ... "build_id": "rome/2", + ... "build_number": 2, ... "log": "/logs/rome/2", ... "worker": "obelix", ... "project": "rome", @@ -705,6 +714,7 @@ Build the first project. WHEN worker-manager makes request POST /work with a valid token and body ... { ... "build_id": "first/1", + ... "build_number": 1, ... "worker": "obelix", ... "project": "first", ... "pipeline": "do_something", @@ -724,6 +734,7 @@ Build the first project. WHEN worker-manager makes request POST /work with a valid token and body ... { ... "build_id": "first/1", + ... "build_number": 1, ... "worker": "obelix", ... "project": "first", ... "pipeline": "do_something", @@ -894,6 +905,7 @@ Trigger both projects. WHEN asterix makes request POST /work with a valid token and body ... { ... "build_id": "first/1", + ... "build_number": 1, ... "worker": "asterix", ... "project": "first", ... "pipeline": "do_something", @@ -919,6 +931,7 @@ Trigger both projects. WHEN obelix makes request POST /work with a valid token and body ... { ... "build_id": "second/1", + ... "build_number": 1, ... "worker": "obelix", ... "project": "second", ... "pipeline": "do_something", diff --git a/yarns/500-build-fail.yarn b/yarns/500-build-fail.yarn index dbe4e2c..95fcd5e 100644 --- a/yarns/500-build-fail.yarn +++ b/yarns/500-build-fail.yarn @@ -85,6 +85,7 @@ Worker wants work and gets the first step to run. AND body matches ... { ... "build_id": "rome/1", + ... "build_number": 1, ... "log": "/logs/rome/1", ... "worker": "obelix", ... "project": "rome", -- cgit v1.2.1