-
Notifications
You must be signed in to change notification settings - Fork 17
399 lines (382 loc) · 13 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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
name: CI
on: [push, pull_request]
permissions:
contents: read
pages: write
id-token: write
jobs:
build-cli:
name: Build compiler
strategy:
matrix:
target:
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
build-name: isograph_cli
artifact-name: isograph_cli-bin-linux-arm64
cross: true
- target: x86_64-apple-darwin
os: macos-latest
build-name: isograph_cli
artifact-name: isograph_cli-macos-x64
- target: aarch64-apple-darwin
os: macos-latest
build-name: isograph_cli
artifact-name: isograph_cli-macos-arm64
- target: x86_64-pc-windows-msvc
os: windows-latest
longpaths: true
build-name: isograph_cli.exe
artifact-name: isograph_cli-bin-win-x64
uses: ./.github/workflows/build-cli.yml
with:
target: ${{ matrix.target.target }}
os: ${{ matrix.target.os }}
build-name: ${{ matrix.target.build-name }}
artifact-name: ${{ matrix.target.artifact-name }}
longpaths: ${{ matrix.target.longpaths || false }}
cross: ${{ matrix.target.cross || false }}
build-cli-linux:
name: Build compiler (x86_64-unknown-linux-musl)
uses: ./.github/workflows/build-cli.yml
with:
target: x86_64-unknown-linux-musl
os: ubuntu-latest
build-name: isograph_cli
artifact-name: isograph_cli-linux-x64
build-demos:
name: Build demos
runs-on: ubuntu-latest
needs: [build-cli-linux]
strategy:
matrix:
target:
- folder: github-demo
- folder: pet-demo
- folder: vite-demo
steps:
- uses: actions/checkout@v2
- name: 'Download cli binary'
uses: actions/download-artifact@v4
with:
name: isograph_cli-linux-x64
path: artifacts/linux-x64
- name: Make artifact executable
run: chmod +x ./artifacts/linux-x64/isograph_cli
- name: 'Build project'
run: ./artifacts/linux-x64/isograph_cli --config ./demos/${{ matrix.target.folder }}/isograph.config.json
- name: 'Check working directory status'
run: './scripts/check-git-status.sh'
build-json-schema:
name: Build json schema
uses: ./.github/workflows/run-cargo-bin-and-ensure-no-changes.yml
with:
binary: build_json_schema
typecheck-demos:
name: Typecheck and Lint Demos
runs-on: ubuntu-latest
strategy:
matrix:
target:
- folder: github-demo
- folder: pet-demo
- folder: vite-demo
steps:
- uses: actions/checkout@v2
- uses: pnpm/action-setup@v2
- name: Use Node.js 22
uses: actions/setup-node@v3
with:
node-version: 22
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
# TODO reuse some artifacts or something, we're doing this in multiple steps
- name: Build JS files
run: pnpm -r compile
- name: Typecheck
run: cd ./demos/${{ matrix.target.folder }} && pnpm tsc
- name: Lint
run: cd ./demos/${{ matrix.target.folder }} && pnpm lint
build-js-packages:
name: Build js packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: pnpm/action-setup@v2
- name: Use Node.js 22
uses: actions/setup-node@v3
with:
node-version: 22
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
- name: Build
run: pnpm -r compile
- name: Run unit tests
# Note: unit tests have to run after building, because the unit tests
# rely on Isograph, which relies on @isograph/react being a valid input
#
# This can be overcome, if necessary, e.g. if "@isograph/react" was a
# parameter passed to the CLI.
run: pnpm test
build-website:
name: Build website
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./docs-website
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
- name: Use Node.js 22
uses: actions/setup-node@v3
with:
node-version: 22
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
- name: Build website
run: pnpm build
- name: Upload artifact
id: upload-artifact
uses: actions/upload-artifact@v4
with:
name: docusaurus-build
# upload-artifact ignores working-directory, seemingly, though
# the docs indicate otherwise.
path: docs-website/build/
retention-days: 1
if-no-files-found: error
prettier:
name: Run prettier
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
- name: Use Node.js 22
uses: actions/setup-node@v3
with:
node-version: 22
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
- name: Run prettier
run: pnpm run format-prettier
- name: 'Check working directory status'
run: './scripts/check-git-status.sh'
rustfmt:
name: Run cargo fmt and clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
components: rustfmt
- name: Run cargo fmt
run: cargo fmt
- name: Run cargo clippy
run: cargo clippy
- name: 'Check working directory status'
run: './scripts/check-git-status.sh'
cargo-test:
name: Run cargo test (excluding relay tests)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
components: rustfmt
- name: Run cargo test
run: cargo test
build-fixtures:
name: Build fixtures
uses: ./.github/workflows/run-cargo-bin-and-ensure-no-changes.yml
with:
binary: generate_isograph_fixtures
all-checks-passed:
name: All checks passed
runs-on: ubuntu-latest
needs:
[
build-fixtures,
build-js-packages,
build-cli,
build-cli-linux,
build-json-schema,
build-demos,
build-website,
prettier,
rustfmt,
cargo-test,
typecheck-demos,
]
steps:
- name: Do nothing
run: echo Isograph is awesome!
deploy-website:
name: Deploy website
runs-on: ubuntu-latest
needs: [all-checks-passed]
if: github.event_name == 'push' && github.repository == 'isographlabs/isograph' && github.ref == 'refs/heads/main' || github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
defaults:
run:
working-directory: ./docs-website
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
- name: Use Node.js 22
uses: actions/setup-node@v3
with:
node-version: 22
cache: 'pnpm'
- name: 'Download build folder'
uses: actions/download-artifact@v4
with:
name: docusaurus-build
path: docs-website/build
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload custom
run: tar --dereference --hard-dereference --directory "build" -cvf "$RUNNER_TEMP/artifact.tar" --exclude=.git --exclude =.github .
- name: Upload artifact
id: upload-artifact
uses: actions/upload-artifact@v4
with:
name: github-pages
path: ${{ runner.temp }}/artifact.tar
retention-days: 1
if-no-files-found: error
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
main-release:
name: Release packages to NPM
runs-on: macos-latest
if: github.event_name == 'push' && github.repository == 'isographlabs/isograph' && github.ref == 'refs/heads/main' || github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
needs: [all-checks-passed]
steps:
- uses: actions/checkout@v2
- uses: pnpm/action-setup@v2
- uses: actions/setup-node@v2
with:
node-version: 22
registry-url: https://registry.npmjs.org/
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
- name: Change package versions to commit
run: pnpm gulp setMainVersion
env:
RELEASE_COMMIT_SHA: ${{ github.sha }}
# TODO reuse this somehow?
- name: Build
run: pnpm -r compile
- name: Download artifact isograph_cli-linux-x64
uses: actions/download-artifact@v4
with:
name: isograph_cli-linux-x64
path: libs/isograph-compiler/artifacts/linux-x64
- name: Download artifact isograph_cli-bin-linux-arm64
uses: actions/download-artifact@v4
with:
name: isograph_cli-bin-linux-arm64
path: libs/isograph-compiler/artifacts/linux-arm64
- name: Download artifact isograph_cli-macos-x64
uses: actions/download-artifact@v4
with:
name: isograph_cli-macos-x64
path: libs/isograph-compiler/artifacts/macos-x64
- name: Download artifact isograph_cli-macos-arm64
uses: actions/download-artifact@v4
with:
name: isograph_cli-macos-arm64
path: libs/isograph-compiler/artifacts/macos-arm64
- name: Download artifact isograph_cli-bin-win-x64
uses: actions/download-artifact@v4
with:
name: isograph_cli-bin-win-x64
path: libs/isograph-compiler/artifacts/win-x64
- name: Mark binaries as executable
run: |
chmod +x libs/isograph-compiler/artifacts/linux-x64/isograph_cli
chmod +x libs/isograph-compiler/artifacts/linux-arm64/isograph_cli
chmod +x libs/isograph-compiler/artifacts/macos-x64/isograph_cli
chmod +x libs/isograph-compiler/artifacts/macos-arm64/isograph_cli
chmod +x libs/isograph-compiler/artifacts/win-x64/isograph_cli.exe
- name: Publish to NPM
run: |
for pkg in libs/*; do
echo PUBLISHING $pkg
cd $pkg
npm publish --tag main
cd ../..
done
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
versioned-release:
name: Release packages to NPM (latest)
runs-on: macos-latest
if: github.event_name == 'push' && github.repository == 'isographlabs/isograph' && github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
needs: [all-checks-passed]
steps:
- uses: actions/checkout@v2
- uses: pnpm/action-setup@v2
- uses: actions/setup-node@v2
with:
node-version: 22
registry-url: https://registry.npmjs.org/
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
# - name: Change package versions to commit
# run: pnpm gulp setMainVersion
# # TODO do this less hackily
- name: Build
run: pnpm -r compile
- name: Download artifact isograph_cli-linux-x64
uses: actions/download-artifact@v4
with:
name: isograph_cli-linux-x64
path: libs/isograph-compiler/artifacts/linux-x64
- name: Download artifact isograph_cli-bin-linux-arm64
uses: actions/download-artifact@v4
with:
name: isograph_cli-bin-linux-arm64
path: libs/isograph-compiler/artifacts/linux-arm64
- name: Download artifact isograph_cli-macos-x64
uses: actions/download-artifact@v4
with:
name: isograph_cli-macos-x64
path: libs/isograph-compiler/artifacts/macos-x64
- name: Download artifact isograph_cli-macos-arm64
uses: actions/download-artifact@v4
with:
name: isograph_cli-macos-arm64
path: libs/isograph-compiler/artifacts/macos-arm64
- name: Download artifact isograph_cli-bin-win-x64
uses: actions/download-artifact@v4
with:
name: isograph_cli-bin-win-x64
path: libs/isograph-compiler/artifacts/win-x64
- name: Mark binaries as executable
run: |
chmod +x libs/isograph-compiler/artifacts/linux-x64/isograph_cli
chmod +x libs/isograph-compiler/artifacts/linux-arm64/isograph_cli
chmod +x libs/isograph-compiler/artifacts/macos-x64/isograph_cli
chmod +x libs/isograph-compiler/artifacts/macos-arm64/isograph_cli
chmod +x libs/isograph-compiler/artifacts/win-x64/isograph_cli.exe
- name: Publish latest version to NPM
run: |
for pkg in libs/*; do
echo PUBLISHING $pkg
cd $pkg
npm publish --tag latest
cd ../..
done
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}