forked from angular-eslint/angular-eslint
-
Notifications
You must be signed in to change notification settings - Fork 0
241 lines (199 loc) · 9.89 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
name: CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master, 'next-major-release/**' ]
concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: true
env:
NX_CLOUD_DISTRIBUTED_EXECUTION: true
NX_VERBOSE_LOGGING: false
jobs:
create_nx_run_group:
name: Create NX_RUN_GROUP
runs-on: ubuntu-latest
outputs:
nx_run_group: ${{ steps.set_nx_run_group.outputs.nx_run_group }}
steps:
- name: Set NX_RUN_GROUP based on $GITHUB_RUN_ID and a uuid
id: set_nx_run_group
run: |
NX_RUN_GROUP="$GITHUB_RUN_ID--$(uuidgen)"
echo "::set-output name=nx_run_group::$NX_RUN_GROUP"
primary:
name: Primary
needs: [create_nx_run_group]
runs-on: ubuntu-latest
steps:
- name: Set NX_RUN_GROUP based on the output of the create_nx_run_group job
run: echo "NX_RUN_GROUP=${{ needs.create_nx_run_group.outputs.nx_run_group }}" >> $GITHUB_ENV
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v2
with:
main-branch-name: master
- name: Install node and npm based on the volta config in our package.json
uses: volta-cli/action@v1
- name: Get yarn cache directory path and node version for cache key
id: yarn-cache-dir-path
run: |
echo "::set-output name=dir::$(yarn cache dir)"
echo "::set-output name=node_version::$(node --version)"
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-node-${{ steps.yarn-cache-dir-path.outputs.node_version }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-${{ steps.yarn-cache-dir-path.outputs.node_version }}-yarn-
- name: Install dependencies (skipping postinstall)
# We use --ignore-scripts to skip automatic postinstall and give us more control over distributing build tasks
run: |
yarn --ignore-engines --frozen-lockfile --prefer-offline --ignore-scripts
yarn check-clean-workspace-after-install
- name: Check code formatting (not distributable)
run: NX_CLOUD_DISTRIBUTED_EXECUTION=false yarn format-check
- name: Run parallel distributed tasks for build, typecheck, check-configs, check-rule-docs, lint and test targets
uses: jameshenry/parallel-bash-commands@v1
with:
# Note that the typecheck target *also* typechecks tests/tools,
# whereas the build only checks src files
cmd1: yarn typecheck
cmd2: yarn build
cmd3: yarn check-configs
cmd4: yarn check-rule-docs
cmd5: yarn lint
cmd6: yarn test
- name: Run distributed integration tests with independent local registries
run: npx nx run-many --target=integration-test --all --withRegistry
- name: Publish code coverage report
run: |
bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }}
- name: Stop all running agents for this CI run
# It's important that we always run this step, otherwise in the case of any failures in preceding non-Nx steps, the agents will keep running and waste billable minutes
if: ${{ always() }}
run: npx nx-cloud stop-all-agents
agents:
name: Nx Distributed CI Agents
needs: [create_nx_run_group]
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
matrix:
agent: [1, 2, 3, 4, 5, 6]
steps:
- name: Set NX_RUN_GROUP based on the output of the create_nx_run_group job
run: echo "NX_RUN_GROUP=${{ needs.create_nx_run_group.outputs.nx_run_group }}" >> $GITHUB_ENV
- uses: actions/checkout@v2
- name: Install node and npm based on the volta config in our package.json
uses: volta-cli/action@v1
- name: Get yarn cache directory path and node version for cache key
id: yarn-cache-dir-path
run: |
echo "::set-output name=dir::$(yarn cache dir)"
echo "::set-output name=node_version::$(node --version)"
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-node-${{ steps.yarn-cache-dir-path.outputs.node_version }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-${{ steps.yarn-cache-dir-path.outputs.node_version }}-yarn-
- name: Install dependencies (skipping postinstall)
# We use --ignore-scripts to skip automatic postinstall and give us more control to distribute tasks
run: yarn --ignore-engines --frozen-lockfile --prefer-offline --ignore-scripts
- name: Start Nx Agent ${{ matrix.agent }}
run: npx nx-cloud start-agent
unit_tests_on_other_node_versions:
name: Unit tests on other supported Node versions
needs: [create_nx_run_group]
runs-on: ubuntu-latest
strategy:
matrix:
# Angular CLI explicitly only supports Node version 12 or 14 at the time of writing
node: [12]
steps:
- name: Set NX_RUN_GROUP based on the output of the create_nx_run_group job
run: echo "NX_RUN_GROUP=${{ needs.create_nx_run_group.outputs.nx_run_group }}" >> $GITHUB_ENV
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v1
with:
error-on-no-matching-tags: false
main-branch-name: master
- uses: actions/setup-node@v1
with:
# The Node.js version to configure
node-version: ${{ matrix.node }}
- name: Get yarn cache directory path and node version for cache key
id: yarn-cache-dir-path
run: |
echo "::set-output name=dir::$(yarn cache dir)"
echo "::set-output name=node_version::$(node --version)"
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-node-${{ steps.yarn-cache-dir-path.outputs.node_version }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-${{ steps.yarn-cache-dir-path.outputs.node_version }}-yarn-
- name: Install dependencies (skipping postinstall)
# We use --ignore-scripts to skip automatic postinstall and give us more control to distribute tasks
run: yarn --ignore-engines --frozen-lockfile --prefer-offline --ignore-scripts
- name: Run build targets on Node ${{ matrix.node }} (not distributable)
env:
# We cannot distribute these because the agents are set up to run the primary node version, not this alternative we are testing
NX_CLOUD_DISTRIBUTED_EXECUTION: false
run: yarn build
- name: Run test targets on Node ${{ matrix.node }} (not distributable)
env:
# We cannot distribute these because the agents are set up to run the primary node version, not this alternative we are testing
NX_CLOUD_DISTRIBUTED_EXECUTION: false
run: yarn test
publish_canary_version:
name: Publish the latest code as a canary version
runs-on: ubuntu-latest
needs: [create_nx_run_group, primary, unit_tests_on_other_node_versions]
if: github.ref == 'refs/heads/master'
steps:
- name: Set NX_RUN_GROUP based on the output of the create_nx_run_group job
run: echo "NX_RUN_GROUP=${{ needs.create_nx_run_group.outputs.nx_run_group }}" >> $GITHUB_ENV
- uses: actions/checkout@v2
# Fetch all history for all tags and branches in this job because lerna needs it
- run: git fetch --prune --unshallow
- name: Install node and npm based on the volta config in our package.json
uses: volta-cli/action@v1
- name: Get yarn cache directory path and node version for cache key
id: yarn-cache-dir-path
run: |
echo "::set-output name=dir::$(yarn cache dir)"
echo "::set-output name=node_version::$(node --version)"
- name: Apply version resolved by volta to standard Node action make authenticated npm publish easier
uses: actions/setup-node@v1
with:
node-version: ${{ steps.yarn-cache-dir-path.outputs.node_version }}
registry-url: https://registry.npmjs.org/
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-node-${{ steps.yarn-cache-dir-path.outputs.node_version }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-${{ steps.yarn-cache-dir-path.outputs.node_version }}-yarn-
- name: Install dependencies (skipping postinstall)
# We use --ignore-scripts to skip automatic postinstall and give us more control to distribute tasks
run: yarn --ignore-engines --frozen-lockfile --prefer-offline --ignore-scripts
- name: Run build ahead of publishing
# We cannot distribute this because the agents have already been stopped by this point
# but it should not matter because this should be a full cloud cache hit
run: NX_CLOUD_DISTRIBUTED_EXECUTION=false yarn build
- name: Publish all packages to npm
run: npx lerna publish --loglevel=verbose --canary --exact --force-publish --yes
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}