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
107 changes: 107 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: CI

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
push:
branches: [main]

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

jobs:
precommit:
name: pre-commit (lint/format/tests)
runs-on: ubuntu-latest
if: github.event_name != 'push' || github.ref == 'refs/heads/main'

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install Poetry
uses: abatilo/actions-poetry@v3
with:
poetry-version: "1.8.3"

- name: Enable in-project venv
run: poetry config virtualenvs.in-project true

- name: Cache Poetry venv
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.py.outputs.python-version || '3.12' }}-${{ hashFiles('poetry.lock') }}
restore-keys: |
venv-${{ runner.os }}-

- name: Install dependencies
run: poetry install --no-interaction

# This runs all hooks defined in pre-commit (e.g., ruff, pytest, mypy)
- name: Run pre-commit on all files
run: |
poetry run pre-commit install
poetry run pre-commit run --all-files

# === Optional: separate pytest job (keep if you want tests isolated) ===
tests:
name: pytest (separated)
runs-on: ubuntu-latest
needs: precommit
if: >
github.event_name != 'push' || github.ref == 'refs/heads/main'
# If you already run pytest in pre-commit, you can disable this whole job

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install Poetry
uses: abatilo/actions-poetry@v3
with:
poetry-version: "1.8.3"

- name: Enable in-project venv
run: poetry config virtualenvs.in-project true

- name: Cache Poetry venv
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.py.outputs.python-version || '3.12' }}-${{ hashFiles('poetry.lock') }}
restore-keys: |
venv-${{ runner.os }}-

- name: Install dependencies
run: poetry install --no-interaction

- name: Run pytest (with coverage)
run: |
poetry run pytest -q --maxfail=1 --disable-warnings \
--cov=src --cov-report=xml --junitxml=pytest-junit.xml

- name: Upload coverage.xml
uses: actions/upload-artifact@v4
with:
name: coverage-xml
path: coverage.xml
if-no-files-found: ignore

- name: Upload JUnit report
uses: actions/upload-artifact@v4
with:
name: pytest-junit
path: pytest-junit.xml
if-no-files-found: ignore
2 changes: 1 addition & 1 deletion tests/perf/test_averages_perf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def _best_time(fn, data, repeats=5):
return min(times), statistics.mean(times)


EXPECTED_MAX_TIME = 0.05 # 50 milliseconds
EXPECTED_MAX_TIME = 0.055 # 55 milliseconds


def test_average_age_performance(capfd):
Expand Down