Merge branch 'refactor/comprehensive-improvements' of github.com:week… #22
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, master, develop, refactor/* ] | |
| pull_request: | |
| branches: [ main, master, develop ] | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| test: | |
| name: Test (Python ${{ matrix.python-version }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12"] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: true | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ".[dev]" | |
| - name: Run tests with coverage | |
| run: | | |
| pytest tests/test_lpm.py tests/test_concurrency.py \ | |
| --cov=service \ | |
| --cov-report=xml \ | |
| --cov-report=term-missing \ | |
| -v | |
| - name: Upload coverage to Codecov | |
| if: matrix.python-version == '3.11' | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| file: ./coverage.xml | |
| flags: unittests | |
| name: codecov-umbrella | |
| fail_ci_if_error: false | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Generate coverage badge | |
| if: matrix.python-version == '3.11' && github.ref == 'refs/heads/main' | |
| run: | | |
| pip install genbadge[coverage] | |
| genbadge coverage -i coverage.xml -o coverage-badge.svg | |
| - name: Commit coverage badge | |
| if: matrix.python-version == '3.11' && github.ref == 'refs/heads/main' | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add coverage-badge.svg | |
| git diff --quiet && git diff --staged --quiet || git commit -m "chore: Update coverage badge [skip ci]" | |
| git push | |
| lint: | |
| name: Code Quality | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ".[dev]" | |
| - name: Run ruff linter | |
| run: | | |
| ruff check service/ tests/ --output-format=github | |
| - name: Run ruff formatter check | |
| run: | | |
| ruff format --check service/ tests/ | |
| - name: Run mypy type checker | |
| run: | | |
| mypy service/ --ignore-missing-imports | |
| security: | |
| name: Security Scan | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install bandit | |
| - name: Run bandit security scan | |
| run: | | |
| bandit -r service/ -f json -o bandit-report.json || true | |
| bandit -r service/ || true | |
| build: | |
| name: Build Container | |
| runs-on: ubuntu-latest | |
| needs: [test, lint] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build runtime image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: false | |
| target: runtime | |
| tags: routing-table-api:latest | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Build test image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: false | |
| target: development | |
| tags: routing-table-api:test | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |