docs: add gist ID for dynamic test count badge #20
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: Tests | |
| on: | |
| push: | |
| branches: [main, 001-modular-refactor] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ['3.9', '3.10', '3.11', '3.12'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements-dev.txt | |
| pip install -r requirements.txt | |
| - name: Run linter | |
| run: | | |
| ruff check src/github_analyzer/ | |
| - name: Run type checker | |
| run: | | |
| mypy src/github_analyzer/ | |
| - name: Run tests | |
| run: | | |
| pytest tests/ -v --tb=short | |
| - name: Run tests with coverage | |
| run: | | |
| pytest tests/ --cov=src/github_analyzer --cov-report=xml --cov-report=term-missing | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| if: matrix.python-version == '3.11' | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: ./coverage.xml | |
| fail_ci_if_error: false | |
| - name: Update test count badge | |
| if: matrix.python-version == '3.11' && github.ref == 'refs/heads/main' | |
| run: | | |
| # Extract test count from pytest output | |
| TEST_COUNT=$(pytest tests/ --collect-only -q 2>/dev/null | tail -1 | grep -oE '^[0-9]+') | |
| echo "Test count: $TEST_COUNT" | |
| # Create badge JSON for shields.io endpoint | |
| echo "{\"schemaVersion\":1,\"label\":\"tests\",\"message\":\"${TEST_COUNT} passed\",\"color\":\"brightgreen\"}" > badge.json | |
| # Update gist with badge data | |
| curl -X PATCH \ | |
| -H "Authorization: token ${{ secrets.GIST_TOKEN }}" \ | |
| -H "Accept: application/vnd.github.v3+json" \ | |
| https://api.github.com/gists/${{ secrets.GIST_ID }} \ | |
| -d "{\"files\":{\"github_analyzer_tests.json\":{\"content\":$(cat badge.json | jq -Rs .)}}}" | |
| test-stdlib-only: | |
| name: Test without requests (stdlib only) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install test dependencies only | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install pytest pytest-cov | |
| - name: Run tests without requests | |
| run: | | |
| pytest tests/ -v --tb=short |