Bug 1359942: rename optimization to skip-unless-changed; r?glandium draft
authorDustin J. Mitchell <dustin@mozilla.com>
Tue, 23 May 2017 10:22:53 -0400
changeset 585123 0acb2048dd7647281a2f77d58e87715eeac4c82f
parent 581313 095aca8a91e68b8b4a723dc016becb37b9c5d1ff
child 630636 c612fbbdffebc044f8e2ccbff6f6723daf579165
push id61015
push userdmitchell@mozilla.com
push dateFri, 26 May 2017 15:29:06 +0000
reviewersglandium
bugs1359942
milestone55.0a1
Bug 1359942: rename optimization to skip-unless-changed; r?glandium MozReview-Commit-ID: 4d4zoDDJYnz
taskcluster/ci/android-stuff/kind.yml
taskcluster/docs/optimization.rst
taskcluster/taskgraph/optimize.py
taskcluster/taskgraph/transforms/job/__init__.py
taskcluster/taskgraph/transforms/task.py
--- a/taskcluster/ci/android-stuff/kind.yml
+++ b/taskcluster/ci/android-stuff/kind.yml
@@ -52,17 +52,17 @@ jobs:
               - "/bin/bash"
               - "-c"
               - "/home/worker/bin/before.sh && /home/worker/bin/build.sh && /home/worker/bin/after.sh && true\n"
             max-run-time: 36000
         scopes:
           - docker-worker:relengapi-proxy:tooltool.download.internal
           - docker-worker:relengapi-proxy:tooltool.download.public
         optimizations:
-          - - files-changed
+          - - skip-unless-changed
             - - "mobile/android/config/**"
               - "testing/mozharness/configs/builds/releng_sub_android_configs/*gradle_dependencies.py"
               - "**/*.gradle"
 
     android-test:
         description: "Android armv7 unit tests"
         treeherder:
             platform: android-4-0-armv7-api15/opt
@@ -99,17 +99,17 @@ jobs:
               # NOTE: this could probably be a job description with run.using = 'mozharness'
               - "/bin/bash"
               - "bin/build.sh"
             max-run-time: 36000
         scopes:
           - docker-worker:relengapi-proxy:tooltool.download.internal
           - docker-worker:relengapi-proxy:tooltool.download.public
         optimizations:
-          - - files-changed
+          - - skip-unless-changed
             - - "mobile/android/base/**"
               - "mobile/android/tests/background/junit4/**"
 
     android-lint:
         description: "Android lint"
         treeherder:
             platform: android-4-0-armv7-api15/opt
             kind: test
@@ -160,17 +160,17 @@ jobs:
               # NOTE: this could probably be a job description with run.using = 'mozharness'
               - "/bin/bash"
               - "bin/build.sh"
             max-run-time: 36000
         scopes:
           - docker-worker:relengapi-proxy:tooltool.download.internal
           - docker-worker:relengapi-proxy:tooltool.download.public
         optimizations:
-          - - files-changed
+          - - skip-unless-changed
             - - "mobile/android/**/*.java"
               - "mobile/android/**/*.jpeg"
               - "mobile/android/**/*.jpg"
               - "mobile/android/**/*.png"
               - "mobile/android/**/*.svg"
               - "mobile/android/**/*.xml" # Manifest & android resources
               - "mobile/android/**/*.gradle"
               - "mobile/android/**/Makefile.in"
@@ -213,17 +213,17 @@ jobs:
               # NOTE: this could probably be a job description with run.using = 'mozharness'
               - "/bin/bash"
               - "bin/build.sh"
             max-run-time: 36000
         scopes:
           - docker-worker:relengapi-proxy:tooltool.download.internal
           - docker-worker:relengapi-proxy:tooltool.download.public
         optimizations:
-          - - files-changed
+          - - skip-unless-changed
             - - "mobile/android/**/checkstyle.xml"
               - "mobile/android/**/*.java"
               - "mobile/android/**/*.gradle"
               - "mobile/android/**/Makefile.in"
               - "mobile/android/**/moz.build"
 
     android-findbugs:
         description: "Android findbugs"
@@ -265,13 +265,13 @@ jobs:
               # NOTE: this could probably be a job description with run.using = 'mozharness'
               - "/bin/bash"
               - "bin/build.sh"
             max-run-time: 36000
         scopes:
           - docker-worker:relengapi-proxy:tooltool.download.internal
           - docker-worker:relengapi-proxy:tooltool.download.public
         optimizations:
-          - - files-changed
+          - - skip-unless-changed
             - - "mobile/android/**/*.java"
               - "mobile/android/**/*.gradle"
               - "mobile/android/**/Makefile.in"
               - "mobile/android/**/moz.build"
--- a/taskcluster/docs/optimization.rst
+++ b/taskcluster/docs/optimization.rst
@@ -18,17 +18,17 @@ in post-order, meaning that each task's 
 the task itself is optimized.
 
 Each task has a ``task.optimizations`` property describing the optimization
 methods that apply.  Each is specified as a list of method and arguments. For
 example::
 
     task.optimizations = [
         ['seta'],
-        ['files-changed', ['js/**', 'tests/**']],
+        ['skip-unless-changed', ['js/**', 'tests/**']],
     ]
 
 These methods are defined in ``taskcluster/taskgraph/optimize.py``.  They are
 applied in order, and the first to return a success value causes the task to
 be optimized.
 
 Each method can return either a taskId (indicating that the given task can be
 replaced) or indicate that the task can be optimized away. If a task on which
--- a/taskcluster/taskgraph/optimize.py
+++ b/taskcluster/taskgraph/optimize.py
@@ -224,20 +224,20 @@ def opt_seta(task, params):
                          params.get('pushdate'),
                          bbb_task):
         # Always optimize away low-value tasks
         return True, None
     else:
         return False, None
 
 
-@optimization('files-changed')
+@optimization('skip-unless-changed')
 def opt_files_changed(task, params, file_patterns):
     # pushlog_id == -1 - this is the case when run from a cron.yml job
     if params.get('pushlog_id') == -1:
         return True, None
 
     changed = files_changed.check(params, file_patterns)
     if not changed:
-        logger.debug('no files found matching a pattern in `when.files-changed` for ' +
+        logger.debug('no files found matching a pattern in `skip-unless-changed` for ' +
                      task.label)
         return True, None
     return False, None
--- a/taskcluster/taskgraph/transforms/job/__init__.py
+++ b/taskcluster/taskgraph/transforms/job/__init__.py
@@ -117,17 +117,18 @@ def rewrite_when_to_optimization(config,
         files_changed.extend([
             '{}/**'.format(config.path),
             'taskcluster/taskgraph/**',
         ])
         if 'in-tree' in job['worker'].get('docker-image', {}):
             files_changed.append('taskcluster/docker/{}/**'.format(
                 job['worker']['docker-image']['in-tree']))
 
-        job.setdefault('optimizations', []).append(['files-changed', files_changed])
+        # "only when files changed" implies "skip if files have not changed"
+        job.setdefault('optimizations', []).append(['skip-unless-changed', files_changed])
 
         assert 'when' not in job
         yield job
 
 
 @transforms.add
 def make_task_description(config, jobs):
     """Given a build description, create a task description"""
--- a/taskcluster/taskgraph/transforms/task.py
+++ b/taskcluster/taskgraph/transforms/task.py
@@ -135,17 +135,17 @@ task_description_schema = Schema({
     # specified in order.  These optimizations are defined in
     # taskcluster/taskgraph/optimize.py.
     Optional('optimizations'): [Any(
         # search the index for the given index namespace, and replace this task if found
         ['index-search', basestring],
         # consult SETA and skip this task if it is low-value
         ['seta'],
         # skip this task if none of the given file patterns match
-        ['files-changed', [basestring]],
+        ['skip-unless-changed', [basestring]],
     )],
 
     # the provisioner-id/worker-type for the task.  The following parameters will
     # be substituted in this string:
     #  {level} -- the scm level of this push
     'worker-type': basestring,
 
     # Whether the job should use sccache compiler caching.