Skip to content

Commit

Permalink
ci: introduce configuration to fail fast for CI failures
Browse files Browse the repository at this point in the history
When failures occur on CI, we should not continue to run the CI checks as a failing case has already
been discovered.  Instead we now cancel the workflow stopping the other jobs to prevent unnecessary
resource usage.

(cherry picked from commit 314ec4e)
  • Loading branch information
josephperrott committed Jul 14, 2021
1 parent 5219c05 commit 9920c55
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ executors:
# Command Definitions
# https://circleci.com/docs/2.0/reusing-config/#authoring-reusable-commands
commands:
fail_fast:
steps:
- run:
name: 'Cancel workflow on fail'
when: on_fail
command: |
curl -X POST --header "Content-Type: application/json" "https://circleci.com/api/v2/workflow/${CIRCLE_WORKFLOW_ID}/cancel?circle-token=${CIRCLE_TOKEN}"
custom_attach_workspace:
description: Attach workspace at a predefined location
steps:
Expand Down Expand Up @@ -207,6 +215,7 @@ jobs:
command: |
mkdir /mnt/ramdisk/e2e-yarn
node ./tests/legacy-cli/run_e2e --nb-shards=${CIRCLE_NODE_TOTAL} --shard=${CIRCLE_NODE_INDEX} <<# parameters.snapshots >>--ng-snapshots<</ parameters.snapshots >> --yarn --tmpdir=/mnt/ramdisk/e2e-yarn --glob="{tests/basic/**,tests/update/**,tests/commands/add/**}"
- fail_fast

test-browsers:
executor:
Expand All @@ -232,6 +241,7 @@ jobs:
- run: node ./tests/legacy-cli/run_e2e ./tests/legacy-cli/e2e/tests/misc/browsers.ts --ve
- run: node ./tests/legacy-cli/run_e2e ./tests/legacy-cli/e2e/tests/misc/browsers.ts
- run: ./scripts/saucelabs/stop-tunnel.sh
- fail_fast

build:
executor: action-executor
Expand All @@ -250,6 +260,7 @@ jobs:
- run:
command: yarn bazel:test
no_output_timeout: 20m
- fail_fast

snapshot_publish:
executor: action-executor
Expand All @@ -267,6 +278,7 @@ jobs:
name: Deployment to Snapshot
command: |
yarn admin snapshots --verbose --githubTokenFile=${HOME}/github_token
- fail_fast

# Windows jobs
e2e-cli-win:
Expand All @@ -292,6 +304,7 @@ jobs:
} else {
node tests\legacy-cli\run_e2e.js --nb-shards=$env:CIRCLE_NODE_TOTAL --shard=$env:CIRCLE_NODE_INDEX
}
- fail_fast

workflows:
version: 2
Expand Down Expand Up @@ -320,7 +333,7 @@ workflows:
name: e2e-cli-ng-snapshots
snapshots: true
requires:
- e2e-cli
- build
filters:
branches:
only:
Expand All @@ -331,7 +344,7 @@ workflows:
nodeversion: '12.20'
<<: *only_release_branches
requires:
- e2e-cli
- build
- test-browsers:
requires:
- build
Expand All @@ -347,7 +360,7 @@ workflows:
# Windows jobs
- e2e-cli-win:
requires:
- test
- build

# Publish jobs
- snapshot_publish:
Expand Down

0 comments on commit 9920c55

Please sign in to comment.