-
Notifications
You must be signed in to change notification settings - Fork 2
181 lines (166 loc) · 6.05 KB
/
Copy pathci.yml
File metadata and controls
181 lines (166 loc) · 6.05 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
name: CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
jobs:
check:
name: Check & Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Rustfmt
run: cargo fmt --all -- --check
- name: Clippy
# Rust 1.97 added manual_filter; existing crud code is unrelated to this PR.
run: cargo clippy --quiet --all-targets --all-features -- -D warnings -A clippy::manual_filter
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Run Tests
run: cargo test --quiet --all-features
version-check:
name: Version Consistency
if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Check version consistency
run: |
for f in Cargo.toml npm/package.json python/pyproject.toml; do
[ -f "$f" ] || { echo "::error::Required manifest not found: $f"; exit 1; }
done
CARGO_VER=$(python3 -c "import tomllib; print(tomllib.load(open('Cargo.toml','rb'))['package']['version'])")
NPM_VER=$(python3 -c "import json; print(json.load(open('npm/package.json'))['version'])")
PYPI_VER_RAW=$(python3 -c "import tomllib; print(tomllib.load(open('python/pyproject.toml','rb'))['project']['version'])")
# Normalise PEP 440 dev versions: 0.1.6.dev0 → 0.1.6-dev
PYPI_VER=$(echo "$PYPI_VER_RAW" | sed 's/\.dev[0-9]*$/-dev/')
echo "Cargo: $CARGO_VER | npm: $NPM_VER | PyPI: $PYPI_VER (raw: $PYPI_VER_RAW)"
if [ "$CARGO_VER" != "$NPM_VER" ] || [ "$CARGO_VER" != "$PYPI_VER" ]; then
echo "::error::Version mismatch: Cargo=$CARGO_VER npm=$NPM_VER PyPI=$PYPI_VER"
exit 1
fi
echo "All versions match: $CARGO_VER"
python-wrapper-test:
name: Python Wrapper (${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.13"]
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install wrapper package
run: python -m pip install --disable-pip-version-check -e ./python
- name: Run wrapper tests
run: python -m unittest discover -s python/tests -v
shell-installer-test:
name: Shell Installer Integrity (${{ matrix.hash-tool }} on ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
hash-tool: sha256sum
- os: macos-latest
hash-tool: shasum
- os: ubuntu-latest
hash-tool: openssl
env:
MAG_TEST_HASH_TOOL: ${{ matrix.hash-tool }}
steps:
- uses: actions/checkout@v7
- name: Run installer checksum tests
run: sh tests/install_checksum_test.sh
benchmark:
name: Benchmark Gate
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Test retrieval benchmark classifier
run: python3 -m unittest tests/test_retrieval_benchmark_gate.py
- name: Detect retrieval and scoring changes
id: filter
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
required="$(python3 scripts/retrieval_benchmark_gate.py --base "$BASE_SHA" --head "$HEAD_SHA")"
case "$required" in
true|false) ;;
*) echo "::error::Unexpected classifier output: $required"; exit 1 ;;
esac
echo "required=$required" >> "$GITHUB_OUTPUT"
- name: Install Rust
if: steps.filter.outputs.required == 'true'
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust build artifacts
if: steps.filter.outputs.required == 'true'
uses: Swatinem/rust-cache@v2
- name: Run benchmark gate
if: steps.filter.outputs.required == 'true'
run: ./scripts/bench.sh --gate
smoke-test:
name: Smoke Test
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v7
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust build artifacts
uses: Swatinem/rust-cache@v2
- name: Run smoke test
run: bash scripts/smoke-test.sh
npm-install-test:
name: npm Install Test
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v7
- name: Install Node 20
uses: actions/setup-node@v6
with:
node-version: '20'
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust build artifacts
uses: Swatinem/rust-cache@v2
- name: Build release binary
run: cargo build --release
- name: Test npm install
run: |
cd npm
# Pack and install globally using the local binary
MAG_BINARY_PATH="$GITHUB_WORKSPACE/target/release/mag" npm install -g "$(npm pack -q)"
# Verify the wrapper exists and works
mag --version
INSTALLED_VER=$(mag --version | awk '{print $2}')
CARGO_VER=$(python3 -c "import tomllib; print(tomllib.load(open('../Cargo.toml','rb'))['package']['version'])")
echo "Installed=$INSTALLED_VER Expected=$CARGO_VER"
if [ "$INSTALLED_VER" != "$CARGO_VER" ]; then
echo "::error::npm install test: version mismatch ($INSTALLED_VER != $CARGO_VER)"
exit 1
fi
echo "npm install test passed: mag $INSTALLED_VER"