Skip to content

Commit 9920c55

Browse files
committed
ci: introduce configuration to fail fast for CI failures
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)
1 parent 5219c05 commit 9920c55

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

.circleci/config.yml

+16-3
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ executors:
6868
# Command Definitions
6969
# https://circleci.com/docs/2.0/reusing-config/#authoring-reusable-commands
7070
commands:
71+
fail_fast:
72+
steps:
73+
- run:
74+
name: 'Cancel workflow on fail'
75+
when: on_fail
76+
command: |
77+
curl -X POST --header "Content-Type: application/json" "https://circleci.com/api/v2/workflow/${CIRCLE_WORKFLOW_ID}/cancel?circle-token=${CIRCLE_TOKEN}"
78+
7179
custom_attach_workspace:
7280
description: Attach workspace at a predefined location
7381
steps:
@@ -207,6 +215,7 @@ jobs:
207215
command: |
208216
mkdir /mnt/ramdisk/e2e-yarn
209217
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/**}"
218+
- fail_fast
210219

211220
test-browsers:
212221
executor:
@@ -232,6 +241,7 @@ jobs:
232241
- run: node ./tests/legacy-cli/run_e2e ./tests/legacy-cli/e2e/tests/misc/browsers.ts --ve
233242
- run: node ./tests/legacy-cli/run_e2e ./tests/legacy-cli/e2e/tests/misc/browsers.ts
234243
- run: ./scripts/saucelabs/stop-tunnel.sh
244+
- fail_fast
235245

236246
build:
237247
executor: action-executor
@@ -250,6 +260,7 @@ jobs:
250260
- run:
251261
command: yarn bazel:test
252262
no_output_timeout: 20m
263+
- fail_fast
253264

254265
snapshot_publish:
255266
executor: action-executor
@@ -267,6 +278,7 @@ jobs:
267278
name: Deployment to Snapshot
268279
command: |
269280
yarn admin snapshots --verbose --githubTokenFile=${HOME}/github_token
281+
- fail_fast
270282

271283
# Windows jobs
272284
e2e-cli-win:
@@ -292,6 +304,7 @@ jobs:
292304
} else {
293305
node tests\legacy-cli\run_e2e.js --nb-shards=$env:CIRCLE_NODE_TOTAL --shard=$env:CIRCLE_NODE_INDEX
294306
}
307+
- fail_fast
295308

296309
workflows:
297310
version: 2
@@ -320,7 +333,7 @@ workflows:
320333
name: e2e-cli-ng-snapshots
321334
snapshots: true
322335
requires:
323-
- e2e-cli
336+
- build
324337
filters:
325338
branches:
326339
only:
@@ -331,7 +344,7 @@ workflows:
331344
nodeversion: '12.20'
332345
<<: *only_release_branches
333346
requires:
334-
- e2e-cli
347+
- build
335348
- test-browsers:
336349
requires:
337350
- build
@@ -347,7 +360,7 @@ workflows:
347360
# Windows jobs
348361
- e2e-cli-win:
349362
requires:
350-
- test
363+
- build
351364

352365
# Publish jobs
353366
- snapshot_publish:

0 commit comments

Comments
 (0)