Repository navigation
127 lines (109 loc) · 3.63 KB
/
Copy pathci.yml
File metadata and controls
127 lines (109 loc) · 3.63 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
name: CI
on:
pull_request:
branches: ['**']
push:
branches:
- main
- dev
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
# The ruleset on main requires "Lint, typecheck, test, build", so the workflow
# cannot be skipped with paths-ignore: a documentation-only pull request would
# never get that check and could not merge. This job decides instead, and the
# matrix is skipped while ci-result still reports.
changes:
name: Detect code changes
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
pull-requests: read
outputs:
code: ${{ steps.filter.outputs.code }}
steps:
- name: Look for changes outside documentation
id: filter
env:
GH_TOKEN: ${{ github.token }}
EVENT: ${{ github.event_name }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
set -euo pipefail
if [ "${EVENT}" != "pull_request" ]; then
echo "code=true" >> "${GITHUB_OUTPUT}"
exit 0
fi
files="$(gh api --paginate "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/files" --jq '.[].filename')"
code="$(printf '%s\n' "${files}" | grep -vE '(\.md|^LICENSE|^docs/.*|^\.github/ISSUE_TEMPLATE/.*)$' || true)"
if [ -n "${code}" ]; then
echo "code=true" >> "${GITHUB_OUTPUT}"
else
echo "code=false" >> "${GITHUB_OUTPUT}"
fi
ci:
name: Lint, typecheck, test, build (Node ${{ matrix.node-version }})
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
timeout-minutes: 20
env:
HUSKY: 0
strategy:
fail-fast: false
matrix:
# The supported range is engines >=22: the oldest supported LTS, the
# development default from .nvmrc, and the newest release.
node-version: [22, 24, latest]
steps:
- name: Checkout
uses: actions/checkout@v7
with:
persist-credentials: false
- name: Setup Node
uses: actions/setup-node@v7
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Typecheck
run: npm run typecheck
- name: Lint
run: npm run lint
- name: Format check
run: npm run format:check
# Only the runtime tree, since dev tooling never reaches a consumer. A high
# severity advisory in what we actually publish should fail the build.
- name: Audit runtime dependencies
run: npm audit --omit=dev --audit-level=high
- name: Test
run: npm test
- name: Build
run: npm run build
- name: Verify package contents
run: npm run check-npm-build
# A consumer may resolve the lowest zod our range allows, so the built
# declarations have to type-check against it (#95).
- name: Type-check consumer against zod floor
run: npm run test:zod-floor
# The ruleset on main requires a check with this exact name, which a matrix
# job no longer reports, so this job reports it once every leg is done.
ci-result:
name: Lint, typecheck, test, build
needs: [changes, ci]
if: always()
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Require every Node version to pass
env:
CHANGES_RESULT: ${{ needs.changes.result }}
CI_RESULT: ${{ needs.ci.result }}
run: |
test "${CHANGES_RESULT}" = success
test "${CI_RESULT}" = success || test "${CI_RESULT}" = skipped