-
Notifications
You must be signed in to change notification settings - Fork 1
94 lines (76 loc) · 2.69 KB
/
Copy pathnode.yml
File metadata and controls
94 lines (76 loc) · 2.69 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
# SPDX-FileCopyrightText: 2026 Etherpad contributors
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# Modeled on https://github.com/nextcloud/notes/blob/main/.github/workflows/node.yml
# Runs vitest plus a production build to catch regressions in the frontend bundle.
name: Node
on: pull_request
permissions:
contents: read
concurrency:
group: node-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
changes:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
src: ${{ steps.changes.outputs.src }}
steps:
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
id: changes
continue-on-error: true
with:
filters: |
src:
- '.github/workflows/node.yml'
- 'package.json'
- 'package-lock.json'
- 'vite.config.*'
- 'vitest.config.*'
- 'src/**'
- 'js/**'
- 'tests/js/**'
build-and-test:
runs-on: ubuntu-latest
needs: changes
if: needs.changes.outputs.src != 'false'
name: npm build + vitest
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Read package.json node and npm engines
id: versions
uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
with:
fallbackNode: '^20'
fallbackNpm: '^10'
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ steps.versions.outputs.nodeVersion }}
cache: npm
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}'
- name: Install dependencies
run: npm ci
- name: Run vitest
run: npm test
- name: Production build
run: npm run build
- name: Fail if built assets are stale
# The committed js/ bundles must match a fresh build of src/.
# Use `git status --porcelain` (not `git diff`) so a brand-new,
# still-untracked chunk/entry point also fails the check.
# If this fails, run `npm run build` locally and commit js/.
run: |
changes="$(git status --porcelain -- js/)"
if [ -n "$changes" ]; then
echo "Built js/ assets are out of date with src/. Run 'npm run build' and commit js/:" >&2
echo "$changes" >&2
exit 1
fi