|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + - dev |
| 8 | + pull_request: |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: ci-${{ github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: read |
| 16 | + |
| 17 | +jobs: |
| 18 | + test: |
| 19 | + name: Lint and test |
| 20 | + runs-on: ubuntu-latest |
| 21 | + timeout-minutes: 15 |
| 22 | + steps: |
| 23 | + - name: Checkout |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Setup Python |
| 27 | + uses: actions/setup-python@v5 |
| 28 | + with: |
| 29 | + python-version: '3.12' |
| 30 | + |
| 31 | + - name: Install dependencies |
| 32 | + run: | |
| 33 | + python -m pip install --upgrade pip |
| 34 | + # The hashed lockfile is the deploy artifact; install from it with |
| 35 | + # --require-hashes so CI fails on lockfile drift, exactly like the |
| 36 | + # Docker build does. |
| 37 | + pip install --require-hashes -r requirements.lock.txt |
| 38 | + pip install pytest pytest-asyncio httpx |
| 39 | +
|
| 40 | + - name: Ruff |
| 41 | + run: pipx run ruff==0.16.6 check . |
| 42 | + |
| 43 | + - name: Verify lockfile matches requirements.txt |
| 44 | + # Dependabot bumps requirements.txt but cannot regenerate the hashed |
| 45 | + # lockfile; without this check a stale lockfile would silently keep |
| 46 | + # the Docker build on old versions. |
| 47 | + run: | |
| 48 | + python - <<'PY' |
| 49 | + import re, sys |
| 50 | + pins = dict(re.findall(r'^([\w-]+)==([\w.]+)$', open('requirements.txt').read(), re.M)) |
| 51 | + lock = open('requirements.lock.txt').read() |
| 52 | + stale = [] |
| 53 | + for name, ver in pins.items(): |
| 54 | + m = re.search(rf'(?mi)^{re.escape(name)}==([\w.]+)\b', lock) |
| 55 | + if m is None or m.group(1) != ver: |
| 56 | + stale.append((name, ver, m.group(1) if m else 'ABSENT')) |
| 57 | + for name, req_ver, lock_ver in stale: |
| 58 | + print(f'STALE LOCKFILE: {name} requirements.txt={req_ver} lock={lock_ver}') |
| 59 | + sys.exit(1 if stale else 0) |
| 60 | + PY |
| 61 | +
|
| 62 | + - name: Run tests |
| 63 | + run: pytest -q |
0 commit comments