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
28 changes: 28 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copilot Instructions for Analysis Template

## Project context (fill these in!)
- **Project name:** <fill>
- **One-liner goal:** <fill>
- **Primary datasets / locations:** <fill>

## Critical rules
- **Don't update Jupyter notebooks** — I manage them myself
- Use `pixi run <command>` or `pixi shell` for all commands
- Summarize in chat, don't create markdown summary files

## Quick reference

| Task | Command |
|------|---------|
| Run Python | `pixi run python script.py` |
| Run tests | `pixi run test` |
| Add conda package | `pixi add <package>` |
| Add PyPI package | `pixi add --pypi <package>` |

## Project structure
- **Notebooks**: `analysis/[INITIALS]-[YYYY]-[MM]-[DD]_description.ipynb`
- **Data**: `data/<dataset>/{raw,processed,resources,results}/`
- **Paths**: Use `from myanalysis import FilePaths` (edit `_constants.py` for datasets)
- **Deps**: All in `pixi.toml` (not pyproject.toml)
- pyproject.toml exists mainly for package metadata and testing
- Run `pixi install` after pulling changes that update `pixi.toml`
33 changes: 0 additions & 33 deletions .github/workflows/build.yaml

This file was deleted.

27 changes: 27 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Code Quality

on:
push:
branches: [main]
pull_request:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
name: Lint & Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
filter: blob:none
fetch-depth: 0
- uses: prefix-dev/setup-pixi@v0.8.0
with:
pixi-version: v0.40.0
cache: true
- name: Run pre-commit checks
run: pixi run pre-commit run --all-files
91 changes: 8 additions & 83 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,102 +1,27 @@
name: Test
name: Tests

on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: "0 5 1,15 * *"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

defaults:
run:
# to fail on error in multiline statements (-e), in pipes (-o pipefail), and on unset variables (-u).
shell: bash -euo pipefail {0}

jobs:
# Get the test environment from hatch as defined in pyproject.toml.
# This ensures that the pyproject.toml is the single point of truth for test definitions and the same tests are
# run locally and on continuous integration.
# Check [[tool.hatch.envs.hatch-test.matrix]] in pyproject.toml and https://hatch.pypa.io/latest/environment/ for
# more details.
get-environments:
runs-on: ubuntu-latest
outputs:
envs: ${{ steps.get-envs.outputs.envs }}
steps:
- uses: actions/checkout@v4
with:
filter: blob:none
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Get test environments
id: get-envs
run: |
ENVS_JSON=$(uvx hatch env show --json | jq -c 'to_entries
| map(
select(.key | startswith("hatch-test"))
| {
name: .key,
label: (if (.key | contains("pre")) then .key + " (PRE-RELEASE DEPENDENCIES)" else .key end),
python: .value.python
}
)')
echo "envs=${ENVS_JSON}" | tee $GITHUB_OUTPUT

# Run tests through hatch. Spawns a separate runner for each environment defined in the hatch matrix obtained above.
test:
needs: get-environments

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
env: ${{ fromJSON(needs.get-environments.outputs.envs) }}

name: ${{ matrix.env.label }}
runs-on: ${{ matrix.os }}

name: Run pytest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
filter: blob:none
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v5
- uses: prefix-dev/setup-pixi@v0.8.0
with:
python-version: ${{ matrix.env.python }}
cache-dependency-glob: pyproject.toml
- name: create hatch environment
run: uvx hatch env create ${{ matrix.env.name }}
- name: run tests using hatch
env:
MPLBACKEND: agg
PLATFORM: ${{ matrix.os }}
DISPLAY: :42
run: |
uvx hatch run ${{ matrix.env.name }}:coverage run -m pytest -v --color=yes
- name: generate coverage report
run: uvx hatch run ${{ matrix.env.name }}:coverage xml
- name: Upload coverage
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}

# Check that all tests defined above pass. This makes it easy to set a single "required" test in branch
# protection instead of having to update it frequently. See https://github.com/re-actors/alls-green#why.
check:
name: Tests pass in all hatch environments
if: always()
needs:
- get-environments
- test
runs-on: ubuntu-latest
steps:
- uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
pixi-version: v0.40.0
cache: true
- name: Run tests
run: pixi run test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ venv/
ENV/
env.bak/
venv.bak/
.pixi/

# Spyder project settings
.spyderproject
Expand Down
Loading
Loading