build(ci/cd): improve performance development workflow #51
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: Development Workflow | |
| on: | |
| pull_request: | |
| branches: [ development ] | |
| push: | |
| branches: [ development ] | |
| permissions: | |
| contents: read | |
| checks: write | |
| pull-requests: write | |
| jobs: | |
| lint: | |
| name: Lint / Format / Type-check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up UV | |
| uses: astral-sh/setup-uv@v6 | |
| with: | |
| python-version: '3.13' | |
| - name: Cache UV | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/uv | |
| key: ${{ runner.os }}-uv-3.13-${{ hashFiles('uv.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-uv-3.13- | |
| - name: Sync dev dependencies | |
| run: uv sync --locked --all-extras --dev --no-progress -q | |
| - name: Lint / Format / Type-check | |
| run: uv run lint | |
| tests: | |
| name: Run tests (matrix) | |
| runs-on: ubuntu-latest | |
| needs: lint | |
| strategy: | |
| matrix: | |
| python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13' ] | |
| fail-fast: false | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up UV | |
| uses: astral-sh/setup-uv@v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Cache UV | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/uv | |
| key: ${{ runner.os }}-uv-${{ matrix.python-version }}-${{ hashFiles('uv.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-uv-${{ matrix.python-version }}- | |
| - name: Sync dev dependencies | |
| run: uv sync --locked --all-extras --dev --no-progress -q | |
| - name: Run tests | |
| run: uv run pytest --cov --cov-report=xml | |
| - name: Upload coverage artifact (only 3.13) | |
| if: matrix.python-version == '3.13' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-3.13 | |
| path: coverage.xml | |
| codecov: | |
| name: Upload saved coverage to Codecov | |
| runs-on: ubuntu-latest | |
| needs: tests | |
| steps: | |
| - name: Download coverage artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: coverage-3.13 | |
| path: . | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: ./coverage.xml | |
| slug: Athroniaeth/fastapi-api-key | |
| fail_ci_if_error: true | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |