diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e9c691a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,65 @@ +name: CI + +on: + pull_request: + push: + branches: [main] + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: pip + cache-dependency-path: pyproject.toml + + - name: Install + run: python -m pip install -e ".[dev]" + + # `ruff format --check` is not enforced yet: the existing sources are not + # format-clean, and reformatting them belongs in its own PR. + - name: Ruff + run: ruff check . + + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.10", "3.11", "3.12", "3.13"] + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: pip + cache-dependency-path: pyproject.toml + + - name: Install + run: python -m pip install -e ".[dev]" + + # pytest exits 5 when it collects no tests. main has no tests yet, so + # treat 5 as success until the first test file lands; every other + # non-zero code still fails the job. + - name: Pytest + run: | + set +e + pytest -q + code=$? + if [ "$code" -eq 5 ]; then + echo "::notice::pytest collected no tests (exit 5); treating as success." + exit 0 + fi + exit "$code"