Skip to content

Commit 00d9eb4

Browse files
committed
dev: Refactor CI and other stuff
.github/workflows/ci.yml: .gitignore: AGENTS.md: Justfile: Makefile: crates/codetracer-python-recorder/Cargo.lock: flake.nix: pyproject.toml: src/codetracer_pure_python_recorder/__init__.py: src/codetracer_pure_python_recorder/cli.py: Signed-off-by: Tzanko Matev <[email protected]>
1 parent ef3ffe5 commit 00d9eb4

File tree

12 files changed

+254
-14
lines changed

12 files changed

+254
-14
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,12 @@ jobs:
1515
os: [ubuntu-latest, macos-latest, windows-latest]
1616
steps:
1717
- uses: actions/checkout@v4
18-
- name: Install make on Windows
19-
if: runner.os == 'Windows'
20-
run: choco install make -y
2118
- uses: actions/setup-python@v5
2219
with:
2320
python-version: '3.x'
2421
- name: Run tests
2522
shell: bash
26-
run: make test
23+
run: python -m unittest discover -v
2724

2825
nix-tests:
2926
runs-on: ubuntu-latest
@@ -35,4 +32,24 @@ jobs:
3532
extra_nix_config: |
3633
experimental-features = nix-command flakes
3734
- name: Run tests via Nix
38-
run: nix develop --command make test
35+
run: nix develop --command just test
36+
37+
rust-smoke:
38+
name: Rust module smoke test on ${{ matrix.os }}
39+
runs-on: ${{ matrix.os }}
40+
strategy:
41+
matrix:
42+
os: [ubuntu-latest, macos-latest, windows-latest]
43+
steps:
44+
- uses: actions/checkout@v4
45+
- uses: actions/setup-python@v5
46+
with:
47+
python-version: '3.x'
48+
- uses: messense/maturin-action@v1
49+
with:
50+
command: build
51+
args: -m crates/codetracer-python-recorder/Cargo.toml --release
52+
- name: Install built wheel
53+
run: python -m pip install --upgrade pip && python -m pip install target/wheels/*.whl
54+
- name: Import smoke test
55+
run: python -c "import codetracer_python_recorder as m; print(m.hello())"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.direnv/
22
**/__pycache__/
33
.aider*
4+
.venv/
5+
**/target/

AGENTS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@ This repository contains two related projects:
88
To run the Python test suite for the pure-Python tracer, execute:
99

1010
```
11-
make test
11+
just test
1212
```
1313

1414
The tester executes a number of sample programs in `tests/programs` and compares their outputs to the fixtures in `tests/fixtures`.
1515

1616
To build and locally develop-install the Rust-backed module:
1717

1818
```
19+
just build-rust
20+
# or:
1921
maturin develop -m crates/codetracer-python-recorder/Cargo.toml
2022
```
2123

Justfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Development helpers for the monorepo
2+
3+
# Print toolchain versions to verify the dev environment
4+
env:
5+
python3 --version
6+
cargo --version
7+
rustc --version
8+
maturin --version
9+
10+
# Create a local virtualenv for Python tooling
11+
venv:
12+
test -d .venv || python3 -m venv .venv
13+
.venv/bin/python -m pip install -U pip
14+
15+
# Build and develop-install the Rust-backed Python module
16+
build-rust:
17+
test -d .venv || python3 -m venv .venv
18+
VIRTUAL_ENV=.venv maturin develop -m crates/codetracer-python-recorder/Cargo.toml
19+
20+
# Smoke test the Rust module after build
21+
smoke-rust:
22+
.venv/bin/python -c "import codetracer_python_recorder as m; print(m.hello())"
23+
24+
# Run the Python test suite for the pure-Python recorder
25+
test:
26+
python3 -m unittest discover -v

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1+
# This Makefile is deprecated. Use 'just test' instead.
12
.PHONY: test
2-
33
test:
4-
python3 -m unittest discover -v
4+
@echo "Deprecated: Use 'just test' instead." && false

crates/codetracer-python-recorder/Cargo.lock

Lines changed: 164 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/codetracer-python-recorder/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ name = "codetracer_python_recorder"
1111
crate-type = ["cdylib"]
1212

1313
[dependencies]
14-
pyo3 = { version = "0.21", features = ["extension-module"] }
14+
pyo3 = { version = "0.25.1", features = ["extension-module"] }

crates/codetracer-python-recorder/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ fn hello() -> PyResult<String> {
1010
}
1111

1212
#[pymodule]
13-
fn codetracer_python_recorder(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
14-
m.add_function(wrap_pyfunction!(hello, m)?)?;
13+
fn codetracer_python_recorder(_py: Python<'_>, m: Bound<'_, PyModule>) -> PyResult<()> {
14+
let hello_fn = wrap_pyfunction!(hello, &m)?;
15+
m.add_function(hello_fn)?;
1516
Ok(())
1617
}

flake.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
just
1919
git-lfs
2020

21+
# Linters and type checkers for Python code
22+
ruff
23+
black
24+
mypy
25+
2126
# Rust toolchain for the Rust-backed Python module
2227
cargo
2328
rustc

pyproject.toml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ requires = ["setuptools>=61"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
6-
name = "codetracer-python-recorder"
6+
name = "codetracer-pure-python-recorder"
77
version = "0.1.0"
8-
description = "Prototype recorder of Python programs producing CodeTracer traces"
8+
description = "Pure-Python prototype recorder producing CodeTracer traces"
99
authors = [{name = "Metacraft Labs Ltd"}]
1010
license = {text = "MIT"}
1111
readme = "README.md"
@@ -20,5 +20,9 @@ classifiers = [
2020
py-modules = ["trace"]
2121
package-dir = {"" = "src"}
2222

23+
[tool.setuptools.packages.find]
24+
where = ["src"]
25+
2326
[project.scripts]
24-
codetracer-record = "trace:main"
27+
codetracer-record = "codetracer_pure_python_recorder.cli:main"
28+
codetracer-record-pure = "codetracer_pure_python_recorder.cli:main"

0 commit comments

Comments
 (0)