Bug 1439876 - Add scriptworker version bumping. r=aki
authorJustin Wood <Callek@gmail.com>
Wed, 21 Feb 2018 12:06:38 +0000
changeset 761276 3ae945fb4a84f7388b5e81f1bf67c1cd64519105
parent 761275 839b847c943e0908bf75da5915f37ddfe253037f
child 761277 17ec5ecc5057aa69378e260aff120b0317efd0af
push id100926
push userrwood@mozilla.com
push dateWed, 28 Feb 2018 21:51:29 +0000
reviewersaki
bugs1439876
milestone60.0a1
Bug 1439876 - Add scriptworker version bumping. r=aki
taskcluster/ci/release-version-bump/kind.yml
taskcluster/taskgraph/transforms/release_version_bump.py
taskcluster/taskgraph/transforms/task.py
taskcluster/taskgraph/util/workertypes.py
--- a/taskcluster/ci/release-version-bump/kind.yml
+++ b/taskcluster/ci/release-version-bump/kind.yml
@@ -1,45 +1,56 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 loader: taskgraph.loader.transform:loader
 
 transforms:
-   - taskgraph.transforms.release_deps:transforms
-   - taskgraph.transforms.job:transforms
-   - taskgraph.transforms.release_notifications:transforms
-   - taskgraph.transforms.task:transforms
+    - taskgraph.transforms.release_deps:transforms
+    - taskgraph.transforms.release_version_bump:transforms
+    - taskgraph.transforms.release_notifications:transforms
+    - taskgraph.transforms.task:transforms
 
 kind-dependencies:
-   - beetmover-cdns
+    - beetmover-cdns
 
 job-defaults:
-   description: Release Promotion version bump
-   worker-type: buildbot-bridge/buildbot-bridge
-   run-on-projects: []
-   shipping-phase: ship
-   run:
-      using: buildbot
-      release-promotion: true
+    description: Release Promotion version bump/tag
+    run-on-projects: []
+    shipping-phase: ship
+    worker-type: scriptworker-prov-v1/treescript-v1
+    worker:
+        implementation: treescript
+        tag: true
+        bump: true
+        bump-files:
+            by-project:
+                default: ["browser/config/version_display.txt"]
+                mozilla-release:
+                    - "browser/config/version.txt"
+                    - "browser/config/version_display.txt"
+                    - "config/milestone.txt"
+                mozilla-esr52:
+                    - "browser/config/version.txt"
+                    - "browser/config/version_display.txt"
+                    - "config/milestone.txt"
+        push:
+            by-project:
+                mozilla-beta: true
+                mozilla-release: true
+                mozilla-esr52: true
+                maple: true
+                birch: true
+                default: false
 
 jobs:
-   fennec:
-      name: fennec-version-bump
-      shipping-product: fennec
-      run:
-         product: fennec
-         buildername: release-{branch}-fennec_version_bump
+    fennec:
+        name: fennec-version-bump
+        shipping-product: fennec
 
-   firefox:
-      name: firefox-version-bump
-      shipping-product: firefox
-      run:
-         product: firefox
-         buildername: release-{branch}-firefox_version_bump
+    firefox:
+        name: firefox-version-bump
+        shipping-product: firefox
 
-   devedition:
-      name: devedition-version-bump
-      shipping-product: devedition
-      run:
-         product: devedition
-         buildername: release-{branch}-devedition_version_bump
+    devedition:
+        name: devedition-version-bump
+        shipping-product: devedition
new file mode 100644
--- /dev/null
+++ b/taskcluster/taskgraph/transforms/release_version_bump.py
@@ -0,0 +1,27 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+"""
+Transform the update generation task into an actual task description.
+"""
+
+from __future__ import absolute_import, print_function, unicode_literals
+
+from taskgraph.transforms.base import TransformSequence
+from taskgraph.util.schema import resolve_keyed_by
+
+transforms = TransformSequence()
+
+
+@transforms.add
+def handle_keyed_by(config, tasks):
+    """Resolve fields that can be keyed by platform, etc."""
+    fields = [
+        'worker.push',
+        'worker.bump-files'
+    ]
+    for task in tasks:
+        for field in fields:
+            resolve_keyed_by(task, field, item_name=task['name'],
+                             project=config.params['project'])
+        yield task
--- a/taskcluster/taskgraph/transforms/task.py
+++ b/taskcluster/taskgraph/transforms/task.py
@@ -592,16 +592,23 @@ task_description_schema = Schema({
 
         # "Invalid" is a noop for try and other non-supported branches
         Required('google-play-track'): Any('production', 'beta', 'alpha', 'rollout', 'invalid'),
         Required('commit'): bool,
         Optional('rollout-percentage'): Any(int, None),
     }, {
         Required('implementation'): 'shipit',
         Required('release-name'): basestring,
+    }, {
+        Required('implementation'): 'treescript',
+        Required('tag'): bool,
+        Required('bump'): bool,
+        Optional('bump-files'): [basestring],
+        Required('force-dry-run', default=True): bool,
+        Required('push', default=False): bool
     }),
 })
 
 TC_TREEHERDER_SCHEMA_URL = 'https://github.com/taskcluster/taskcluster-treeherder/' \
                            'blob/master/schemas/task-treeherder-config.yml'
 
 
 UNKNOWN_GROUP_NAME = "Treeherder group {} (from {}) has no name; " \
@@ -1128,16 +1135,55 @@ def build_push_apk_breakpoint_payload(co
 def build_ship_it_payload(config, task, task_def):
     worker = task['worker']
 
     task_def['payload'] = {
         'release_name': worker['release-name']
     }
 
 
+@payload_builder('treescript')
+def build_treescript_payload(config, task, task_def):
+    worker = task['worker']
+    release_config = get_release_config(config)
+
+    task_def['payload'] = {}
+    task_def.setdefault('scopes', [])
+    if worker['tag']:
+        product = task['shipping-product'].upper()
+        version = release_config['version'].replace('.', '_')
+        buildnum = release_config['build_number']
+        tag_names = [
+            "{}_{}_BUILD{}".format(product, version, buildnum),
+            "{}_{}_RELEASE".format(product, version)
+        ]
+        tag_info = {
+            'tags': tag_names,
+            'revision': config.params['head_rev']
+        }
+        task_def['payload']['tag_info'] = tag_info
+        task_def['scopes'].append('project:releng:treescript:action:tagging')
+
+    if worker['bump']:
+        if not worker['bump-files']:
+            raise Exception("Version Bump requested without bump-files")
+
+        bump_info = {}
+        bump_info['next_version'] = release_config['next_version']
+        bump_info['files'] = worker['bump-files']
+        task_def['payload']['version_bump_info'] = bump_info
+        task_def['scopes'].append('project:releng:treescript:action:version_bump')
+
+    if worker['push']:
+        task_def['scopes'].append('project:releng:treescript:action:push')
+
+    if worker.get('force-dry-run'):
+        task_def['payload']['dry_run'] = True
+
+
 @payload_builder('invalid')
 def build_invalid_payload(config, task, task_def):
     task_def['payload'] = 'invalid task - should never be created'
 
 
 @payload_builder('always-optimized')
 def build_always_optimized_payload(config, task, task_def):
     task_def['payload'] = {}
--- a/taskcluster/taskgraph/util/workertypes.py
+++ b/taskcluster/taskgraph/util/workertypes.py
@@ -44,16 +44,17 @@ WORKER_TYPES = {
     'releng-hardware/gecko-t-linux-talos': ('native-engine', 'linux'),
     'scriptworker-prov-v1/balrog-dev': ('balrog', None),
     'scriptworker-prov-v1/balrogworker-v1': ('balrog', None),
     'scriptworker-prov-v1/beetmoverworker-v1': ('beetmover', None),
     'scriptworker-prov-v1/pushapk-v1': ('push-apk', None),
     "scriptworker-prov-v1/signing-linux-v1": ('scriptworker-signing', None),
     "scriptworker-prov-v1/shipit": ('shipit', None),
     "scriptworker-prov-v1/shipit-dev": ('shipit', None),
+    "scriptworker-prov-v1/treescript-v1": ('treescript', None),
     'releng-hardware/gecko-t-osx-1010': ('generic-worker', 'macosx'),
 }
 
 
 def worker_type_implementation(worker_type):
     """Get the worker implementation and OS for the given workerType, where the
     OS represents the host system, not the target OS, in the case of
     cross-compiles."""