Skip to content

Commit 27aae61

Browse files
committed
ci: migrate to uv, add pre-commit hooks, and expand linting rules
- Switch CI from pip to uv (astral-sh/setup-uv) with built-in caching - Add Python 3.11/3.12 matrix and concurrency group to cancel stale runs - Add docker-compose build check as separate job - Upload coverage report to GitHub Job Summary - Add ruff and pyright to dev dependencies in pyproject.toml - Migrate build backend from setuptools to hatchling - Expand ruff lint rules: bugbear, pyupgrade, simplify, numpy, pytest-style - Add .pre-commit-config.yaml with ruff lint and format hooks
1 parent 8c8d4cd commit 27aae61

4 files changed

Lines changed: 129 additions & 30 deletions

File tree

.github/workflows/test.yml

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,48 @@ on:
66
pull_request:
77
branches: [main]
88

9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
913
jobs:
10-
ci:
14+
test-and-lint:
1115
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
python-version: ["3.11", "3.12"]
1219

1320
steps:
1421
- uses: actions/checkout@v4
1522

16-
- uses: actions/setup-python@v5
17-
with:
18-
python-version: "3.11"
19-
20-
- uses: actions/cache@v4
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v5
2125
with:
22-
path: ~/.cache/pip
23-
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
24-
restore-keys: ${{ runner.os }}-pip-
26+
python-version: ${{ matrix.python-version }}
27+
enable-cache: true
2528

26-
- name: Install package and dev dependencies
27-
run: pip install -e ".[dev,notebooks]"
29+
- name: Install dependencies
30+
run: uv sync --all-extras
2831

29-
- name: Install linting and type-checking tools
30-
run: pip install ruff pyright
32+
- name: Check formatting (Ruff)
33+
run: uv run ruff format --check .
3134

32-
- name: Ruff lint
33-
run: ruff check . --config pyproject.toml
35+
- name: Lint (Ruff)
36+
run: uv run ruff check --output-format=github .
3437

35-
- name: Pyright type check
36-
run: pyright src/ --warnings
38+
- name: Type check (Pyright)
39+
run: uv run pyright src/
3740

3841
- name: Pytest with coverage
39-
run: pytest --cov=src/heliotrace --cov-report=term-missing
42+
run: uv run pytest --cov=src/heliotrace --cov-report=xml --cov-report=term-missing
43+
44+
- name: Upload coverage to Job Summary
45+
if: matrix.python-version == '3.11' # Only run once
46+
run: uv run coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
47+
48+
docker-check:
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/checkout@v4
52+
- name: Test Docker Build
53+
run: docker compose build

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.3.0 # replace with current ruff version
4+
hooks:
5+
- id: ruff
6+
args: [ --fix ]
7+
- id: ruff-format

pyproject.toml

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,28 @@ dependencies = [
1414
]
1515

1616
[project.optional-dependencies]
17-
# Install with: pip install heliotrace[notebooks]
17+
dev = [
18+
"pytest>=8.0",
19+
"pytest-cov",
20+
"ruff",
21+
"pyright",
22+
]
1823
notebooks = [
1924
"sunpy~=5.1",
2025
"matplotlib~=3.10",
2126
]
22-
# Install with: pip install heliotrace[dev]
27+
28+
[dependency-groups]
2329
dev = [
2430
"pytest>=8.0",
2531
"pytest-cov",
32+
"ruff",
33+
"pyright",
2634
]
2735

2836
[build-system]
29-
requires = ["setuptools>=61.0"]
30-
build-backend = "setuptools.build_meta"
31-
32-
[tool.setuptools.packages.find]
33-
where = ["src"]
37+
requires = ["hatchling"]
38+
build-backend = "hatchling.build"
3439

3540
[tool.pytest.ini_options]
3641
testpaths = ["tests"]
@@ -42,16 +47,22 @@ addopts = "-v"
4247
exclude = [".venv", ".git", "__pycache__"]
4348

4449
[tool.ruff.lint]
45-
select = ["E", "F", "W", "I"]
46-
ignore = ["E501", "F401"]
50+
select =[
51+
"E", "F", "W", # Standard Flake8
52+
"I", # isort
53+
"B", # flake8-bugbear
54+
"UP", # pyupgrade: modern Python 3.11+ syntax
55+
"SIM", # flake8-simplify: cleaner code logic
56+
"NPY", # NumPy-specific rules: for Astropy/SciPy workflows
57+
"PT", # flake8-pytest-style: keeps tests clean
58+
]
59+
ignore = ["E501"]
4760

4861
[tool.ruff.lint.isort]
4962
known-first-party = ["heliotrace"]
5063

5164
[tool.pyright]
5265
pythonVersion = "3.11"
53-
venvPath = "."
54-
venv = ".venv"
5566
typeCheckingMode = "basic"
5667
reportMissingTypeStubs = false
5768
reportAttributeAccessIssue = "warning" # CI shouldn't fail on sol.t or array.to()

uv.lock

Lines changed: 68 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)