Skip to content

Commit e2177c5

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 e2177c5

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

.circleci/config.yml

Lines changed: 20 additions & 3 deletions
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:
@@ -148,12 +156,14 @@ jobs:
148156
key: *cache_key
149157
paths:
150158
- ~/.cache/yarn
159+
- fail_fast
151160

152161
lint:
153162
executor: action-executor
154163
steps:
155164
- custom_attach_workspace
156165
- run: yarn lint
166+
- fail_fast
157167

158168
validate:
159169
executor: action-executor
@@ -178,6 +188,7 @@ jobs:
178188
command: yarn ts-circular-deps:check
179189
- run:
180190
command: yarn -s admin validate
191+
- fail_fast
181192

182193
e2e-cli:
183194
parameters:
@@ -207,6 +218,7 @@ jobs:
207218
command: |
208219
mkdir /mnt/ramdisk/e2e-yarn
209220
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/**}"
221+
- fail_fast
210222

211223
test-browsers:
212224
executor:
@@ -232,12 +244,14 @@ jobs:
232244
- run: node ./tests/legacy-cli/run_e2e ./tests/legacy-cli/e2e/tests/misc/browsers.ts --ve
233245
- run: node ./tests/legacy-cli/run_e2e ./tests/legacy-cli/e2e/tests/misc/browsers.ts
234246
- run: ./scripts/saucelabs/stop-tunnel.sh
247+
- fail_fast
235248

236249
build:
237250
executor: action-executor
238251
steps:
239252
- custom_attach_workspace
240253
- run: yarn build
254+
- fail_fast
241255

242256
test:
243257
executor: test-executor
@@ -250,6 +264,7 @@ jobs:
250264
- run:
251265
command: yarn bazel:test
252266
no_output_timeout: 20m
267+
- fail_fast
253268

254269
snapshot_publish:
255270
executor: action-executor
@@ -267,6 +282,7 @@ jobs:
267282
name: Deployment to Snapshot
268283
command: |
269284
yarn admin snapshots --verbose --githubTokenFile=${HOME}/github_token
285+
- fail_fast
270286

271287
# Windows jobs
272288
e2e-cli-win:
@@ -292,6 +308,7 @@ jobs:
292308
} else {
293309
node tests\legacy-cli\run_e2e.js --nb-shards=$env:CIRCLE_NODE_TOTAL --shard=$env:CIRCLE_NODE_INDEX
294310
}
311+
- fail_fast
295312

296313
workflows:
297314
version: 2
@@ -320,7 +337,7 @@ workflows:
320337
name: e2e-cli-ng-snapshots
321338
snapshots: true
322339
requires:
323-
- e2e-cli
340+
- build
324341
filters:
325342
branches:
326343
only:
@@ -331,7 +348,7 @@ workflows:
331348
nodeversion: '12.20'
332349
<<: *only_release_branches
333350
requires:
334-
- e2e-cli
351+
- build
335352
- test-browsers:
336353
requires:
337354
- build
@@ -347,7 +364,7 @@ workflows:
347364
# Windows jobs
348365
- e2e-cli-win:
349366
requires:
350-
- test
367+
- build
351368

352369
# Publish jobs
353370
- snapshot_publish:

0 commit comments

Comments
 (0)