-
Notifications
You must be signed in to change notification settings - Fork 10
277 lines (232 loc) · 8.41 KB
/
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
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
name: 'ci'
run-name: 'ODK Web Forms CI'
on:
workflow_dispatch:
push:
merge_group:
pull_request:
paths-ignore:
- ".vscode/**"
- "**/*.md"
- ".github/ISSUE_TEMPLATE/**"
# Automatically cancel older in-progress jobs on the same branch
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request_target' && github.head_ref || github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
changes:
runs-on: 'ubuntu-latest'
outputs:
root: ${{ steps.changes.outputs.root }}
odk-web-forms: ${{ steps.changes.outputs.odk-web-forms }}
odk-xpath: ${{ steps.changes.outputs.odk-xpath }}
tree-sitter-xpath: ${{ steps.changes.outputs.tree-sitter-xpath }}
steps:
- uses: 'actions/checkout@v3'
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
root:
- '*'
- '.github/workflows/*'
odk-web-forms:
- 'packages/odk-web-forms/**'
odk-xpath:
- 'packages/odk-xpath/**'
tree-sitter-xpath:
- 'packages/tree-sitter-xpath/grammar.ts'
- 'packages/tree-sitter-xpath/scripts/**'
- 'packages/tree-sitter-xpath/test/**'
# So the `paths-filter` action doesn't attempt to use the GitHub API
# when run on pull requests
token: ''
install-and-build:
runs-on: 'ubuntu-latest'
strategy:
matrix:
node-version: ['18.18.1', '20.8.0']
steps:
- uses: 'actions/checkout@v3'
- uses: 'volta-cli/action@v4'
with:
node-version: '${{ matrix.node-version }}'
yarn-version: '1.22.19'
- uses: 'actions/cache@v3'
id: cache-install
with:
path: |
~/.cache/ms-playwright
node_modules
**/node_modules
key: install-${{ matrix.node-version }}-${{ hashFiles('yarn.lock', 'examples/*/yarn.lock', 'packages/*/yarn.lock') }}
- uses: 'actions/cache@v3'
id: cache-build
with:
# Note: the tree-sitter-xpath .js and .wasm paths are standard for
# tree-sitter's build output. They also litter a bunch of other files
# in various build phases, several under `src` (which is why the
# grammar's TypeScript source is not there).
path: |
examples/*/dist
packages/*/dist
packages/tree-sitter-xpath/grammar.js
packages/tree-sitter-xpath/src/grammar.json
packages/tree-sitter-xpath/src/parser.c
packages/tree-sitter-xpath/src/tree_sitter/parser.h
packages/tree-sitter-xpath/tree-sitter-xpath.wasm
packages/tree-sitter-xpath/types
key: build-${{ matrix.node-version }}-${{ github.sha }}
- if: steps.cache-install.outputs.cache-hit != 'true'
run: 'yarn install --frozen-lockfile && yarn playwright install chromium firefox webkit'
- run: 'yarn build --force'
lint:
needs: ['install-and-build', 'changes']
runs-on: 'ubuntu-latest'
strategy:
matrix:
node-version: ['20.8.0']
steps:
- uses: 'actions/checkout@v3'
- uses: 'volta-cli/action@v4'
with:
node-version: '${{ matrix.node-version }}'
yarn-version: '1.22.19'
- uses: 'actions/cache@v3'
id: cache-install
with:
path: |
~/.cache/ms-playwright
node_modules
**/node_modules
key: install-${{ matrix.node-version }}-${{ hashFiles('yarn.lock', 'examples/*/yarn.lock', 'packages/*/yarn.lock') }}
fail-on-cache-miss: true
- uses: 'actions/cache@v3'
id: cache-build
with:
path: |
examples/*/dist
packages/*/dist
packages/tree-sitter-xpath/grammar.js
packages/tree-sitter-xpath/src/grammar.json
packages/tree-sitter-xpath/src/parser.c
packages/tree-sitter-xpath/src/tree_sitter/parser.h
packages/tree-sitter-xpath/tree-sitter-xpath.wasm
packages/tree-sitter-xpath/types
key: build-${{ matrix.node-version }}-${{ github.sha }}
fail-on-cache-miss: true
- run: 'yarn lint'
test-odk-web-forms:
needs: ['install-and-build', 'changes']
if: needs.changes.outputs.root == 'true' || needs.changes.outputs.odk-web-forms == 'true'
runs-on: 'ubuntu-latest'
strategy:
matrix:
node-version: ['18.18.1', '20.8.0']
steps:
- uses: 'actions/checkout@v3'
- uses: 'volta-cli/action@v4'
with:
node-version: '${{ matrix.node-version }}'
yarn-version: '1.22.19'
- uses: 'actions/cache@v3'
id: cache-install
with:
path: |
~/.cache/ms-playwright
node_modules
**/node_modules
key: install-${{ matrix.node-version }}-${{ hashFiles('yarn.lock', 'examples/*/yarn.lock', 'packages/*/yarn.lock') }}
fail-on-cache-miss: true
- uses: 'actions/cache@v3'
id: cache-build
with:
path: |
examples/*/dist
packages/*/dist
packages/tree-sitter-xpath/grammar.js
packages/tree-sitter-xpath/src/grammar.json
packages/tree-sitter-xpath/src/parser.c
packages/tree-sitter-xpath/src/tree_sitter/parser.h
packages/tree-sitter-xpath/tree-sitter-xpath.wasm
packages/tree-sitter-xpath/types
key: build-${{ matrix.node-version }}-${{ github.sha }}
fail-on-cache-miss: true
- run: 'yarn workspace @odk/web-forms test'
test-odk-xpath:
needs: ['install-and-build', 'changes']
if: needs.changes.outputs.root == 'true' || needs.changes.outputs.odk-xpath == 'true'
runs-on: 'ubuntu-latest'
strategy:
matrix:
node-version: ['18.18.1', '20.8.0']
steps:
- uses: 'actions/checkout@v3'
- uses: 'volta-cli/action@v4'
with:
node-version: '${{ matrix.node-version }}'
yarn-version: '1.22.19'
- uses: 'actions/cache@v3'
id: cache-install
with:
path: |
~/.cache/ms-playwright
node_modules
**/node_modules
key: install-${{ matrix.node-version }}-${{ hashFiles('yarn.lock', 'examples/*/yarn.lock', 'packages/*/yarn.lock') }}
fail-on-cache-miss: true
- uses: 'actions/cache@v3'
id: cache-build
with:
path: |
examples/*/dist
packages/*/dist
packages/tree-sitter-xpath/grammar.js
packages/tree-sitter-xpath/src/grammar.json
packages/tree-sitter-xpath/src/parser.c
packages/tree-sitter-xpath/src/tree_sitter/parser.h
packages/tree-sitter-xpath/tree-sitter-xpath.wasm
packages/tree-sitter-xpath/types
key: build-${{ matrix.node-version }}-${{ github.sha }}
fail-on-cache-miss: true
- run: 'yarn workspace @odk/xpath test'
test-tree-sitter-xpath:
needs: ['install-and-build', 'changes']
if: needs.changes.outputs.root == 'true' || needs.changes.outputs.tree-sitter-xpath == 'true'
runs-on: 'ubuntu-latest'
strategy:
matrix:
node-version: ['18.18.1', '20.8.0']
steps:
- uses: 'actions/checkout@v3'
- uses: 'volta-cli/action@v4'
with:
node-version: '${{ matrix.node-version }}'
yarn-version: '1.22.19'
- uses: 'actions/cache@v3'
id: cache-install
with:
path: |
~/.cache/ms-playwright
node_modules
**/node_modules
key: install-${{ matrix.node-version }}-${{ hashFiles('yarn.lock', 'examples/*/yarn.lock', 'packages/*/yarn.lock') }}
fail-on-cache-miss: true
- uses: 'actions/cache@v3'
id: cache-build
with:
path: |
examples/*/dist
packages/*/dist
packages/tree-sitter-xpath/grammar.js
packages/tree-sitter-xpath/src/grammar.json
packages/tree-sitter-xpath/src/parser.c
packages/tree-sitter-xpath/src/tree_sitter/parser.h
packages/tree-sitter-xpath/tree-sitter-xpath.wasm
packages/tree-sitter-xpath/types
key: build-${{ matrix.node-version }}-${{ github.sha }}
fail-on-cache-miss: true
- run: 'yarn workspace tree-sitter-xpath test'