-
-
Notifications
You must be signed in to change notification settings - Fork 11
268 lines (257 loc) · 9.01 KB
/
nodejs.yml
File metadata and controls
268 lines (257 loc) · 9.01 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
# For details of what checks are run for PRs please refer below
# docs: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
name: Node CI
on:
push:
branches: [ "master", "next" ]
tags: [ "v*" ]
pull_request:
workflow_dispatch:
schedule:
# schedule daily tests, since dependencies are not intended to be locked
# this means: at 23:42 every day
- cron: '42 23 * * *'
concurrency:
group: '${{ github.workflow }}-${{ github.ref }}'
cancel-in-progress: true
permissions: {}
env:
REPORTS_DIR: CI_reports
NODE_ACTIVE_LTS: "22" # https://nodejs.org/en/about/releases/
TESTS_REPORTS_ARTIFACT: tests-reports
jobs:
build:
name: build ${{ matrix.target }}
runs-on: "ubuntu-latest"
timeout-minutes: 30
steps:
- name: Checkout
# see https://github.com/actions/checkout
uses: actions/checkout@v6
- name: Setup Node.js ${{ env.NODE_ACTIVE_LTS }}
# see https://github.com/actions/setup-node
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_ACTIVE_LTS }}
package-manager-cache: false
- name: setup project
run: npm i --ignore-scripts
- name: build ${{ matrix.target }}
run: npm run build-dev
- name: artifact build result
# see https://github.com/actions/upload-artifact
uses: actions/upload-artifact@v6
with:
name: dist
path: dist
if-no-files-found: error
test-standard:
name: test standard
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
# see https://github.com/actions/checkout
uses: actions/checkout@v6
- name: Setup Node.js ${{ env.NODE_ACTIVE_LTS }}
# see https://github.com/actions/setup-node
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_ACTIVE_LTS }}
package-manager-cache: false
- name: setup project
run: |
npm install --ignore-scripts --loglevel=silly
- name: setup tools
run: |
echo "::group::install code-style deps"
npm run -- dev-setup:tools:code-style --ignore-scripts --loglevel=silly
echo "::endgroup::"
- name: make reports dir
run: mkdir -p "$REPORTS_DIR"
- name: test
run: >
npm run -- test:standard
--format json
--output-file "$PWD/$REPORTS_DIR/eslint.json"
- name: Annotate Code
if: ${{ failure() || success() }}
# see https://github.com/DerLev/eslint-annotations
uses: DerLev/eslint-annotations@v2
with:
eslint-report: ${{ env.REPORTS_DIR }}/eslint.json
- name: artifact eslint result
# see https://github.com/actions/upload-artifact
uses: actions/upload-artifact@v6
if: ${{ failure() }}
with:
name: ${{ env.STANDARD_REPORTS_ARTIFACT }}
path: ${{ env.REPORTS_DIR }}
if-no-files-found: error
test-dependencies:
name: test dependencies
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
# see https://github.com/actions/checkout
uses: actions/checkout@v6
- name: Setup Node.js ${{ env.NODE_ACTIVE_LTS }}
# see https://github.com/actions/setup-node
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_ACTIVE_LTS }}
package-manager-cache: false
- name: setup project
run: npm install --ignore-scripts --loglevel=silly
- name: setup tool
run: npm run -- dev-setup:tools:test-dependencies --ignore-scripts --loglevel=silly
- name: test
run: npm run -- test:dependencies -d
test-jest:
needs: [ 'build' ]
name: >
test:Jest
node${{ matrix.node-version }}
${{ matrix.os }}
${{ (matrix.experimental == true) && '[experimental]' || '' }}
timeout-minutes: 30
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- 'ubuntu-latest'
- 'windows-latest'
- 'macos-latest'
node-version:
# action based on https://github.com/actions/node-versions/releases
# see also: https://nodejs.org/en/about/previous-releases
- "25" # Current
- "24" # active LTS
- "22"
- "20"
- "20.18.0" # lowest supported
include:
- node-version: "25"
experimental: true
continue-on-error: ${{ matrix.experimental == true }}
steps:
- name: Checkout
# see https://github.com/actions/checkout
uses: actions/checkout@v6
- name: Setup Node.js ${{ matrix.node-version }}
# see https://github.com/actions/setup-node
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
package-manager-cache: false
- name: enable yarn
if: "matrix.node-version != '14.0.0'" # node14 has broken corepack
run: |-
corepack enable yarn
yarn --version
working-directory: .. # prevent evaluation of package.json
- name: install project
shell: bash
run: |
set -ex
dev_requirements='c8 jest jest-junit imurmurhash fast-glob'
npm i --ignore-scripts --omit=peer --omit=dev --only=prod --production --loglevel=silly
## rebuild deps for which scripts were ignored, or partially installed - since "ignore-scripts" was used
npm rebuild --loglevel=silly libxmljs2 || npm uninstall --no-save libxmljs2 || true
## install the needed dev-deps
npm i --ignore-scripts --loglevel=silly --no-save $dev_requirements
- name: fetch build artifact
# see https://github.com/actions/download-artifact
uses: actions/download-artifact@v7
with:
name: dist
path: dist
- name: setup test beds
run: npm run setup-tests
- name: artifact npm errors
if: ${{ failure() }}
# see https://github.com/actions/upload-artifact
uses: actions/upload-artifact@v6
with:
name: 'npm-errors_${{ matrix.os }}_node${{ matrix.node-version }}'
path: '/home/runner/.npm/_logs/*.log'
if-no-files-found: ignore
retention-days: 7
- name: test
run: npm run test:jest
env:
JEST_JUNIT_OUTPUT_DIR: ${{ env.REPORTS_DIR }}/${{ matrix.os }}_node${{ matrix.node-version }}
- name: collect coverage
if: ${{ failure() || success() }}
run: >
node -- node_modules/c8/bin/c8.js
report
--reporter clover
--reports-dir '${{ env.REPORTS_DIR }}/coverage/${{ matrix.os }}_node${{ matrix.node-version }}'
- name: artifact test reports
if: ${{ ! cancelled() }}
# see https://github.com/actions/upload-artifact
uses: actions/upload-artifact@v6
with:
name: '${{ env.TESTS_REPORTS_ARTIFACT }}_${{ matrix.os }}_node${{ matrix.node-version }}'
path: ${{ env.REPORTS_DIR }}
test-examples:
needs: [ 'build' ]
name: Example ${{ matrix.scope }}
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
scope:
- simple
env:
EXAMPLE_DIR: examples/${{ matrix.scope }}
steps:
- name: Checkout
# see https://github.com/actions/checkout
uses: actions/checkout@v6
- name: Setup Node.js ${{ env.NODE_ACTIVE_LTS }}
# see https://github.com/actions/setup-node
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_ACTIVE_LTS }}
package-manager-cache: false
- name: fetch build artifact
# see https://github.com/actions/download-artifact
uses: actions/download-artifact@v7
with:
name: dist
path: dist
- name: setup example
working-directory: ${{ env.EXAMPLE_DIR }}
run: npm i --install-links --loglevel=silly
- name: build example
working-directory: ${{ env.EXAMPLE_DIR }}
run: npm run build
report-coverage:
name: Publish test coverage
needs:
- test-jest
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: fetch test artifacts
# see https://github.com/actions/download-artifact
uses: actions/download-artifact@v7
with:
pattern: '${{ env.TESTS_REPORTS_ARTIFACT }}_*'
merge-multiple: true
path: ${{ env.REPORTS_DIR }}
- name: Run codacy-coverage-reporter
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
## see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-secrets
if: ${{ env.CODACY_PROJECT_TOKEN != '' }}
# see https://github.com/codacy/codacy-coverage-reporter-action
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ env.CODACY_PROJECT_TOKEN }}
coverage-reports: ${{ env.REPORTS_DIR }}/coverage/*/*