|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + tags: |
| 9 | + - "v*.*.*" |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + packages: write |
| 14 | + |
| 15 | +env: |
| 16 | + IMAGE_NAME: ghcr.io/${{ github.repository }} |
| 17 | + PYTHON_VERSION: "3.14" |
| 18 | + POETRY_VERSION: "2.4.1" |
| 19 | + |
| 20 | +jobs: |
| 21 | + verify: |
| 22 | + name: Test and lint |
| 23 | + runs-on: ubuntu-latest |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Check out repository |
| 27 | + uses: actions/checkout@v4 |
| 28 | + |
| 29 | + - name: Set up Python |
| 30 | + uses: actions/setup-python@v5 |
| 31 | + with: |
| 32 | + python-version: ${{ env.PYTHON_VERSION }} |
| 33 | + |
| 34 | + - name: Install Poetry |
| 35 | + run: pipx install poetry==${{ env.POETRY_VERSION }} |
| 36 | + |
| 37 | + - name: Configure Poetry cache |
| 38 | + uses: actions/cache@v4 |
| 39 | + with: |
| 40 | + path: ~/.cache/pypoetry |
| 41 | + key: poetry-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('poetry.lock') }} |
| 42 | + restore-keys: | |
| 43 | + poetry-${{ runner.os }}-${{ env.PYTHON_VERSION }}- |
| 44 | +
|
| 45 | + - name: Install dependencies |
| 46 | + run: poetry install --with dev --no-interaction --no-ansi --no-root |
| 47 | + |
| 48 | + - name: Run lint |
| 49 | + run: poetry run ruff check src tests scripts |
| 50 | + |
| 51 | + - name: Run tests |
| 52 | + run: poetry run pytest -q |
| 53 | + |
| 54 | + docker: |
| 55 | + name: Build and publish image |
| 56 | + runs-on: ubuntu-latest |
| 57 | + needs: verify |
| 58 | + |
| 59 | + steps: |
| 60 | + - name: Check out repository |
| 61 | + uses: actions/checkout@v4 |
| 62 | + |
| 63 | + - name: Set up Docker Buildx |
| 64 | + uses: docker/setup-buildx-action@v3 |
| 65 | + |
| 66 | + - name: Log in to GHCR |
| 67 | + if: github.event_name == 'push' |
| 68 | + uses: docker/login-action@v3 |
| 69 | + with: |
| 70 | + registry: ghcr.io |
| 71 | + username: ${{ github.actor }} |
| 72 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 73 | + |
| 74 | + - name: Extract Docker metadata |
| 75 | + id: meta |
| 76 | + uses: docker/metadata-action@v5 |
| 77 | + with: |
| 78 | + images: ${{ env.IMAGE_NAME }} |
| 79 | + tags: | |
| 80 | + type=ref,event=branch |
| 81 | + type=ref,event=tag |
| 82 | + type=sha,prefix=sha- |
| 83 | +
|
| 84 | + - name: Build image |
| 85 | + uses: docker/build-push-action@v6 |
| 86 | + with: |
| 87 | + context: . |
| 88 | + target: runtime |
| 89 | + push: ${{ github.event_name == 'push' }} |
| 90 | + tags: ${{ steps.meta.outputs.tags }} |
| 91 | + labels: ${{ steps.meta.outputs.labels }} |
| 92 | + cache-from: type=gha |
| 93 | + cache-to: type=gha,mode=max |
0 commit comments