-
Notifications
You must be signed in to change notification settings - Fork 1
95 lines (89 loc) · 3.02 KB
/
Copy pathtest.yml
File metadata and controls
95 lines (89 loc) · 3.02 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: Test
# Reusable test suite. Called by ci.yml (PR gate) and release.yml (pre-publish gate)
# so both run the exact same checks.
on:
workflow_call:
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
lint:
name: Lint, format & docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
prefix-key: lint
- name: Check formatting
run: cargo fmt --all --check
- name: Clippy
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
- name: Build docs
env:
RUSTDOCFLAGS: -D warnings
run: cargo doc --no-deps --all-features
- name: Doctests
run: cargo test --doc --all-features
test:
name: Test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
prefix-key: test
# The pyo3/napi cdylib crates are extension modules that cannot be linked
# as cargo test binaries; they are built via maturin/napi in the `bindings`
# job below. Everything else is tested across all three OSes.
- name: Run tests
run: cargo test --workspace --all-features --exclude code2graph-py --exclude code2graph-node
bindings:
name: Build bindings
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
prefix-key: bindings
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Build Python wheel (maturin)
run: |
pip install maturin
maturin build --release -m bindings/python/Cargo.toml
- name: Set up Node
uses: actions/setup-node@v5
with:
node-version: "22"
- name: Build Node addon (napi)
working-directory: bindings/node
run: |
npm ci
npx napi build --release --platform
# `napi build` regenerates index.js / index.d.ts from the #[napi] API.
# They are committed (so the published package ships its loader), so a
# change to the Rust binding API that wasn't regenerated leaves them stale.
# Fail the gate if the just-built files differ from what's committed.
- name: Verify committed napi bindings are in sync
working-directory: bindings/node
run: |
if ! git diff --exit-code -- index.js index.d.ts; then
echo "::error::bindings/node/index.js or index.d.ts is out of date — run 'npm run build' in bindings/node and commit the regenerated files."
exit 1
fi