From 22e483858ed5d216cec91d6c1da9135a29307acc Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Tue, 22 Oct 2019 14:30:09 +0300 Subject: [PATCH] ci: use YAML aliases to define branch filters for CircleCI jobs (#33321) PR Close #33321 --- .circleci/config.yml | 50 +++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 813ccc139b..bbd9832de3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -38,21 +38,26 @@ var_6: &material_unit_tests_cache_key_fallback v4-angular-material- # https://circleci.com/blog/deep-diving-into-circleci-workspaces/ var_7: &workspace_location ~/ -# Branch filter that can be specified for jobs that should only run on publish branches -# (e.g. master or the patch branch) -var_8: &publish_branches_filter - branches: - only: - - master - # e.g. 7.0.x, 7.1.x, etc. - - /\d+\.\d+\.x/ +# Filter to run a job on builds for pull requests only. +var_8: &only_on_pull_requests + filters: + branches: + only: + - /pull\/\d+/ -# Filter to ignore pull requests on a given job. -var_9: &ignore_pull_requests +# Filter to skip a job on builds for pull requests. +var_9: &skip_on_pull_requests filters: branches: ignore: - - /pull\/.*/ + - /pull\/\d+/ + +# Filter to run a job on builds for the master branch only. +var_10: &only_on_master + filters: + branches: + only: + - master # Executor Definitions # https://circleci.com/docs/2.0/reusing-config/#authoring-reusable-executors @@ -775,15 +780,13 @@ workflows: requires: - setup - test_saucelabs_bazel: - requires: - - setup # This job is currently a PoC and a subset of `legacy-unit-tests-saucelabs`. Running on # master only to avoid wasting resources. # # TODO: Run this job on all branches (including PRs) as soon as it is not a PoC. - filters: - branches: - only: master + <<: *only_on_master + requires: + - setup - test_aio: requires: - setup @@ -810,12 +813,10 @@ workflows: requires: - build-ivy-npm-packages - aio_preview: + # Only run on PR builds. (There can be no previews for non-PR builds.) + <<: *only_on_pull_requests requires: - setup - # Only run on PR builds. (There can be no previews for non-PR builds.) - filters: - branches: - only: /pull\/\d+/ - test_aio_preview: requires: - aio_preview @@ -857,11 +858,11 @@ workflows: # This isn't strictly necessary as there is no artifact dependency, but helps economize # CI resources by not attempting to build when we know should fail. - test_win: - <<: *ignore_pull_requests + <<: *skip_on_pull_requests requires: - test - test_ivy_aot_win: - <<: *ignore_pull_requests + <<: *skip_on_pull_requests requires: - test_ivy_aot @@ -876,9 +877,6 @@ workflows: - setup triggers: - schedule: + <<: *only_on_master # Runs AIO monitoring jobs at 10:00AM every day. cron: "0 10 * * *" - filters: - branches: - only: - - master