feat: accounts #5
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: CI | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| env: | |
| ENV: TEST | |
| jobs: | |
| lint: | |
| name: Lint & Format | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: "Set up Python" | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version-file: ".python-version" | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| version: "latest" | |
| - name: Install dependencies | |
| run: uv sync --dev | |
| - name: Check code formatting with ruff | |
| run: uv run ruff format --check . | |
| - name: Run ruff linter | |
| run: uv run ruff check . | |
| typecheck: | |
| name: Type Check | |
| runs-on: ubuntu-latest | |
| needs: lint | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: "Set up Python" | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version-file: ".python-version" | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| version: "latest" | |
| - name: Install dependencies | |
| run: uv sync --dev | |
| - name: Run pyright type checker | |
| run: uv run pyright | |
| test: | |
| name: Test | |
| runs-on: ubuntu-latest | |
| needs: [lint, typecheck] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| services: | |
| postgres: | |
| image: postgres:15 | |
| env: | |
| POSTGRES_DB: ${{ vars.DB_NAME }} | |
| POSTGRES_USER: ${{ vars.DB_USER }} | |
| POSTGRES_PASSWORD: ${{ secrets.DB_PASSWORD }} | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: "Set up Python" | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version-file: ".python-version" | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| version: "latest" | |
| - name: Install dependencies | |
| run: uv sync --dev | |
| - name: Run tests with coverage | |
| id: tests | |
| continue-on-error: true | |
| run: | | |
| uv run coverage run -m pytest | |
| echo "pytest_exit_code=$?" >> $GITHUB_OUTPUT | |
| - name: Generate coverage report | |
| id: coverage | |
| if: always() | |
| run: | | |
| uv run coverage report --format=markdown --sort=Cover --skip-covered > coverage_report.md | |
| uv run coverage report | |
| echo "coverage_exit_code=$?" >> $GITHUB_OUTPUT | |
| - name: Comment coverage report on PR | |
| if: always() && github.event_name == 'pull_request' | |
| uses: marocchino/sticky-pull-request-comment@v2 | |
| with: | |
| header: coverage | |
| path: coverage_report.md | |
| - name: Check if tests and coverage passed | |
| if: always() | |
| run: | | |
| if [ "${{ steps.tests.outputs.pytest_exit_code }}" != "0" ]; then | |
| echo "Tests failed with exit code ${{ steps.tests.outputs.pytest_exit_code }}" | |
| exit 1 | |
| fi | |
| if [ "${{ steps.coverage.outputs.coverage_exit_code }}" != "0" ]; then | |
| echo "Coverage check failed with exit code ${{ steps.coverage.outputs.coverage_exit_code }}" | |
| exit 1 | |
| fi |