-
Notifications
You must be signed in to change notification settings - Fork 2
170 lines (163 loc) · 5.88 KB
/
Copy pathtest.yml
File metadata and controls
170 lines (163 loc) · 5.88 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
# SPDX-License-Identifier: Apache-2.0
name: Test
# Reusable test suite. Called by ci.yml and Release Prepare so both run the same gates.
on:
workflow_call:
inputs:
skip_bindings:
description: "Skip binding compilation when an equivalent release matrix runs it"
required: false
default: false
type: boolean
source_ref:
description: "Immutable source commit for release callers"
required: false
default: ""
type: string
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
lint:
name: Lint, format & docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.source_ref || github.sha }}
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
prefix-key: lint
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Test release helper and workflow contracts
run: |
python -m pip install PyYAML
python scripts/release/tests/test_contracts.py
- name: Lint GitHub Actions workflows
uses: docker://rhysd/actionlint:1.7.7
- 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
with:
ref: ${{ inputs.source_ref || github.sha }}
- 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
packaging:
name: Install CLI from source
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.source_ref || github.sha }}
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
prefix-key: packaging
# Dependent package verification runs in release after its exact core
# version is available from crates.io. PRs still prove the install surface.
- name: Install and run CLI from source
shell: bash
run: |
set -euo pipefail
INSTALL_ROOT="$(mktemp -d)"
cargo install --path cli --root "$INSTALL_ROOT"
"$INSTALL_ROOT/bin/code2graph" --help
bindings:
if: ${{ !inputs.skip_bindings }}
name: Build bindings (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.source_ref || github.sha }}
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
prefix-key: bindings
- name: Set up Python
if: matrix.os == 'ubuntu-latest'
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Build Python wheel (maturin)
if: matrix.os == 'ubuntu-latest'
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
npm run build
# `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
shell: bash
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
- name: Verify host native addon loads
working-directory: bindings/node
run: node -e "const addon=require('./'); if (!addon.languageOf('sample.rs')) process.exit(1)"
- name: Install Pi package test dependencies against this built addon
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
set -euo pipefail
STAGE="$(mktemp -d)"
mkdir -p "$STAGE/core"
(cd bindings/node && npm pack --pack-destination "$STAGE/core")
CORE_TGZ="$(find "$STAGE/core" -name '*.tgz' -print -quit)"
cd bindings/pi
npm install --no-save --package-lock=false "$CORE_TGZ" ignore tsx typescript @types/node @earendil-works/pi-ai @earendil-works/pi-coding-agent @earendil-works/pi-tui
npm install --global @earendil-works/pi-coding-agent@latest
- name: Validate packed Pi package through Pi loader and worker scan
if: matrix.os == 'ubuntu-latest'
working-directory: bindings/pi
run: npm run test:all