Skip to content

Commit 0303ecf

Browse files
pieternfacebook-github-bot
authored andcommitted
Turn should_run_job into command
Summary: Pull Request resolved: #26160 Test Plan: Imported from OSS Differential Revision: D17366539 Pulled By: pietern fbshipit-source-id: a870d6da21925764986c6c748ad291440b78e6fd
1 parent 219a04e commit 0303ecf

File tree

7 files changed

+68
-168
lines changed

7 files changed

+68
-168
lines changed

.circleci/config.yml

Lines changed: 34 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,26 @@ setup_linux_system_environment: &setup_linux_system_environment
2828
no_output_timeout: "1h"
2929
command: ~/workspace/.circleci/scripts/setup_linux_system_environment.sh
3030

31-
# NB: This (and the command below) must be run after attaching
32-
# ~/workspace. This is NOT the default working directory (that's
33-
# ~/project); this workspace is generated by the setup job.
34-
should_run_job: &should_run_job
35-
name: Should Run Job After attach_workspace
36-
no_output_timeout: "2m"
37-
command: ~/workspace/.circleci/scripts/should_run_job.sh
38-
3931
setup_ci_environment: &setup_ci_environment
4032
name: Set Up CI Environment After attach_workspace
4133
no_output_timeout: "1h"
4234
command: ~/workspace/.circleci/scripts/setup_ci_environment.sh
4335
commands:
36+
# NB: This command must be run as the first command in a job. It
37+
# attaches the workspace at ~/workspace; this workspace is generated
38+
# by the setup job. Note that ~/workspace is not the default working
39+
# directory (that's ~/project).
40+
should_run_job:
41+
description: "Test if the job should run or not"
42+
steps:
43+
- attach_workspace:
44+
name: Attaching workspace
45+
at: ~/workspace
46+
- run:
47+
name: Should run job
48+
no_output_timeout: "2m"
49+
command: ~/workspace/.circleci/scripts/should_run_job.sh
50+
4451
brew_update:
4552
description: "Update Homebrew and install base formulae"
4653
steps:
@@ -282,10 +289,7 @@ jobs:
282289
image: ubuntu-1604:201903-01
283290
steps:
284291
# See Note [Workspace for CircleCI scripts] in job-specs-setup.yml
285-
- attach_workspace:
286-
at: ~/workspace
287-
- run:
288-
<<: *should_run_job
292+
- should_run_job
289293
- run:
290294
<<: *setup_linux_system_environment
291295
- checkout
@@ -344,10 +348,7 @@ jobs:
344348
image: ubuntu-1604:201903-01
345349
steps:
346350
# See Note [Workspace for CircleCI scripts] in job-specs-setup.yml
347-
- attach_workspace:
348-
at: ~/workspace
349-
- run:
350-
<<: *should_run_job
351+
- should_run_job
351352
- run:
352353
<<: *setup_linux_system_environment
353354
- run:
@@ -386,10 +387,7 @@ jobs:
386387
image: ubuntu-1604:201903-01
387388
steps:
388389
# See Note [Workspace for CircleCI scripts] in job-specs-setup.yml
389-
- attach_workspace:
390-
at: ~/workspace
391-
- run:
392-
<<: *should_run_job
390+
- should_run_job
393391
- run:
394392
<<: *setup_linux_system_environment
395393
- checkout
@@ -451,12 +449,9 @@ jobs:
451449
image: ubuntu-1604:201903-01
452450
steps:
453451
# See Note [Workspace for CircleCI scripts] in job-specs-setup.yml
454-
- attach_workspace:
455-
at: ~/workspace
452+
- should_run_job
456453
- run:
457454
<<: *setup_linux_system_environment
458-
- run:
459-
<<: *should_run_job
460455
- run:
461456
<<: *setup_ci_environment
462457
- run:
@@ -519,10 +514,7 @@ jobs:
519514
xcode: "9.0"
520515
steps:
521516
# See Note [Workspace for CircleCI scripts] in job-specs-setup.yml
522-
- attach_workspace:
523-
at: ~/workspace
524-
- run:
525-
<<: *should_run_job
517+
- should_run_job
526518
- checkout
527519
- run_brew_for_macos_build
528520
- run:
@@ -601,10 +593,7 @@ jobs:
601593
<<: *binary_linux_build_params
602594
steps:
603595
# See Note [Workspace for CircleCI scripts] in job-specs-setup.yml
604-
- attach_workspace:
605-
at: ~/workspace
606-
- run:
607-
<<: *should_run_job
596+
- should_run_job
608597
- run:
609598
<<: *binary_checkout
610599
- run:
@@ -658,13 +647,10 @@ jobs:
658647
image: ubuntu-1604:201903-01
659648
steps:
660649
# See Note [Workspace for CircleCI scripts] in job-specs-setup.yml
661-
- attach_workspace:
662-
at: ~/workspace
650+
- should_run_job
663651
# TODO: We shouldn't attach the workspace multiple times
664652
- attach_workspace:
665653
at: /home/circleci/project
666-
- run:
667-
<<: *should_run_job
668654
- run:
669655
<<: *setup_linux_system_environment
670656
- run:
@@ -686,10 +672,7 @@ jobs:
686672
image: ubuntu-1604:201903-01
687673
steps:
688674
# See Note [Workspace for CircleCI scripts] in job-specs-setup.yml
689-
- attach_workspace:
690-
at: ~/workspace
691-
- run:
692-
<<: *should_run_job
675+
- should_run_job
693676
- run:
694677
<<: *setup_linux_system_environment
695678
- run:
@@ -775,10 +758,7 @@ jobs:
775758
xcode: "9.0"
776759
steps:
777760
# See Note [Workspace for CircleCI scripts] in job-specs-setup.yml
778-
- attach_workspace:
779-
at: ~/workspace
780-
- run:
781-
<<: *should_run_job
761+
- should_run_job
782762
- run:
783763
<<: *binary_checkout
784764
- run:
@@ -815,10 +795,7 @@ jobs:
815795
xcode: "9.0"
816796
steps:
817797
# See Note [Workspace for CircleCI scripts] in job-specs-setup.yml
818-
- attach_workspace:
819-
at: ~/workspace
820-
- run:
821-
<<: *should_run_job
798+
- should_run_job
822799
- run:
823800
<<: *binary_checkout
824801
- run:
@@ -881,10 +858,7 @@ jobs:
881858
image: ubuntu-1604:201903-01
882859
steps:
883860
# See Note [Workspace for CircleCI scripts] in job-specs-setup.yml
884-
- attach_workspace:
885-
at: ~/workspace
886-
- run:
887-
<<: *should_run_job
861+
- should_run_job
888862
- run:
889863
<<: *setup_linux_system_environment
890864
- run:
@@ -920,10 +894,7 @@ jobs:
920894
image: ubuntu-1604:201903-01
921895
steps:
922896
# See Note [Workspace for CircleCI scripts] in job-specs-setup.yml
923-
- attach_workspace:
924-
at: ~/workspace
925-
- run:
926-
<<: *should_run_job
897+
- should_run_job
927898
- run:
928899
<<: *setup_linux_system_environment
929900
- run:
@@ -970,10 +941,7 @@ jobs:
970941
image: ubuntu-1604:201903-01
971942
steps:
972943
# See Note [Workspace for CircleCI scripts] in job-specs-setup.yml
973-
- attach_workspace:
974-
at: ~/workspace
975-
- run:
976-
<<: *should_run_job
944+
- should_run_job
977945
- run:
978946
<<: *setup_linux_system_environment
979947
- run:
@@ -1018,10 +986,7 @@ jobs:
1018986
xcode: "9.0"
1019987
steps:
1020988
# See Note [Workspace for CircleCI scripts] in job-specs-setup.yml
1021-
- attach_workspace:
1022-
at: ~/workspace
1023-
- run:
1024-
<<: *should_run_job
989+
- should_run_job
1025990
- checkout
1026991
- run_brew_for_macos_build
1027992
- run:
@@ -1062,10 +1027,7 @@ jobs:
10621027
steps:
10631028
# See Note [Workspace for CircleCI scripts] in job-specs-setup.yml
10641029
# This workspace also carries binaries from the build job
1065-
- attach_workspace:
1066-
at: ~/workspace
1067-
- run:
1068-
<<: *should_run_job
1030+
- should_run_job
10691031
- run_brew_for_macos_build
10701032
- run:
10711033
name: Test
@@ -1087,10 +1049,7 @@ jobs:
10871049
xcode: "9.0"
10881050
steps:
10891051
# See Note [Workspace for CircleCI scripts] in job-specs-setup.yml
1090-
- attach_workspace:
1091-
at: ~/workspace
1092-
- run:
1093-
<<: *should_run_job
1052+
- should_run_job
10941053
- checkout
10951054
- run_brew_for_macos_build
10961055
- run:
@@ -1140,10 +1099,7 @@ jobs:
11401099
machine:
11411100
image: ubuntu-1604:201903-01
11421101
steps:
1143-
- attach_workspace:
1144-
at: ~/workspace
1145-
- run:
1146-
<<: *should_run_job
1102+
- should_run_job
11471103
- run:
11481104
<<: *setup_linux_system_environment
11491105
- checkout
@@ -1231,10 +1187,7 @@ jobs:
12311187
machine:
12321188
image: ubuntu-1604:201903-01
12331189
steps:
1234-
- attach_workspace:
1235-
at: ~/workspace
1236-
- run:
1237-
<<: *should_run_job
1190+
- should_run_job
12381191
- run:
12391192
name: filter out not PR runs
12401193
no_output_timeout: "5m"
@@ -1279,10 +1232,7 @@ jobs:
12791232
xcode: "10.2.1"
12801233
steps:
12811234
# See Note [Workspace for CircleCI scripts] in job-specs-setup.yml
1282-
- attach_workspace:
1283-
at: ~/workspace
1284-
- run:
1285-
<<: *should_run_job
1235+
- should_run_job
12861236
- checkout
12871237
- run_brew_for_ios_build
12881238
- run:

.circleci/verbatim-sources/binary-job-specs.yml

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
<<: *binary_linux_build_params
33
steps:
44
# See Note [Workspace for CircleCI scripts] in job-specs-setup.yml
5-
- attach_workspace:
6-
at: ~/workspace
7-
- run:
8-
<<: *should_run_job
5+
- should_run_job
96
- run:
107
<<: *binary_checkout
118
- run:
@@ -59,13 +56,10 @@
5956
image: ubuntu-1604:201903-01
6057
steps:
6158
# See Note [Workspace for CircleCI scripts] in job-specs-setup.yml
62-
- attach_workspace:
63-
at: ~/workspace
59+
- should_run_job
6460
# TODO: We shouldn't attach the workspace multiple times
6561
- attach_workspace:
6662
at: /home/circleci/project
67-
- run:
68-
<<: *should_run_job
6963
- run:
7064
<<: *setup_linux_system_environment
7165
- run:
@@ -87,10 +81,7 @@
8781
image: ubuntu-1604:201903-01
8882
steps:
8983
# See Note [Workspace for CircleCI scripts] in job-specs-setup.yml
90-
- attach_workspace:
91-
at: ~/workspace
92-
- run:
93-
<<: *should_run_job
84+
- should_run_job
9485
- run:
9586
<<: *setup_linux_system_environment
9687
- run:
@@ -176,10 +167,7 @@
176167
xcode: "9.0"
177168
steps:
178169
# See Note [Workspace for CircleCI scripts] in job-specs-setup.yml
179-
- attach_workspace:
180-
at: ~/workspace
181-
- run:
182-
<<: *should_run_job
170+
- should_run_job
183171
- run:
184172
<<: *binary_checkout
185173
- run:
@@ -216,10 +204,7 @@
216204
xcode: "9.0"
217205
steps:
218206
# See Note [Workspace for CircleCI scripts] in job-specs-setup.yml
219-
- attach_workspace:
220-
at: ~/workspace
221-
- run:
222-
<<: *should_run_job
207+
- should_run_job
223208
- run:
224209
<<: *binary_checkout
225210
- run:

.circleci/verbatim-sources/caffe2-job-specs.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
image: ubuntu-1604:201903-01
55
steps:
66
# See Note [Workspace for CircleCI scripts] in job-specs-setup.yml
7-
- attach_workspace:
8-
at: ~/workspace
9-
- run:
10-
<<: *should_run_job
7+
- should_run_job
118
- run:
129
<<: *setup_linux_system_environment
1310
- checkout
@@ -69,12 +66,9 @@
6966
image: ubuntu-1604:201903-01
7067
steps:
7168
# See Note [Workspace for CircleCI scripts] in job-specs-setup.yml
72-
- attach_workspace:
73-
at: ~/workspace
69+
- should_run_job
7470
- run:
7571
<<: *setup_linux_system_environment
76-
- run:
77-
<<: *should_run_job
7872
- run:
7973
<<: *setup_ci_environment
8074
- run:
@@ -137,10 +131,7 @@
137131
xcode: "9.0"
138132
steps:
139133
# See Note [Workspace for CircleCI scripts] in job-specs-setup.yml
140-
- attach_workspace:
141-
at: ~/workspace
142-
- run:
143-
<<: *should_run_job
134+
- should_run_job
144135
- checkout
145136
- run_brew_for_macos_build
146137
- run:

.circleci/verbatim-sources/commands.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
commands:
2+
# NB: This command must be run as the first command in a job. It
3+
# attaches the workspace at ~/workspace; this workspace is generated
4+
# by the setup job. Note that ~/workspace is not the default working
5+
# directory (that's ~/project).
6+
should_run_job:
7+
description: "Test if the job should run or not"
8+
steps:
9+
- attach_workspace:
10+
name: Attaching workspace
11+
at: ~/workspace
12+
- run:
13+
name: Should run job
14+
no_output_timeout: "2m"
15+
command: ~/workspace/.circleci/scripts/should_run_job.sh
16+
217
brew_update:
318
description: "Update Homebrew and install base formulae"
419
steps:

0 commit comments

Comments
 (0)