Skip to content

Commit 8feb720

Browse files
committed
Harden Python package release checks
1 parent b119650 commit 8feb720

3 files changed

Lines changed: 101 additions & 9 deletions

File tree

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Package smoke
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
jobs:
10+
python-package:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: actions/setup-python@v5
16+
with:
17+
python-version: "3.11"
18+
19+
- name: Build and check Python distributions
20+
run: |
21+
python -m pip install --upgrade pip
22+
python -m pip install build twine check-wheel-contents
23+
python -m build --sdist --wheel
24+
python -m twine check dist/*
25+
check-wheel-contents dist/*.whl
26+
27+
- name: Verify wheel import and bundled probe artifact
28+
run: |
29+
python -m venv /tmp/intentprobe-wheel-smoke
30+
/tmp/intentprobe-wheel-smoke/bin/python -m pip install --upgrade pip
31+
/tmp/intentprobe-wheel-smoke/bin/python -m pip install --no-deps dist/*.whl
32+
cd /tmp
33+
/tmp/intentprobe-wheel-smoke/bin/python - <<'PY'
34+
from importlib.resources import files
35+
import intentprobe
36+
37+
artifact = files("intentprobe").joinpath(
38+
"scanner",
39+
"artifacts",
40+
"qwen-pooled-curated-core-l13-15-v2",
41+
)
42+
assert intentprobe.__version__ == "0.1.0"
43+
assert artifact.joinpath("metadata.json").is_file()
44+
assert artifact.joinpath("probe_weights.npz").is_file()
45+
print(f"intentprobe {intentprobe.__version__} artifact OK: {artifact}")
46+
PY
47+
48+
npm-package:
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/checkout@v4
52+
53+
- uses: actions/setup-node@v4
54+
with:
55+
node-version: "22"
56+
57+
- name: Check npm launcher package
58+
run: |
59+
npm --prefix npm run check
60+
npm --prefix npm run pack:dry
61+
npm publish ./npm --dry-run

docs/RELEASE_CHECKLIST.md

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,19 @@
33
This checklist is the local gate before telling strangers to download and try
44
intentprobe.
55

6+
## CI package smoke
7+
8+
The GitHub workflow `.github/workflows/package-smoke.yml` must pass on `main`.
9+
It builds/checks the Python wheel/sdist from a clean checkout and dry-runs the
10+
npm launcher package.
11+
612
## Clean checkout
713

814
```bash
915
git status --short --branch
10-
python -m pip install -e .
16+
python3 -m venv /tmp/intentprobe-editable-smoke
17+
/tmp/intentprobe-editable-smoke/bin/python -m pip install --upgrade pip
18+
/tmp/intentprobe-editable-smoke/bin/python -m pip install -e .
1119
```
1220

1321
## CLI smoke tests
@@ -53,14 +61,37 @@ python -m research.activation_scanner_regression \
5361
## Package build
5462

5563
```bash
56-
python -m pip install build
57-
python -m build --sdist --wheel
58-
python -m zipfile -l dist/intentprobe-0.1.0-py3-none-any.whl | \
64+
python3 -m venv /tmp/intentprobe-release-tools
65+
/tmp/intentprobe-release-tools/bin/python -m pip install --upgrade pip
66+
/tmp/intentprobe-release-tools/bin/python -m pip install build twine check-wheel-contents
67+
68+
repo=/path/to/IntentProbe
69+
sdist_dist=$(mktemp -d /tmp/intentprobe-sdist-dist.XXXXXX)
70+
sdist_src=$(mktemp -d /tmp/intentprobe-sdist-src.XXXXXX)
71+
wheel_dist=$(mktemp -d /tmp/intentprobe-wheel-dist.XXXXXX)
72+
73+
cd /tmp
74+
/tmp/intentprobe-release-tools/bin/python -m build --sdist \
75+
--outdir "$sdist_dist" "$repo"
76+
tar -xzf "$sdist_dist"/intentprobe-0.1.0.tar.gz -C "$sdist_src"
77+
cd "$sdist_src"/intentprobe-0.1.0
78+
/tmp/intentprobe-release-tools/bin/python -m build --wheel --outdir "$wheel_dist"
79+
80+
/tmp/intentprobe-release-tools/bin/python -m twine check \
81+
"$sdist_dist"/intentprobe-0.1.0.tar.gz \
82+
"$wheel_dist"/intentprobe-0.1.0-py3-none-any.whl
83+
/tmp/intentprobe-release-tools/bin/check-wheel-contents \
84+
"$wheel_dist"/intentprobe-0.1.0-py3-none-any.whl
85+
python3 -m zipfile -l "$wheel_dist"/intentprobe-0.1.0-py3-none-any.whl | \
5986
rg 'probe_weights|metadata.json|targets.py|entry_points'
60-
python -m tarfile -l dist/intentprobe-0.1.0.tar.gz | \
87+
python3 -m tarfile -l "$sdist_dist"/intentprobe-0.1.0.tar.gz | \
6188
rg 'probe_weights|metadata.json|targets.py|SECURITY.md|SAMPLE_REPORTING|RELEASE_CHECKLIST|RUNTIME_HOOKS|runtime_toy_agent'
6289
```
6390

91+
Build the release wheel from the freshly extracted sdist. The repo can have an
92+
ignored `build/` directory from setuptools, and direct local wheel builds may
93+
reuse stale `build/lib` contents.
94+
6495
## Hygiene
6596

6697
```bash

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ intentprobe = "intentprobe.cli:main"
2929
intentprobe-hook = "intentprobe.hook:main"
3030

3131
[project.urls]
32-
Homepage = "https://github.com/mcpware/intentprobe"
33-
Repository = "https://github.com/mcpware/intentprobe"
32+
Homepage = "https://github.com/mcpware/IntentProbe"
33+
Repository = "https://github.com/mcpware/IntentProbe"
34+
Issues = "https://github.com/mcpware/IntentProbe/issues"
3435

3536
[tool.setuptools]
3637
include-package-data = true
3738

3839
[tool.setuptools.packages.find]
39-
include = ["intentprobe*", "research*"]
40+
include = ["intentprobe*"]
4041

4142
[tool.setuptools.package-data]
4243
intentprobe = ["scanner/artifacts/**/*.json", "scanner/artifacts/**/*.npz"]
43-
research = ["**/*.json", "**/*.md", "**/*.txt", "**/*.mjs", "**/*.ipynb"]

0 commit comments

Comments
 (0)