Repository navigation
279 lines (270 loc) · 10.4 KB
/
Copy pathtest.yml
File metadata and controls
279 lines (270 loc) · 10.4 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
name: Test
on:
push:
branches: [main]
pull_request:
merge_group:
permissions:
contents: read
env:
NODE_VERSION_20: "20.20.2"
NODE_VERSION_22: "22.23.1"
NODE_VERSION_24: "24.18.0"
jobs:
discover-projects:
name: Discover projects
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.projects.outputs.matrix }}
count: ${{ steps.projects.outputs.count }}
runtime-matrix: ${{ steps.projects.outputs.runtime-matrix }}
runtime-count: ${{ steps.projects.outputs.runtime-count }}
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
persist-credentials: false
fetch-depth: 0
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: ${{ env.NODE_VERSION_22 }}
- name: Build project matrix
id: projects
env:
BASE_SHA: ${{ github.event.pull_request.base.sha || github.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
run: |
matrix="$(node scripts/ci-projects.mjs --event "$GITHUB_EVENT_NAME" --base "$BASE_SHA" --head "$HEAD_SHA")"
count="$(node -e 'process.stdout.write(String(JSON.parse(process.argv[1]).include.length))' "$matrix")"
runtime_matrix="$(node -e 'const { include } = JSON.parse(process.argv[1]); process.stdout.write(JSON.stringify({ include: include.filter((project) => project.npmRuntime !== "") }))' "$matrix")"
runtime_count="$(node -e 'process.stdout.write(String(JSON.parse(process.argv[1]).include.length))' "$runtime_matrix")"
{
echo "matrix=$matrix"
echo "count=$count"
echo "runtime-matrix=$runtime_matrix"
echo "runtime-count=$runtime_count"
} >> "$GITHUB_OUTPUT"
install:
name: Install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
persist-credentials: false
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: ${{ env.NODE_VERSION_22 }}
cache: pnpm
- run: pnpm install --frozen-lockfile
quality:
name: Repository quality
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
persist-credentials: false
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: ${{ env.NODE_VERSION_22 }}
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm run test:ci-projects
- run: pnpm run docs:check
- run: pnpm run lint
- run: pnpm run check:generated
- name: Check generated files
run: git diff --exit-code
project:
name: ${{ matrix.name }}
needs: discover-projects
if: needs.discover-projects.outputs.count != '0'
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.discover-projects.outputs.matrix) }}
env:
BRAINTRUST_API_KEY: ci-test-key
GITHUB_TOKEN: ci-test-token
HONEYCOMB_API_KEY: ci-test-key
SENTRY_CLIENT_ID: ${{ vars.SENTRY_CLIENT_ID }}
SENTRY_OAUTH_CLIENT_SECRET: ci-test-secret
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
persist-credentials: false
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: ${{ env.NODE_VERSION_22 }}
cache: pnpm
- run: cp .env.example .env.local
- run: pnpm install --frozen-lockfile
- name: Build project dependencies
env:
PROJECT_NAME: ${{ matrix.name }}
run: pnpm --filter "${PROJECT_NAME}^..." --if-present run build
- name: Prepare project
if: matrix.prepare != ''
env:
PROJECT_NAME: ${{ matrix.name }}
CHECK_SCRIPT: ${{ matrix.prepare }}
run: pnpm --filter "$PROJECT_NAME" run "$CHECK_SCRIPT"
- name: Build project
if: matrix.build != ''
env:
PROJECT_NAME: ${{ matrix.name }}
CHECK_SCRIPT: ${{ matrix.build }}
run: pnpm --filter "$PROJECT_NAME" run "$CHECK_SCRIPT"
- name: Lint project
if: matrix.lint != ''
env:
PROJECT_NAME: ${{ matrix.name }}
CHECK_SCRIPT: ${{ matrix.lint }}
run: pnpm --filter "$PROJECT_NAME" run "$CHECK_SCRIPT"
- name: Typecheck project
if: matrix.typecheck != ''
env:
PROJECT_NAME: ${{ matrix.name }}
CHECK_SCRIPT: ${{ matrix.typecheck }}
run: pnpm --filter "$PROJECT_NAME" run "$CHECK_SCRIPT"
- name: Clear stale JUnit
if: matrix.junit != ''
env:
JUNIT_FILE: ${{ matrix.junit }}
run: rm -f "$JUNIT_FILE"
- name: Test project
if: matrix.test != ''
env:
PROJECT_NAME: ${{ matrix.name }}
CHECK_SCRIPT: ${{ matrix.test }}
run: pnpm --filter "$PROJECT_NAME" run "$CHECK_SCRIPT"
- name: Verify JUnit
if: matrix.junit != ''
env:
JUNIT_FILE: ${{ matrix.junit }}
run: |
test -s "$JUNIT_FILE"
python3 -c 'import sys, xml.etree.ElementTree as ET; ET.parse(sys.argv[1])' "$JUNIT_FILE"
- name: Check project policies
if: matrix.policy != ''
env:
PROJECT_NAME: ${{ matrix.name }}
CHECK_SCRIPT: ${{ matrix.policy }}
run: pnpm --filter "$PROJECT_NAME" run "$CHECK_SCRIPT"
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
if: matrix.e2e != ''
with:
node-version: ${{ env.NODE_VERSION_24 }}
cache: pnpm
- name: Run E2E tests on Node 24
if: matrix.e2e != ''
env:
PROJECT_NAME: ${{ matrix.name }}
CHECK_SCRIPT: ${{ matrix.e2e }}
SENTRY_CLI_BINARY: ${{ github.workspace }}/packages/cli/dist-bin/sentry-linux-x64
run: pnpm --filter "$PROJECT_NAME" run "$CHECK_SCRIPT"
- name: Verify coverage
if: matrix.coverage != ''
env:
COVERAGE_FILE: ${{ matrix.coverage }}
run: test -s "$COVERAGE_FILE"
- name: Check generated files
run: |
git diff --exit-code
[[ -z "$(git status --porcelain --untracked-files=all)" ]]
npm-runtime:
name: NPM package (${{ matrix.name }})
needs: discover-projects
if: needs.discover-projects.outputs.runtime-count != '0'
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.discover-projects.outputs.runtime-matrix) }}
env:
SENTRY_CLIENT_ID: ${{ vars.SENTRY_CLIENT_ID }}
SENTRY_CLI_NO_TELEMETRY: "1"
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
persist-credentials: false
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: ${{ env.NODE_VERSION_22 }}
cache: pnpm
- run: pnpm install --frozen-lockfile
- name: Build package dependencies
env:
PROJECT_NAME: ${{ matrix.name }}
run: pnpm --filter "${PROJECT_NAME}^..." --if-present run build
- name: Build and pack once on Node 22
env:
BUILD_SCRIPT: ${{ matrix.npmRuntime }}
PROJECT_NAME: ${{ matrix.name }}
run: |
pnpm --filter "$PROJECT_NAME" run "$BUILD_SCRIPT"
mkdir -p "$RUNNER_TEMP/npm-package"
pnpm --filter "$PROJECT_NAME" pack --pack-destination "$RUNNER_TEMP/npm-package"
shopt -s nullglob
packages=("$RUNNER_TEMP/npm-package"/*.tgz)
[[ "${#packages[@]}" == 1 ]]
test -s "${packages[0]}"
[[ "$(stat -c %s "${packages[0]}")" -le 52428800 ]]
mv "${packages[0]}" "$RUNNER_TEMP/npm-package/package.tgz"
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: ${{ env.NODE_VERSION_20 }}
- name: Validate packaged runtime on Node 20
env:
RUNTIME_BIN: ${{ matrix.runtimeBin }}
RUNTIME_PACKAGE: ${{ matrix.name }}
run: bash scripts/validate-npm-runtime.sh
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: ${{ env.NODE_VERSION_22 }}
- name: Validate packaged runtime on Node 22
env:
RUNTIME_BIN: ${{ matrix.runtimeBin }}
RUNTIME_PACKAGE: ${{ matrix.name }}
run: bash scripts/validate-npm-runtime.sh
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: ${{ env.NODE_VERSION_24 }}
- name: Validate packaged runtime on Node 24
env:
RUNTIME_BIN: ${{ matrix.runtimeBin }}
RUNTIME_PACKAGE: ${{ matrix.name }}
run: bash scripts/validate-npm-runtime.sh
test:
name: test
if: always()
needs: [discover-projects, install, quality, project, npm-runtime]
runs-on: ubuntu-latest
steps:
- name: Require all workspace checks
env:
DISCOVER_RESULT: ${{ needs.discover-projects.result }}
INSTALL_RESULT: ${{ needs.install.result }}
QUALITY_RESULT: ${{ needs.quality.result }}
PROJECT_RESULT: ${{ needs.project.result }}
PROJECT_COUNT: ${{ needs.discover-projects.outputs.count }}
RUNTIME_RESULT: ${{ needs.npm-runtime.result }}
RUNTIME_COUNT: ${{ needs.discover-projects.outputs.runtime-count }}
run: |
[[ "$DISCOVER_RESULT" == success ]]
[[ "$INSTALL_RESULT" == success ]]
[[ "$QUALITY_RESULT" == success ]]
expected=success
if [[ "$PROJECT_COUNT" == 0 ]]; then
expected=skipped
fi
[[ "$PROJECT_RESULT" == "$expected" ]]
expected=success
if [[ "$RUNTIME_COUNT" == 0 ]]; then
expected=skipped
fi
[[ "$RUNTIME_RESULT" == "$expected" ]]