-
Notifications
You must be signed in to change notification settings - Fork 2
185 lines (163 loc) · 5.44 KB
/
node-ci.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
name: Node CI
on:
pull_request:
# edited is needed because that's the trigger when the base branch is
# changed on a PR
# The rest are the defaults.
types: [edited, opened, synchronize, reopened]
# Our jobs run like this to minimize wasting resource cycles:
# 1. Prime caches for primary configuration (ubuntu on node 14).
# This way the next two jobs can run in parallel but rely on this primed
# cache.
# 2. Lint and coverage
# a. Lint
# b. Coverage
# 3. Run tests for remaining configurations
# Since these don't share caches, we don't need to prime those caches.
jobs:
prime_cache_primary:
name: Prime node_modules cache for primary configuration
env:
CI: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node-version: [20.x]
steps:
- uses: actions/checkout@v4
- name: Install & cache node_modules
uses: Khan/actions@shared-node-cache-v2
with:
node-version: ${{ matrix.node-version }}
lint:
needs: [prime_cache_primary]
name: Lint, typecheck, and coverage check
env:
CI: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node-version: [20.x]
steps:
- name: Checking out latest commit
uses: actions/checkout@v4
- name: Install & cache node_modules
uses: Khan/actions@shared-node-cache-v2
with:
node-version: ${{ matrix.node-version }}
- name: Get All Changed Files
uses: Khan/actions@get-changed-files-v2
id: changed
- id: js-ts-files
name: Find .js/.ts changed files
uses: Khan/actions@filter-files-v1
with:
changed-files: ${{ steps.changed.outputs.files }}
extensions: '.js,.jsx,.ts,.tsx'
- id: eslint-reset
uses: Khan/actions@filter-files-v1
name: Files that would trigger a full eslint run
with:
changed-files: ${{ steps.changed.outputs.files }}
files: '.eslintrc.js,yarn.lock,.eslintignore'
- name: Build so that inter-package references are resolved
run: yarn build
- name: Build Types
run: yarn build:types
# Linting / type checking
- name: Eslint
uses: Khan/actions@full-or-limited-v0
with:
full-trigger: ${{ steps.eslint-reset.outputs.filtered }}
full: yarn lint:ci .
limited-trigger: ${{ steps.js-ts-files.outputs.filtered }}
limited: yarn lint:ci {}
- name: Typecheck
if: steps.js-ts-files.outputs.filtered != '[]'
run: yarn typecheck
# Collect and record coverage
- name: Run Jest with coverage
run: yarn coverage
- name: Upload Coverage
# We don't bother collecting a record of coverage for dependabot changes
if: ${{ github.actor != 'dependabot[bot]' }}
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/coverage-final.json
fail_ci_if_error: true
- uses: Khan/actions@check-for-changeset-v1
if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
with:
exclude: .github/,.storybook/
- name: Pre-publish check
run: node utils/pre-publish-check-ci.js
# Make sure our packages aren't growing unexpectedly
# This must come last as it builds the old code last and so leaves the
# wrong code in place for the next job.
- name: Check Builds
uses: preactjs/compressed-size-action@v2
with:
# We only care about the browser ES module size, really:
pattern: "**/dist/browser/es/index.js"
# Always ignore SourceMaps and node_modules:
exclude: "{**/*.map,**/node_modules/**}"
# Clean up before a build
clean-script: "clean"
# Build production
build-script: "build:prodsizecheck"
#
# Do not place any steps after "Check Builds"
#
test:
needs: [lint]
name: Test
env:
CI: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
# We want to include all the versions we support here.
node-version: [20.x]
exclude:
# And exclude the configuration that our coverage job already
# includes.
- os: ubuntu-latest
node-version: 20.x
steps:
- uses: actions/checkout@v4
- name: Install & cache node_modules
uses: Khan/actions@shared-node-cache-v2
with:
node-version: ${{ matrix.node-version }}
- name: Get All Changed Files
uses: Khan/actions@get-changed-files-v2
id: changed
- name: Build so that inter-package references are resolved
run: yarn build
- id: jest-reset
uses: Khan/actions@filter-files-v1
name: Files that would trigger a full Jest run
with:
changed-files: ${{ steps.changed.outputs.files }}
files: |
jest.config.js
yarn.lock
test.config.js
test.transform.js
- id: js-ts-files
name: Find .js/.ts changed files
uses: Khan/actions@filter-files-v1
with:
changed-files: ${{ steps.changed.outputs.files }}
extensions: '.js,.jsx,.ts,.tsx'
- name: Jest
uses: Khan/actions@full-or-limited-v0
with:
full-trigger: ${{ steps.jest-reset.outputs.filtered }}
full: yarn test
limited-trigger: ${{ steps.js-ts-files.outputs.filtered }}
limited: yarn test --findRelatedTests --passWithNoTests {}