Bug 1288573 - Ability to start releases before en-US builds are done r=rail
authorJohan Lorenzo <jlorenzo@mozilla.com>
Fri, 02 Sep 2016 10:28:01 +0200
changeset 7002 833477b826d0
parent 7001 aa164a2ca9be
child 7003 4e0eca3d8476
push id5223
push userjlorenzo@mozilla.com
push dateFri, 02 Sep 2016 17:37:53 +0000
reviewersrail
bugs1288573
Bug 1288573 - Ability to start releases before en-US builds are done r=rail MozReview-Commit-ID: 8U3ujVl0qUr
buildfarm/release/build_status.py
buildfarm/release/release-runner.py
new file mode 100644
--- /dev/null
+++ b/buildfarm/release/build_status.py
@@ -0,0 +1,25 @@
+import taskcluster
+
+from kickoff import task_for_revision
+
+import logging
+log = logging.getLogger(__name__)
+
+
+# TODO: Bug 1300147. Avoid having 7 parameters by using a release object that contains only what's needed.
+def are_en_us_builds_completed(index, queue, release_name, branch, revision, tc_product_name, platforms):
+    try:
+        tasks_to_watch = [
+            task_for_revision(index, branch, revision, tc_product_name, platform)['taskId']
+            for platform in platforms
+        ]
+    except taskcluster.exceptions.TaskclusterRestFailure:
+        log.debug('At least one task is not created yet for %s', release_name)
+        return False
+
+    log.debug('All tasks have been found: %s', tasks_to_watch)
+    return _are_all_tasks_completed(queue, tasks_to_watch)
+
+
+def _are_all_tasks_completed(queue, taskIds):
+    return all([queue.status(taskId)['status']['state'] == 'completed' for taskId in taskIds])
--- a/buildfarm/release/release-runner.py
+++ b/buildfarm/release/release-runner.py
@@ -26,16 +26,17 @@ from kickoff.sanity import ReleaseSaniti
 from release.info import readBranchConfig
 from release.l10n import parsePlainL10nChangesets
 from release.versions import getAppVersion
 from taskcluster import Scheduler, Index, Queue
 from taskcluster.utils import slugId
 from util.hg import mercurial
 from util.retry import retry
 from util.file import load_config, get_config
+from build_status import are_en_us_builds_completed
 
 log = logging.getLogger(__name__)
 
 
 # both CHECKSUMS and ALL_FILES have been defined to improve the release sanity
 # en-US binaries timing by whitelisting artifacts of interest - bug 1251761
 CHECKSUMS = set([
     '.checksums',
@@ -304,16 +305,17 @@ def main(options):
             if path.exists(symlink):
                 log.warning("Skipping %s -> %s symlink" % (symlink, target))
             else:
                 log.info("Adding %s -> %s symlink" % (symlink, target))
                 os.symlink(target, symlink)
 
     # TODO: this won't work for Thunderbird...do we care?
     branch = release["branch"].split("/")[-1]
+    release['branchShortName'] = branch
     branchConfig = readBranchConfig(path.join(configs_workdir, "mozilla"), branch=branch)
 
     release_channels = update_channels(release["version"], branchConfig["release_channel_mappings"])
     # candidate releases are split in two graphs and release-runner only handles the first
     # graph of tasks. so parts like postrelease, push_to_releases/mirrors, and mirror dependant
     # channels are handled in the second generated graph outside of release-runner.
     # This is not elegant but it should do the job for now
     candidate_release = is_candidate_release(release_channels)
@@ -333,16 +335,30 @@ def main(options):
         postrelease_bouncer_aliases_enabled = branchConfig['postrelease_bouncer_aliases_enabled']
         postrelease_mark_as_shipped_enabled = branchConfig['postrelease_mark_as_shipped_enabled']
         final_verify_channels = release_channels
         publish_to_balrog_channels = release_channels
         push_to_releases_enabled = True
 
     rc = 0
     for release in rr.new_releases:
+        ship_it_product_name = release['product']
+        tc_product_name = branchConfig['stage_product'][ship_it_product_name]
+        # XXX: Doesn't work with neither Fennec nor Thunderbird
+        platforms = branchConfig['release_platforms']
+        log.debug('Will check these platforms in order to know if builds are completed: %s', platforms)
+
+        if not are_en_us_builds_completed(index, queue, release_name=release['name'], branch=branch,
+                                          revision=release['mozillaRevision'], tc_product_name=tc_product_name,
+                                          platforms=platforms):
+            log.info('Builds are not completed yet, skipping release "%s" for now', release['name'])
+            rr.update_status(release, 'Waiting for builds to be completed')
+            continue
+
+        log.info('Every build is completed for release: %s', release['name'])
         graph_id = slugId()
         try:
             rr.update_status(release, 'Generating task graph')
             l10n_changesets = parsePlainL10nChangesets(rr.get_release_l10n(release["name"]))
 
             kwargs = {
                 "public_key": docker_worker_key,
                 "version": release["version"],