-
Notifications
You must be signed in to change notification settings - Fork 2
95 lines (87 loc) · 3.03 KB
/
Copy pathci.yml
File metadata and controls
95 lines (87 loc) · 3.03 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
name: CI
on:
push:
branches: [main]
pull_request:
env:
CARGO_TERM_COLOR: always
jobs:
package-versions:
name: Package versions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Verify application package versions agree
run: |
node <<'NODE'
const fs = require('node:fs');
const cargo = fs.readFileSync('Cargo.toml', 'utf8');
const cargoVersion = cargo.match(/^version\s*=\s*"([^"]+)"$/m)?.[1];
const packageJson = JSON.parse(fs.readFileSync('viewer-ui/package.json', 'utf8'));
const packageLock = JSON.parse(fs.readFileSync('viewer-ui/package-lock.json', 'utf8'));
const versions = {
'Cargo.toml': cargoVersion,
'viewer-ui/package.json': packageJson.version,
'viewer-ui/package-lock.json': packageLock.version,
};
if (!cargoVersion || Object.values(versions).some((version) => version !== cargoVersion)) {
console.error('Application package versions must match:');
for (const [file, version] of Object.entries(versions)) console.error(` ${file}: ${version ?? 'missing'}`);
process.exit(1);
}
NODE
- uses: dtolnay/rust-toolchain@stable
- name: Verify Cargo lockfile
run: cargo metadata --locked --format-version 1 > /dev/null
- name: Verify npm lockfile
run: npm ci --ignore-scripts
working-directory: viewer-ui
test:
name: Test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo build --locked
- run: cargo test --locked
- run: cargo clippy --locked --all-targets --all-features -- -D warnings
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- run: cargo fmt --check
viewer-ui:
name: Viewer frontend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: viewer-ui/package-lock.json
- run: npm ci
working-directory: viewer-ui
- run: npm run build
working-directory: viewer-ui
# dist/ is committed so `cargo install` needs no Node. If a rebuild here
# differs, the checked-in bundle is stale and the binary would ship a
# frontend that does not match the source.
- name: Check the committed bundle is up to date
run: |
if ! git diff --quiet -- viewer-ui/dist; then
echo "viewer-ui/dist is stale — run 'npm --prefix viewer-ui run build' and commit"
git diff --stat -- viewer-ui/dist
exit 1
fi