Add dependency caching to PR check workflows #6
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
| --- | |
| # ABOUTME: GitHub Actions workflow for validating backend pull requests. | |
| # ABOUTME: Runs tests and validates Docker build without pushing. | |
| name: PR Check Backend | |
| "on": | |
| pull_request: | |
| branches: | |
| - main | |
| - master | |
| paths: | |
| - 'truecover-backend/**' | |
| - '.github/workflows/pr-check-backend.yml' | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: ./truecover-backend | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| cache-dependency-glob: "truecover-backend/uv.lock" | |
| - name: Set up Python | |
| run: uv python install 3.12 | |
| - name: Install dependencies | |
| run: uv sync --frozen --extra dev | |
| - name: Run linting | |
| continue-on-error: true | |
| run: | | |
| uv run black --check . | |
| uv run flake8 | |
| - name: Run tests | |
| run: uv run pytest | |
| docker-build: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Docker image (validation only) | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ./truecover-backend | |
| file: ./truecover-backend/Dockerfile | |
| push: false | |
| tags: truecover-backend:pr-${{ github.event.pull_request.number }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Build validation complete | |
| env: | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| run: | | |
| echo "## Docker Build Validation" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "Backend Docker image built successfully for PR #$PR_NUMBER" \ | |
| >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Note:** Image was not pushed to registry" \ | |
| >> $GITHUB_STEP_SUMMARY |