|
| 1 | +name: CICD |
| 2 | +on: [ push, pull_request ] |
| 3 | + |
| 4 | +env: |
| 5 | + REGISTRY: ghcr.io |
| 6 | + IMAGE_NAME: ${{ github.repository }} |
| 7 | + |
| 8 | +jobs: |
| 9 | + ruff: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - uses: actions/checkout@v4 |
| 13 | + - uses: astral-sh/ruff-action@v3 |
| 14 | + |
| 15 | + tests: |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + python-version: ["3.13"] |
| 20 | + os: [ubuntu-24.04, macos-latest, windows-latest] |
| 21 | + |
| 22 | + runs-on: ${{ matrix.os }} |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Install uv |
| 27 | + uses: astral-sh/setup-uv@v5 |
| 28 | + with: |
| 29 | + enable-cache: true |
| 30 | + python-version: ${{ matrix.python-version }} |
| 31 | + |
| 32 | + - name: Install the project |
| 33 | + run: uv sync --all-extras --dev |
| 34 | + |
| 35 | + - name: Run tests |
| 36 | + run: uv run pytest |
| 37 | + |
| 38 | + docker: |
| 39 | + strategy: |
| 40 | + fail-fast: false |
| 41 | + matrix: |
| 42 | + os: [ubuntu-24.04, ubuntu-24.04-arm] |
| 43 | + |
| 44 | + permissions: |
| 45 | + contents: read |
| 46 | + packages: write |
| 47 | + attestations: write |
| 48 | + id-token: write |
| 49 | + |
| 50 | + runs-on: ${{ matrix.os }} |
| 51 | + needs: [ ruff, tests ] |
| 52 | + steps: |
| 53 | + - name: Checkout repository |
| 54 | + uses: actions/checkout@v4 |
| 55 | + |
| 56 | + - name: Log in to the Container registry |
| 57 | + uses: docker/login-action@v3 |
| 58 | + with: |
| 59 | + registry: ${{ env.REGISTRY }} |
| 60 | + username: ${{ github.actor }} |
| 61 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 62 | + |
| 63 | + - name: Extract metadata (tags, labels) for Docker |
| 64 | + id: meta |
| 65 | + uses: docker/metadata-action@v5 |
| 66 | + with: |
| 67 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 68 | + |
| 69 | + - name: Set up Docker Buildx |
| 70 | + uses: docker/setup-buildx-action@v3 |
| 71 | + |
| 72 | + - name: Build and push Docker image |
| 73 | + id: push |
| 74 | + uses: docker/build-push-action@v6 |
| 75 | + with: |
| 76 | + context: . |
| 77 | + push: true |
| 78 | + provenance: false |
| 79 | + tags: ${{ steps.meta.outputs.tags }} |
| 80 | + labels: ${{ steps.meta.outputs.labels }} |
| 81 | + |
| 82 | + - name: Generate artifact attestation |
| 83 | + uses: actions/attest-build-provenance@v2 |
| 84 | + with: |
| 85 | + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} |
| 86 | + subject-digest: ${{ steps.push.outputs.digest }} |
| 87 | + push-to-registry: true |
0 commit comments