From fc3260d87e3af9ffd2cfc4ba8fc7540b15df2454 Mon Sep 17 00:00:00 2001 From: Filipe Silva Date: Wed, 18 Sep 2019 17:23:18 +0100 Subject: [PATCH] ci: use CircleCI parameterized jobs (#32745) Parameterized jobs lets us reduce duplication of very similar jobs. See https://circleci.com/docs/2.0/reusing-config/#authoring-parameterized-jobs for more info. PR Close #32745 --- .circleci/config.yml | 81 +++++++++++++++++--------------------------- aio/README.md | 2 +- aio/package.json | 10 +++--- 3 files changed, 37 insertions(+), 56 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8a69298aa1..89a7dae848 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -205,6 +205,8 @@ commands: curl --request POST --header "Content-Type: application/json" --data "$notificationJson" $SLACK_DEV_INFRA_CI_FAILURES_WEBHOOK_URL # Job definitions +# Jobs can include parameters that are passed in the workflow job invocation. +# https://circleci.com/docs/2.0/reusing-config/#authoring-parameterized-jobs jobs: setup: executor: action-executor @@ -384,13 +386,17 @@ jobs: - run: yarn --cwd aio deploy-production test_aio_local: + parameters: + ivy: + type: boolean + default: false # Needed because the AIO tests and the PWA score test depend on Chrome being available. executor: browsers-executor steps: - custom_attach_workspace - init_environment # Build aio (with local Angular packages) - - run: yarn --cwd aio build-local-ci + - run: yarn --cwd aio build-local<<# parameters.ivy >>-with-ivy<>-ci # Run unit tests - run: yarn --cwd aio test --progress=false --watch=false # Run e2e tests @@ -398,24 +404,7 @@ jobs: # Run PWA-score tests - run: yarn --cwd aio test-pwa-score-localhost $CI_AIO_MIN_PWA_SCORE # Check the bundle sizes. - - run: yarn --cwd aio payload-size aio-local - - test_aio_local_ivy: - # Needed because the AIO tests and the PWA score test depend on Chrome being available. - executor: browsers-executor - steps: - - custom_attach_workspace - - init_environment - # Build aio with Ivy (using local Angular packages) - - run: yarn --cwd aio build-with-ivy-ci - # Run unit tests - - run: yarn --cwd aio test --progress=false --watch=false - # Run e2e tests - - run: yarn --cwd aio e2e --configuration=ci - # Run PWA-score tests - - run: yarn --cwd aio test-pwa-score-localhost $CI_AIO_MIN_PWA_SCORE - # Check the bundle sizes. - - run: yarn --cwd aio payload-size aio-local-ivy + - run: yarn --cwd aio payload-size aio-local<<# parameters.ivy >>-ivy<> test_aio_tools: executor: action-executor @@ -430,45 +419,33 @@ jobs: - run: ./aio/aio-builds-setup/scripts/test.sh test_docs_examples: + parameters: + ivy: + type: boolean + default: false executor: # Needed because the example e2e tests depend on Chrome. name: browsers-executor resource_class: xlarge - parallelism: 4 - steps: - - custom_attach_workspace - - init_environment - # Install aio - - run: yarn --cwd aio install --frozen-lockfile --non-interactive - # Run examples tests. The "CIRCLE_NODE_INDEX" will be set if "parallelism" is enabled. - # Since the parallelism is set to "3", there will be three parallel CircleCI containers - # with either "0", "1" or "2" as node index. This can be passed to the "--shard" argument. - - run: yarn --cwd aio example-e2e --setup --local --cliSpecsConcurrency=5 --shard=${CIRCLE_NODE_INDEX}/${CIRCLE_NODE_TOTAL} --retry 2 - - test_docs_examples_ivy: - executor: - # Needed because the example e2e tests depend on Chrome. - name: browsers-executor - resource_class: xlarge - # We increase the parallelism here to five while the "test_docs_examples" job runs with - # a parallelism of four. This is necessary because this job also need to run NGCC which - # takes up more time and we don't want these jobs to impact the overall CI turnaround. parallelism: 5 steps: - custom_attach_workspace - init_environment # Install aio - run: yarn --cwd aio install --frozen-lockfile --non-interactive - # Rename the Ivy packages dist folder to "dist/packages-dist" as the AIO - # package installer picks up the locally built packages from that location. - # *Note*: We could also adjust the packages installer, but given we won't have - # two different folders of Angular distributions in the future, we should keep - # the packages installer unchanged. - - run: mv dist/packages-dist-ivy-aot dist/packages-dist - # Run examples tests with ivy. The "CIRCLE_NODE_INDEX" will be set if "parallelism" is enabled. - # Since the parallelism is set to "3", there will be three parallel CircleCI containers - # with either "0", "1" or "2" as node index. This can be passed to the "--shard" argument. - - run: yarn --cwd aio example-e2e --setup --local --ivy --cliSpecsConcurrency=5 --shard=${CIRCLE_NODE_INDEX}/${CIRCLE_NODE_TOTAL} --retry 2 + - when: + condition: << parameters.ivy >> + steps: + # Rename the Ivy packages dist folder to "dist/packages-dist" as the AIO + # package installer picks up the locally built packages from that location. + # *Note*: We could also adjust the packages installer, but given we won't have + # two different folders of Angular distributions in the future, we should keep + # the packages installer unchanged. + - run: mv dist/packages-dist-ivy-aot dist/packages-dist + # Run examples tests. The "CIRCLE_NODE_INDEX" will be set if "parallelism" is enabled. + # Since the parallelism is set to "5", there will be five parallel CircleCI containers. + # with either "0", "1", etc as node index. This can be passed to the "--shard" argument. + - run: yarn --cwd aio example-e2e --setup --local <<# parameters.ivy >>--ivy<> --cliSpecsConcurrency=5 --shard=${CIRCLE_NODE_INDEX}/${CIRCLE_NODE_TOTAL} --retry 2 # This job should only be run on PR builds, where `CI_PULL_REQUEST` is not `false`. aio_preview: @@ -826,7 +803,9 @@ workflows: - test_aio_local: requires: - build-npm-packages - - test_aio_local_ivy: + - test_aio_local: + name: test_aio_local_ivy + ivy: true requires: - build-npm-packages - test_aio_tools: @@ -835,7 +814,9 @@ workflows: - test_docs_examples: requires: - build-npm-packages - - test_docs_examples_ivy: + - test_docs_examples: + name: test_docs_examples_ivy + ivy: true requires: - build-ivy-npm-packages - aio_preview: diff --git a/aio/README.md b/aio/README.md index b3144ed8db..e4690504ff 100644 --- a/aio/README.md +++ b/aio/README.md @@ -18,7 +18,7 @@ Here are the most important tasks you might need to use: * `yarn build` - create a production build of the application (after installing dependencies, boilerplate, etc). * `yarn build-local` - same as `build`, but use `setup-local` instead of `setup`. -* `yarn build-with-ivy` - same as `build-local`, but in addition also turns on `ivy` mode in aio. +* `yarn build-local-with-ivy` - same as `build-local`, but in addition also turns on `ivy` mode in aio. (Note: To turn on `ivy` mode in examples, see `yarn boilerplate:add` below.) * `yarn start` - run a development web server that watches the files; then builds the doc-viewer and reloads the page, as necessary. diff --git a/aio/package.json b/aio/package.json index de0dd1a808..e5a46cbb3c 100644 --- a/aio/package.json +++ b/aio/package.json @@ -19,10 +19,10 @@ "build-local": "yarn ~~build", "prebuild-local-ci": "yarn setup-local --no-build-packages", "build-local-ci": "yarn ~~build --progress=false", - "prebuild-with-ivy": "yarn setup-local && node scripts/switch-to-ivy", - "build-with-ivy": "yarn ~~build", - "prebuild-with-ivy-ci": "yarn setup-local --no-build-packages && node scripts/switch-to-ivy", - "build-with-ivy-ci": "yarn ~~build --progress=false", + "prebuild-local-with-ivy": "yarn setup-local && node scripts/switch-to-ivy", + "build-local-with-ivy": "yarn ~~build", + "prebuild-local-with-ivy-ci": "yarn setup-local --no-build-packages && node scripts/switch-to-ivy", + "build-local-with-ivy-ci": "yarn ~~build --progress=false", "extract-cli-command-docs": "node tools/transforms/cli-docs-package/extract-cli-commands.js 0a36071b8", "lint": "yarn check-env && yarn docs-lint && ng lint && yarn example-lint && yarn tools-lint", "test": "yarn check-env && ng test", @@ -174,4 +174,4 @@ "xregexp": "^4.0.0", "yargs": "^7.0.2" } -} \ No newline at end of file +}