-
Notifications
You must be signed in to change notification settings - Fork 23
214 lines (192 loc) · 8.89 KB
/
Copy pathci.yml
File metadata and controls
214 lines (192 loc) · 8.89 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
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
name: CI
on:
push:
branches: ["main"]
pull_request:
branches: ["*"]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
rust-lint:
name: Lint Rust Code
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v6
# Modeled on DoenetML's "Lint Rust Code" job: install a minimal
# stable toolchain with the rustfmt + clippy components, then gate
# on formatting and a warning-free clippy. Uses rustup directly
# (not the devcontainer) so the lint job stays fast and independent
# of the wasm/Node toolchain the build/test jobs need.
- name: Install toolchain
run: |
rustup set profile minimal
rustup toolchain install stable --component rustfmt --component clippy
rustup default stable
# `--all` covers the whole workspace (the wasm crate is not a
# default member; see rust-test).
- name: Cargo fmt
run: cargo fmt --all -- --check
# `--workspace --all-targets` lints the wasm crate and the test /
# example targets too, not just the default-member library.
- name: Cargo clippy
run: cargo clippy --workspace --all-targets -- -D warnings
rust-build:
name: Rust build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Build the Rust crate
uses: devcontainers/ci@v0.3
with:
runCmd: cargo build --release
rust-test:
name: Rust test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
# `--workspace`, not a bare `cargo test`: the wasm-binding crate is
# deliberately not a default member (so host builds skip it), but it
# carries unit tests (`js_match`, `parse`, `limits`) that must still
# run in CI. Its host build is cheap — wasm-bindgen compiles to a
# no-op shim off wasm32.
- name: Run the Rust test suite
uses: devcontainers/ci@v0.3
with:
runCmd: cargo test --workspace
playground-build:
name: Playground build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
# `npm run build` runs the wireit graph, which first compiles the
# Rust crate to wasm (build:wasm -> rebuild-wasm.sh) and then runs
# the typecheck and `vite build`. The pinned wasm-bindgen-cli and
# wasm32 target come from the devcontainer.
- name: Build the playground
uses: devcontainers/ci@v0.3
with:
runCmd: cd packages/playground && npm ci && npm run build
wasm-e2e:
name: wasm end-to-end
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
# Builds the browser (web-target) wasm-bindgen package and runs the
# end-to-end suite against it (ESM import + initSync, no require). The
# wasm32 target + pinned wasm-bindgen-cli come from the devcontainer.
- name: Build wasm and run the end-to-end suite
uses: devcontainers/ci@v0.3
with:
runCmd: |
npm ci
cd packages/math-expressions-rs-wasm
npm run build:wasm
npm test
js-compat-test:
name: js-compat test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
# Builds everything the published tarball contains (`build:package` —
# both wasm targets, the rs-wasm bindings, the Vite lib build), then
# runs the legacy JS suite (converted to TS) against the js-compat
# drop-in (published to npm as `math-expressions`). The full build
# rather than just the wasm, because `spec/build_{esm,umd}.spec.ts`
# exercise `dist/` — the artifact a consumer actually installs — and
# skip themselves when it is absent.
#
# This job gates. It used to end in `|| true`, from when the suite
# was hundreds of failures deep and the number was still falling;
# that made it incapable of reporting a regression, which is the
# only thing it is for now that the suite is green. The one test
# that cannot pass soundly is `it.skip`ped at its site with the
# reason, rather than left red — see `COMPAT_TEST_FAILURE_SUMMARY.md`.
- name: Build the package and run the js-compat suite
uses: devcontainers/ci@v0.3
with:
runCmd: |
npm ci
cd packages/math-expressions-js-compat
npm run build:package
npm run typecheck
npm test
package-publishability:
name: package publishability
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
# The only job that sees this package the way npm consumers will.
# Everything else here resolves through workspace symlinks and finds
# build outputs already present, which hides exactly the failures
# that matter at publish time: an unpublished `dependencies` entry,
# an `exports` target inside a git-ignored directory nothing built,
# a runtime asset missing from `files`. `verify:package` packs the
# tarball, installs it into a throwaway project outside the
# workspace, and drives it through both supported loading paths —
# Node's self-loading fallback and a browser/Web-Worker host
# injecting the `--target web` build. It gates: this one is not
# informational.
- name: Pack, install and consume the tarball
uses: devcontainers/ci@v0.3
with:
runCmd: |
npm ci
cd packages/math-expressions-js-compat
npm run verify:package
# ---- GitHub Pages: the playground at the site root, Rust API docs at /docs ----
# Deploys only on pushes to main. Requires the repo's Pages source to be set to
# "GitHub Actions" (Settings → Pages). `pages-build` assembles a single site and
# uploads it as the Pages artifact; `pages-deploy` publishes it.
pages-build:
name: Build Pages site (playground + docs)
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v6
# Built in the devcontainer (Rust + wasm toolchain + Node), then
# assembled into _site/ (a mounted path, so it persists on the runner):
# _site/ → the playground (Vite build; base = /<repo>/ so the
# project-Pages sub-path resolves asset + wasm URLs)
# _site/docs/ → `cargo doc` output, with a landing redirect
# _site/.nojekyll → serve rustdoc's files verbatim (disable Jekyll)
- name: Build playground + Rust docs and assemble the site
uses: devcontainers/ci@v0.3
with:
runCmd: |
set -euo pipefail
( cd packages/playground
npm ci
npm run build:wasm
npx vite build --base=/${{ github.event.repository.name }}/ )
cargo doc --no-deps
rm -rf _site && mkdir -p _site/docs
cp -r packages/playground/dist/. _site/
cp -r target/doc/. _site/docs/
printf '<!doctype html><meta http-equiv="refresh" content="0; url=./math_expressions/index.html">\n' > _site/docs/index.html
touch _site/.nojekyll
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: _site
pages-deploy:
name: Deploy to GitHub Pages
runs-on: ubuntu-latest
needs: pages-build
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deploy.outputs.page_url }}
# Serialize Pages deploys; never cancel one that is mid-publish.
concurrency:
group: pages
cancel-in-progress: false
steps:
- name: Deploy
id: deploy
uses: actions/deploy-pages@v4