Skip to content

Commit 5c92d0d

Browse files
authored
Merge pull request #7 from quadbio/feature/pixi-modernization
Modernize template: pixi environment + copilot instructions
2 parents 32849c6 + cfe2f47 commit 5c92d0d

17 files changed

Lines changed: 11419 additions & 217 deletions

.github/copilot-instructions.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copilot Instructions for Analysis Template
2+
3+
## Project context (fill these in!)
4+
- **Project name:** <fill>
5+
- **One-liner goal:** <fill>
6+
- **Primary datasets / locations:** <fill>
7+
8+
## Critical rules
9+
- **Don't update Jupyter notebooks** — I manage them myself
10+
- Use `pixi run <command>` or `pixi shell` for all commands
11+
- Summarize in chat, don't create markdown summary files
12+
13+
## Quick reference
14+
15+
| Task | Command |
16+
|------|---------|
17+
| Run Python | `pixi run python script.py` |
18+
| Run tests | `pixi run test` |
19+
| Add conda package | `pixi add <package>` |
20+
| Add PyPI package | `pixi add --pypi <package>` |
21+
22+
## Project structure
23+
- **Notebooks**: `analysis/[INITIALS]-[YYYY]-[MM]-[DD]_description.ipynb`
24+
- **Data**: `data/<dataset>/{raw,processed,resources,results}/`
25+
- **Paths**: Use `from myanalysis import FilePaths` (edit `_constants.py` for datasets)
26+
- **Deps**: All in `pixi.toml` (not pyproject.toml)
27+
- pyproject.toml exists mainly for package metadata and testing
28+
- Run `pixi install` after pulling changes that update `pixi.toml`

.github/workflows/build.yaml

Lines changed: 0 additions & 33 deletions
This file was deleted.

.github/workflows/lint.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Code Quality
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
lint:
15+
name: Lint & Format
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
filter: blob:none
21+
fetch-depth: 0
22+
- uses: prefix-dev/setup-pixi@v0.8.0
23+
with:
24+
pixi-version: v0.40.0
25+
cache: true
26+
- name: Run pre-commit checks
27+
run: pixi run pre-commit run --all-files

.github/workflows/test.yaml

Lines changed: 8 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,27 @@
1-
name: Test
1+
name: Tests
22

33
on:
44
push:
55
branches: [main]
66
pull_request:
77
branches: [main]
8-
schedule:
9-
- cron: "0 5 1,15 * *"
108

119
concurrency:
1210
group: ${{ github.workflow }}-${{ github.ref }}
1311
cancel-in-progress: true
1412

15-
defaults:
16-
run:
17-
# to fail on error in multiline statements (-e), in pipes (-o pipefail), and on unset variables (-u).
18-
shell: bash -euo pipefail {0}
19-
2013
jobs:
21-
# Get the test environment from hatch as defined in pyproject.toml.
22-
# This ensures that the pyproject.toml is the single point of truth for test definitions and the same tests are
23-
# run locally and on continuous integration.
24-
# Check [[tool.hatch.envs.hatch-test.matrix]] in pyproject.toml and https://hatch.pypa.io/latest/environment/ for
25-
# more details.
26-
get-environments:
27-
runs-on: ubuntu-latest
28-
outputs:
29-
envs: ${{ steps.get-envs.outputs.envs }}
30-
steps:
31-
- uses: actions/checkout@v4
32-
with:
33-
filter: blob:none
34-
fetch-depth: 0
35-
- name: Install uv
36-
uses: astral-sh/setup-uv@v5
37-
- name: Get test environments
38-
id: get-envs
39-
run: |
40-
ENVS_JSON=$(uvx hatch env show --json | jq -c 'to_entries
41-
| map(
42-
select(.key | startswith("hatch-test"))
43-
| {
44-
name: .key,
45-
label: (if (.key | contains("pre")) then .key + " (PRE-RELEASE DEPENDENCIES)" else .key end),
46-
python: .value.python
47-
}
48-
)')
49-
echo "envs=${ENVS_JSON}" | tee $GITHUB_OUTPUT
50-
51-
# Run tests through hatch. Spawns a separate runner for each environment defined in the hatch matrix obtained above.
5214
test:
53-
needs: get-environments
54-
55-
strategy:
56-
fail-fast: false
57-
matrix:
58-
os: [ubuntu-latest]
59-
env: ${{ fromJSON(needs.get-environments.outputs.envs) }}
60-
61-
name: ${{ matrix.env.label }}
62-
runs-on: ${{ matrix.os }}
63-
15+
name: Run pytest
16+
runs-on: ubuntu-latest
6417
steps:
6518
- uses: actions/checkout@v4
6619
with:
6720
filter: blob:none
6821
fetch-depth: 0
69-
- name: Install uv
70-
uses: astral-sh/setup-uv@v5
22+
- uses: prefix-dev/setup-pixi@v0.8.0
7123
with:
72-
python-version: ${{ matrix.env.python }}
73-
cache-dependency-glob: pyproject.toml
74-
- name: create hatch environment
75-
run: uvx hatch env create ${{ matrix.env.name }}
76-
- name: run tests using hatch
77-
env:
78-
MPLBACKEND: agg
79-
PLATFORM: ${{ matrix.os }}
80-
DISPLAY: :42
81-
run: |
82-
uvx hatch run ${{ matrix.env.name }}:coverage run -m pytest -v --color=yes
83-
- name: generate coverage report
84-
run: uvx hatch run ${{ matrix.env.name }}:coverage xml
85-
- name: Upload coverage
86-
uses: codecov/codecov-action@v4
87-
with:
88-
token: ${{ secrets.CODECOV_TOKEN }}
89-
90-
# Check that all tests defined above pass. This makes it easy to set a single "required" test in branch
91-
# protection instead of having to update it frequently. See https://github.com/re-actors/alls-green#why.
92-
check:
93-
name: Tests pass in all hatch environments
94-
if: always()
95-
needs:
96-
- get-environments
97-
- test
98-
runs-on: ubuntu-latest
99-
steps:
100-
- uses: re-actors/alls-green@release/v1
101-
with:
102-
jobs: ${{ toJSON(needs) }}
24+
pixi-version: v0.40.0
25+
cache: true
26+
- name: Run tests
27+
run: pixi run test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ venv/
109109
ENV/
110110
env.bak/
111111
venv.bak/
112+
.pixi/
112113

113114
# Spyder project settings
114115
.spyderproject

0 commit comments

Comments
 (0)