diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..879562e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,81 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + # ── Job 1: Lint ──────────────────────────────────────────────────── + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Cache pip + uses: actions/cache@v4 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} + restore-keys: ${{ runner.os }}-pip- + + - name: Install linter + run: pip install ruff + + - name: Run lint + run: ruff check src/ + + # ── Job 2: Test ──────────────────────────────────────────────────── + test: + name: Test + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.10", "3.11", "3.12"] + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + + - name: Install dependencies + run: pip install -r requirements.txt + + - name: Run tests + run: pytest src/ --junitxml=test-results.xml + + - uses: actions/upload-artifact@v4 + if: always() # runs even if previous steps failed + with: + name: debug-logs + path: '*.log' + # ── Job 3: Build ─────────────────────────────────────────────────── + build: + name: Build + needs: [lint, test] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + + - name: Build distribution + run: | + pip install build + cd src + python -m build --outdir ../dist + + - name: Upload dist artifact + uses: actions/upload-artifact@v4 + with: + name: dist + path: dist/ \ No newline at end of file