-
Notifications
You must be signed in to change notification settings - Fork 40
240 lines (225 loc) · 10.6 KB
/
BuildJobs.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
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: zgosalvez/github-actions-ensure-sha-pinned-actions@38608ef4fb69adae7f1eac6eeb88e67b7d083bfd # v3.0.16
check:
name: Run code quality check
runs-on: ubuntu-latest
needs: [check-sha]
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0
- name: Setup node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.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@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
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: Run unit tests
run: pnpm run test ${{ env.since_flag }}
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.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: [build, release]
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0
- name: Setup node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.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@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
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 }}
- if: runner.os == 'Windows'
name: Set concurrency on Windows
run: echo "task_concurrency=3" >> $env:GITHUB_ENV
- if: runner.os == 'Linux'
name: Set concurrency on Linux
run: echo "task_concurrency=5" >> $GITHUB_ENV
- name: Install dependencies
run: pnpm install
- name: Run ${{ matrix.target }} task
run: pnpm run ${{ matrix.target }} --concurrency=${{ env.task_concurrency }} ${{ 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:
name: Run automated end-to-end tests
needs:
- check-sha
- mxversion
# 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:
index: [0, 1, 2, 3]
include:
- chunks: 4
steps:
- name: Download mxtools cache
uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0
- name: Setup node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.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@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
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: Check file existence
id: check_files
uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0
with:
files: "./automation/run-e2e/ctrf/*.json"
if: always()
- name: "Generating Github 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
- 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@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
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