fix naming #109
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build / Test / Push | |
| on: | |
| push: | |
| branches: | |
| - '**' | |
| workflow_dispatch: | |
| env: | |
| DOCKER_METADATA_SET_OUTPUT_ENV: 'true' | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.runner }} | |
| outputs: | |
| image-app-arm64: ${{ steps.gen-output.outputs.image-app-arm64 }} | |
| image-app-x64: ${{ steps.gen-output.outputs.image-app-x64 }} | |
| image-dev-arm64: ${{ steps.gen-output.outputs.image-develoment-arm64 }} | |
| image-dev-x64: ${{ steps.gen-output.outputs.image-develoment-x64 }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| runner: | |
| - ubuntu-24.04 | |
| - ubuntu-24.04-arm | |
| target: | |
| - app | |
| - development | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Docker meta | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ghcr.io/${{ github.repository }} | |
| # note Specifies a single tag to ensure the default doesn't add more than one. | |
| # The actual tag is not used, this is just used to sanitize the registry name | |
| # and produce labels. | |
| tags: type=sha | |
| - name: Sanitize registry repository name | |
| id: get-reg | |
| run: | | |
| echo "registry=$(echo '${{ steps.meta.outputs.tags }}' | cut -f1 -d:)" | tee -a "$GITHUB_OUTPUT" | |
| - name: Build/push the arch-specific image | |
| id: build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| # @todo GHA caching needs tuning, these tend not to hit. Perhaps switch to type=registry? | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| labels: ${{ steps.meta.outputs.labels }} | |
| provenance: mode=max | |
| sbom: true | |
| tags: ${{ steps.get-reg.outputs.registry }} | |
| outputs: type=image,push-by-digest=true,push=true | |
| target: ${{ matrix.target }} | |
| - name: Write arch-specific image digest to outputs | |
| id: gen-output | |
| run: | | |
| echo "image-${{ matrix.target }}-${RUNNER_ARCH,,}=${{ steps.get-reg.outputs.registry }}@${{ steps.build.outputs.digest }}" | tee -a "$GITHUB_OUTPUT" | |
| merge: | |
| runs-on: ubuntu-24.04 | |
| needs: | |
| - build | |
| env: | |
| DOCKER_APP_IMAGE_ARM64: ${{ needs.build.outputs.image-app-arm64 }} | |
| DOCKER_APP_IMAGE_X64: ${{ needs.build.outputs.image-app-x64 }} | |
| DOCKER_DEV_IMAGE_ARM64: ${{ needs.build.outputs.image-dev-arm64 }} | |
| DOCKER_DEV_IMAGE_X64: ${{ needs.build.outputs.image-dev-x64 }} | |
| outputs: | |
| app-image: ${{ steps.app-meta.outputs.tags }} | |
| dev-image: ${{ steps.dev-meta.outputs.tags }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Generate tag for the dev image | |
| id: dev-meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ghcr.io/${{ github.repository }} | |
| tags: | | |
| type=sha,suffix=-build-${{ github.run_id }}_${{ github.run_attempt }}-dev | |
| - name: Push the multi-platform dev image | |
| run: | | |
| docker buildx imagetools create \ | |
| --tag "$DOCKER_METADATA_OUTPUT_TAGS" \ | |
| "$DOCKER_DEV_IMAGE_ARM64" "$DOCKER_DEV_IMAGE_X64" | |
| - name: Generate tag for the app image | |
| id: app-meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ghcr.io/${{ github.repository }} | |
| tags: | | |
| type=sha,suffix=-build-${{ github.run_id }}_${{ github.run_attempt }} | |
| - name: Push the multi-platform app image | |
| run: | | |
| docker buildx imagetools create \ | |
| --tag "$DOCKER_METADATA_OUTPUT_TAGS" \ | |
| "$DOCKER_APP_IMAGE_ARM64" "$DOCKER_APP_IMAGE_X64" | |
| test-mypy: | |
| runs-on: ubuntu-24.04 | |
| needs: merge | |
| container: | |
| image: ${{ needs.merge.outputs.dev-image }} | |
| defaults: | |
| run: | |
| working-directory: /app | |
| steps: | |
| - name: Run mypy | |
| run: mypy . | |
| test-pydoclint: | |
| runs-on: ubuntu-24.04 | |
| needs: merge | |
| container: | |
| image: ${{ needs.merge.outputs.dev-image }} | |
| defaults: | |
| run: | |
| working-directory: /app | |
| steps: | |
| - name: Run pydoclint | |
| run: pydoclint . | |
| # pylint returns error codes if the checks fail | |
| # @see https://pylint.readthedocs.io/en/latest/user_guide/usage/run.html#exit-codes | |
| test-pylint: | |
| runs-on: ubuntu-24.04 | |
| needs: merge | |
| container: | |
| image: ${{ needs.merge.outputs.dev-image }} | |
| defaults: | |
| run: | |
| working-directory: /app | |
| steps: | |
| - name: Run pylint | |
| run: pylint -v . | |
| test-unittest: | |
| runs-on: ubuntu-24.04 | |
| needs: merge | |
| container: | |
| image: ${{ needs.merge.outputs.dev-image }} | |
| defaults: | |
| run: | |
| working-directory: /app | |
| steps: | |
| - name: Run unit tests | |
| run: | | |
| cp env.example .env | |
| python -m unittest . | |
| test-startup: | |
| runs-on: ubuntu-24.04 | |
| needs: merge | |
| env: | |
| COMPOSE_FILE: docker-compose.yml:docker-compose.ci.yml | |
| DOCKER_APP_IMAGE: ${{ needs.merge.outputs.app-image }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Compose | |
| uses: docker/setup-compose-action@v1 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Run the test script | |
| run: | | |
| docker compose up --detach --wait | |
| push: | |
| runs-on: ubuntu-24.04 | |
| needs: | |
| - merge | |
| - test-mypy | |
| - test-pydoclint | |
| - test-pylint | |
| - test-startup | |
| - test-unittest | |
| env: | |
| DOCKER_APP_IMAGE: ${{ needs.merge.outputs.app-image }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Produce permanent image tags | |
| id: branch-meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ghcr.io/${{ github.repository }} | |
| tags: | | |
| type=sha | |
| type=ref,event=branch | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Retag and push the image | |
| run: | | |
| docker pull "$DOCKER_APP_IMAGE" | |
| echo "$DOCKER_METADATA_OUTPUT_TAGS" | tr ' ' '\n' | xargs -n1 docker tag "$DOCKER_APP_IMAGE" | |
| docker push --all-tags "$(echo "$DOCKER_APP_IMAGE" | cut -f1 -d:)" |