Simplify CI #103
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: Pull request | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| continuous-integration: | |
| if: github.actor != 'dependabot[bot]' | |
| runs-on: ubuntu-24.04 | |
| outputs: | |
| docker-tag: ${{ steps.docker-tag.outputs.docker-tag }} | |
| env: | |
| UV_FROZEN: true | |
| PYTHON_APP_ENVIRONMENT: development | |
| CI: true # Enable pytest CI mode | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 # v7.1.4 | |
| with: | |
| version-file: pyproject.toml | |
| resolution-strategy: lowest | |
| - name: Install Python | |
| uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 | |
| with: | |
| python-version-file: .python-version | |
| - name: Install Python packages | |
| run: | | |
| unset UV_FROZEN | |
| uv sync --locked | |
| shell: bash | |
| - name: Check code | |
| run: make check-code | |
| shell: bash | |
| - name: Unit tests | |
| run: uv run -- pytest --cov=python_template --cov-branch tests/unit | |
| shell: bash | |
| - name: Integration tests | |
| if: false | |
| run: uv run -- pytest --cov=python_template --cov-branch --cov-append tests/integration | |
| shell: bash | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 | |
| - name: Set docker tag | |
| id: docker-tag | |
| run: echo "docker-tag=myregistry/python-template:${{ github.event.pull_request.head.sha }}" >> $GITHUB_OUTPUT | |
| - name: Build and push | |
| uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 | |
| with: | |
| file: src/python_template/api/Dockerfile | |
| tags: ${{ steps.docker-tag.outputs.docker-tag }} | |
| push: false | |
| deploy-dev: | |
| name: Deploy to development | |
| needs: continuous-integration | |
| uses: ./.github/workflows/_deploy.yaml | |
| with: | |
| environment: dev | |
| docker_tag: ${{ needs.continuous-integration.outputs.docker-tag }} | |
| secrets: inherit | |
| deploy-stg: | |
| name: Deploy to staging | |
| needs: [continuous-integration, deploy-dev] | |
| uses: ./.github/workflows/_deploy.yaml | |
| with: | |
| environment: stg | |
| docker_tag: ${{ needs.continuous-integration.outputs.docker-tag }} | |
| secrets: inherit | |
| deploy-prd: | |
| name: Deploy to production | |
| needs: [continuous-integration, deploy-stg] | |
| uses: ./.github/workflows/_deploy.yaml | |
| with: | |
| environment: prd | |
| docker_tag: ${{ needs.continuous-integration.outputs.docker-tag }} | |
| secrets: inherit |