diff options
-rw-r--r-- | cbuildbot/constants.py | 5 | ||||
-rw-r--r-- | cbuildbot/stages/sync_stages.py | 19 | ||||
-rw-r--r-- | cbuildbot/stages/sync_stages_unittest.py | 11 |
3 files changed, 34 insertions, 1 deletions
diff --git a/cbuildbot/constants.py b/cbuildbot/constants.py index ee99ddb3d..027f124cf 100644 --- a/cbuildbot/constants.py +++ b/cbuildbot/constants.py @@ -850,3 +850,8 @@ STATSD_HOST = '146.148.70.158' STATSD_PORT = 8125 STATSD_PROD_PREFIX = 'chromite' STATSD_DEBUG_PREFIX = 'chromite_debug' + +# Publication of Project SDK artifacts. +BRILLO_RELEASE_MANIFESTS_URL = 'gs://brillo-releases/sdk-releases' +BRILLO_LATEST_RELEASE_URL = os.path.join(BRILLO_RELEASE_MANIFESTS_URL, + 'LATEST') diff --git a/cbuildbot/stages/sync_stages.py b/cbuildbot/stages/sync_stages.py index e9fffa0ad..54564f4ee 100644 --- a/cbuildbot/stages/sync_stages.py +++ b/cbuildbot/stages/sync_stages.py @@ -35,6 +35,7 @@ from chromite.lib import commandline from chromite.lib import cros_build_lib from chromite.lib import cros_logging as logging from chromite.lib import git +from chromite.lib import gs from chromite.lib import osutils from chromite.lib import patch as cros_patch from chromite.scripts import cros_mark_chrome_as_stable @@ -617,10 +618,25 @@ class ManifestVersionedSyncStage(SyncStage): git.AddPath(latest_manifest_path) git.Commit(git_repo, 'Create project_sdk for %s.' % current_version) - # Push it. + # Push it to Gerrit. logging.info('Pushing Project SDK Manifest.') git.PushWithRetry(branch, git_repo) + # Push to GS. + gs_ctx = gs.GSContext(dry_run=self._run.debug) + publish_uri = os.path.join(constants.BRILLO_RELEASE_MANIFESTS_URL, + sdk_manifest_name) + + # We use the default ACL (public readable) for this file. + logging.info('Pushing Project SDK Manifest to: %s', publish_uri) + gs_ctx.Copy(manifest, publish_uri) + + # Populate a file on GS with the newest version published. + with tempfile.NamedTemporaryFile() as latest: + osutils.WriteFile(latest.name, current_version) + gs_ctx.Copy(latest.name, constants.BRILLO_LATEST_RELEASE_URL) + + # Log what we published. logging.info('Project SDK Manifest \'%s\' published:', os.path.basename(sdk_manifest_path)) logging.info('%s', osutils.ReadFile(manifest)) @@ -652,6 +668,7 @@ class ManifestVersionedSyncStage(SyncStage): next_manifest, filter_cros=self._run.options.local) as new_manifest: self.ManifestCheckout(new_manifest) + # TODO(dgarrett): Push this logic into it's own stage. # If we are a Canary Master, create an additional derivative Manifest for # the Project SDK builders. if (cbuildbot_config.IsCanaryType(self._run.config.build_type) and diff --git a/cbuildbot/stages/sync_stages_unittest.py b/cbuildbot/stages/sync_stages_unittest.py index 0718f5aab..5623ade4d 100644 --- a/cbuildbot/stages/sync_stages_unittest.py +++ b/cbuildbot/stages/sync_stages_unittest.py @@ -34,6 +34,7 @@ from chromite.lib import fake_cidb from chromite.lib import gerrit from chromite.lib import git from chromite.lib import git_unittest +from chromite.lib import gs_unittest from chromite.lib import gob_util from chromite.lib import osutils from chromite.lib import patch as cros_patch @@ -89,6 +90,9 @@ class ManifestVersionedSyncStageTest(generic_stages_unittest.AbstractStageTest): @mock.patch.object(git, 'PushWithRetry') def testCommitProjectSDKManifest(self, _mock_push): """Tests that we can 'push' an SDK manifest.""" + gs_mock = self.StartPatcher(gs_unittest.GSContextMock()) + gs_mock.SetDefaultCmdResult() + # Create test manifest MANIFEST_CONTENTS = 'bogus value' manifest = os.path.join(self.tempdir, 'sdk.xml') @@ -110,6 +114,13 @@ class ManifestVersionedSyncStageTest(generic_stages_unittest.AbstractStageTest): self.assertTrue(os.path.exists(latest_path)) self.assertEqual(os.path.realpath(latest_path), manifest_path) + # Verify pushes to GS. + gs_mock.assertCommandContains( + ('cp', manifest, 'gs://brillo-releases/sdk-releases/test_version.xml')) + + gs_mock.assertCommandContains( + ('cp', 'gs://brillo-releases/sdk-releases/latest')) + class MockPatch(mock.MagicMock): """MagicMock for a GerritPatch-like object.""" |