-
Notifications
You must be signed in to change notification settings - Fork 77
301 lines (284 loc) · 13.3 KB
/
BuildJobs.yml
File metadata and controls
301 lines (284 loc) · 13.3 KB
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
name: Run build jobs
# This workflow is main place for build jobs.
# If you need add job that will run as part of github check
# you need add it in this file.
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
since_flag: ${{ github.event_name == 'pull_request' && format('--filter "...[origin/{0}]"', github.base_ref) || '' }}
jobs:
check-sha:
name: Check SHA in GH Actions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: zgosalvez/github-actions-ensure-sha-pinned-actions@70c4af2ed5282c51ba40566d026d6647852ffa3e # v5.0.1
check:
name: Run code quality check
runs-on: ubuntu-latest
needs: [check-sha]
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
- name: Setup node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version-file: ".nvmrc"
cache: "pnpm"
- name: Get sha of main
run: echo "main_sha=$(git rev-parse origin/main)" >> $GITHUB_ENV
- name: Restore Turbo Cache
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: node_modules/.cache/turbo
# NOTE: We create new cache record for every new commit on main
# but fallback to latest entry
key: turbo-cache-${{ runner.os }}-lint-test-${{ env.main_sha }}
restore-keys: |
turbo-cache-${{ runner.os }}-lint-test
- name: Install dependencies
run: pnpm install
- name: Lint code
run: pnpm run lint ${{ env.since_flag }}
- name: Verify package format
run: pnpm run verify ${{ env.since_flag }}
- name: Run unit tests
run: pnpm run test ${{ env.since_flag }}
- name: Verify changelog entries
run: pnpm run -w check-changelogs
if: >-
${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'mendix/web-widgets' && github.event.pull_request.user.login != 'uicontent' }}
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
mxversion:
name: Read versions file
runs-on: ubuntu-latest
needs: [check-sha]
outputs:
mxversion: ${{ steps.readfile.outputs.mxversion }}
mxbuild_path: ${{ steps.readfile.outputs.mxbuild_path }}
mxbuild_tag: ${{ steps.readfile.outputs.mxbuild_tag }}
mxruntime_path: ${{ steps.readfile.outputs.mxruntime_path }}
mxruntime_tag: ${{ steps.readfile.outputs.mxruntime_tag }}
mx_tools_cache_key: mx-tools-cache:${{ steps.readfile.outputs.mxversion }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 1
- name: Set job outputs
id: readfile
run: |
MENDIX_VERSION=$(cat automation/run-e2e/mendix-versions.json | jq -r '.latest')
echo "mxversion=$MENDIX_VERSION" | tee -a "$GITHUB_OUTPUT"
echo "mxbuild_path=.docker-cache/mxbuild_$MENDIX_VERSION.tar" | tee -a "$GITHUB_OUTPUT"
echo "mxbuild_tag=mxbuild:$MENDIX_VERSION" | tee -a "$GITHUB_OUTPUT"
echo "mxruntime_path=.docker-cache/mxruntime_$MENDIX_VERSION.tar" | tee -a "$GITHUB_OUTPUT"
echo "mxruntime_tag=mxruntime:$MENDIX_VERSION" | tee -a "$GITHUB_OUTPUT"
build:
name: Run ${{ matrix.target }} task on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: [check-sha, check]
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
target: [release]
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
- name: Setup node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version-file: ".nvmrc"
cache: "pnpm"
- name: Get sha of main
run: echo "main_sha=$(git rev-parse origin/main)" >> ${{ runner.os == 'Windows' && '$env:GITHUB_ENV' || '$GITHUB_ENV' }}
- name: Restore Turbo Cache
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: node_modules/.cache/turbo
# NOTE: build & release tasks should have their own cache
# this is why we include matrix.target param in key
# NOTE: We create new cache record for every new commit on main
# but fallback to latest entry
key: turbo-cache-${{ runner.os }}-${{ matrix.target }}-${{ env.main_sha }}
restore-keys: |
turbo-cache-${{ runner.os }}-${{ matrix.target }}
- name: Install dependencies
run: pnpm install
- name: Run ${{ matrix.target }} task
run: pnpm run ${{ matrix.target }} --concurrency=1 ${{ env.since_flag }}
env:
# Limit memory to avoid out of memory issues
NODE_OPTIONS: "--max-old-space-size=5120 --max_old_space_size=5120"
e2e-plan:
name: Plan E2E matrix
runs-on: ubuntu-latest
needs: [check-sha]
# Same gate as the e2e job
if: >-
${{ github.event_name == 'push' ||
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == 'mendix/web-widgets' }}
outputs:
matrix: ${{ steps.compute.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
- name: Setup node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version-file: ".nvmrc"
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Compute matrix
id: compute
run: |
matrix=$(node ./automation/run-e2e/bin/run-e2e-in-chunks.mjs --print-matrix --event-name ${{ github.event_name }})
echo "matrix=$matrix" >> $GITHUB_OUTPUT
e2e:
name: Run automated end-to-end tests
needs:
- check-sha
- mxversion
- e2e-plan
# Run job only if it's push to main or PR from web-widgets, don't run for fork PRs
if: >-
${{ github.event_name == 'push' ||
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == 'mendix/web-widgets' }}
runs-on: ubuntu-latest
permissions:
packages: read
contents: read
env:
MENDIX_VERSION: ${{needs.mxversion.outputs.mxversion}}
MXBUILD_PATH: ${{needs.mxversion.outputs.mxbuild_path}}
MXBUILD_TAG: ${{needs.mxversion.outputs.mxbuild_tag}}
MXRUNTIME_PATH: ${{needs.mxversion.outputs.mxruntime_path}}
MXRUNTIME_TAG: ${{needs.mxversion.outputs.mxruntime_tag}}
strategy:
# when one test fails, DO NOT cancel the other
fail-fast: false
matrix: ${{ fromJSON(needs.e2e-plan.outputs.matrix) }}
steps:
- name: Download mxtools cache
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
id: cache
with:
path: |
${{ env.MXBUILD_PATH }}
${{ env.MXRUNTIME_PATH }}
key: ${{needs.mxversion.outputs.mx_tools_cache_key}}
- name: Load mxbuild & mxruntime images
# Skip if there is no cache
if: steps.cache.outputs.cache-hit == 'true'
run: |
docker load --input ${{ env.MXBUILD_PATH }}
docker load --input ${{ env.MXRUNTIME_PATH }}
docker image ls -a
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
- name: Setup node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version-file: ".nvmrc"
cache: "pnpm"
- name: Get sha of main
run: echo "main_sha=$(git rev-parse origin/main)" >> ${{ runner.os == 'Windows' && '$env:GITHUB_ENV' || '$GITHUB_ENV' }}
- name: Restore Turbo Cache
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: node_modules/.cache/turbo
key: turbo-cache-${{ runner.os }}-e2e-chunk-${{ matrix.index }}-${{ env.main_sha }}
restore-keys: |
turbo-cache-${{ runner.os }}-e2e-chunk-${{ matrix.index }}
- name: Install dependencies
run: pnpm install
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps chromium
- name: "Executing E2E tests"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >-
node ./automation/run-e2e/bin/run-e2e-in-chunks.mjs --chunks ${{ matrix.chunks }} --index ${{ matrix.index }} --event-name ${{ github.event_name }}
- name: "Upload CTRF reports"
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
if: always()
with:
name: ctrf-reports-${{ matrix.index }}
path: ./automation/run-e2e/ctrf/*.json
if-no-files-found: ignore
- name: "Fixing files permissions"
if: failure()
run: |
sudo find ${{ github.workspace }}/packages/* -type d -exec chmod 755 {} \;
sudo find ${{ github.workspace }}/packages/* -type f -exec chmod 644 {} \;
- name: "Archive test screenshot diff results"
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
if: failure()
with:
name: test-screenshot-results-${{ matrix.index }}
path: |
${{ github.workspace }}/packages/**/**/test-results/**/*.png
${{ github.workspace }}/packages/**/**/test-results/**/*.zip
if-no-files-found: error
e2e-report:
name: Publish E2E test summary
runs-on: ubuntu-latest
needs: [e2e]
if: always()
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 1
- name: Setup pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
- name: Setup node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version-file: ".nvmrc"
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Download CTRF reports from all chunks
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
with:
pattern: ctrf-reports-*
path: ./automation/run-e2e/ctrf
merge-multiple: true
- name: Check file existence
id: check_files
uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0
with:
files: "./automation/run-e2e/ctrf/*.json"
- name: Generate test summary
if: steps.check_files.outputs.files_exists == 'true'
run: |
pnpm --filter run-e2e run report:merge
pnpm dlx github-actions-ctrf custom ./automation/run-e2e/ctrf/merged-report.json ./automation/run-e2e/ctrf-custom-template/custom-summary.hbs