Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 0 additions & 55 deletions .github/workflows/full-tests.yml

This file was deleted.

54 changes: 47 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Fast Tests
name: Tests

on:
push:
Expand All @@ -7,14 +7,15 @@ on:
- ".github/badges/coverage.svg"
pull_request:
branches: [main, master]
workflow_dispatch:

permissions:
contents: read

jobs:
fast-test:
test:
runs-on: ubuntu-latest
timeout-minutes: 15
timeout-minutes: 75

steps:
- uses: actions/checkout@v4
Expand All @@ -31,10 +32,49 @@ jobs:
- name: Install dependencies
run: uv sync --python 3.11 --all-extras

- name: Run fast test gate
- name: Run test suite
run: >
uv run --python 3.11 pytest tests/
-m "(unit or component or optimization) and not slow and not characterization and not pdk"
uv run --no-active --python 3.11 python -m pytest tests/
-v
--tb=short
--durations=25
--durations=50
--cov=beamz
--cov-report=term-missing
--cov-report=xml
--cov-fail-under=75

- name: Upload coverage report
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v4
with:
name: coverage-xml
path: coverage.xml

coverage-badge:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: test
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v4

- name: Download coverage report
uses: actions/download-artifact@v4
with:
name: coverage-xml

- name: Generate coverage badge
run: python scripts/update_coverage_badge.py coverage.xml .github/badges/coverage.svg

- name: Commit coverage badge
run: |
if git diff --quiet -- .github/badges/coverage.svg; then
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .github/badges/coverage.svg
git commit -m "ci: update coverage badge"
git push
27 changes: 27 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Codex refactoring rules

Goal: make this repository smaller, clearer, and easier to maintain without changing public behavior.

Hard constraints:
- Do not change public APIs unless explicitly requested.
- Do not change numerical results except within documented tolerances.
- Do not rewrite large subsystems in one PR.
- Prefer deleting dead code, merging duplicated logic, simplifying files, and removing unused abstractions.
- Keep every PR small and reviewable.
- Every change must pass tests, linting, and type checks.
- If behavior changes are necessary, stop and explain before editing.

Definition of done:
- Tests pass.
- New or updated tests cover the refactored behavior.
- Public imports still work.
- Numerical regression tests pass.
- LOC, complexity, or duplication improves.
- PR description explains what was removed, what was preserved, and how correctness was checked.

For JAX code:
- Do not accidentally move dynamic values into static arguments.
- Do not introduce recompilation loops.
- Do not change dtype behavior without tests.
- Do not change array shapes, pytree structure, or JIT boundaries unless explicitly asked.
- Do not optimize for elegance at the cost of compile time or memory use.
19 changes: 8 additions & 11 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,16 @@ All development commands use the Makefile:
```bash
make help # Show all available commands
make test # Run tests with coverage
make test-fast # Run quick tests
make format # Format code and fix package lint issues
make lint # Check code quality
make dead-code # Check for high-confidence dead code
make audit # Run lint, dead-code checks, and fast tests
make audit # Run lint, dead-code checks, and tests
make build # Build distribution
```

Or use uv directly:
```bash
uv run pytest tests/
uv run python -m pytest tests/
uv run --extra lint ruff check beamz/
uv run --extra lint ruff format beamz/
```
Expand Down Expand Up @@ -90,18 +89,15 @@ uv remove <package-name>
# All tests with coverage
make test

# Fast tests (skip @pytest.mark.slow)
make test-fast

# Single test file
make test-single FILE=test_physics_energy.py

# Specific test function
uv run pytest tests/test_physics_energy.py::test_energy_conservation -v
uv run python -m pytest tests/test_physics_energy.py::test_energy_conservation -v

# Tests by marker
uv run pytest -m design
uv run pytest -m simulation
uv run python -m pytest -m design
uv run python -m pytest -m simulation
```

### Writing Tests
Expand Down Expand Up @@ -267,14 +263,15 @@ uv sync

GitHub Actions workflows use uv:
- `.github/workflows/tests.yml` - Run tests on push/PR
- Configured for Python 3.10 and 3.11
- Configured for Python 3.11
- Uses `astral-sh/setup-uv@v5` action
- Runs the full suite with coverage and enforces the current coverage baseline

## Best Practices

1. **Always use `uv add/remove`** for dependencies (keeps lockfile in sync)
2. **Run `make format`** before committing
3. **Run `make test-fast`** during development
3. **Run focused `uv run python -m pytest ...` commands** while iterating
4. **Run `make test`** before pushing
5. **Keep lockfile committed** (ensures reproducibility)
6. **Use `make` commands** for consistency
Expand Down
Loading
Loading