✨ NATS server #991
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: Tests | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| jobs: | |
| tests: | |
| name: Tests (Python ${{ matrix.python-version }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: | |
| - '3.10' | |
| - '3.11' | |
| - '3.12' | |
| - '3.13' | |
| - '3.14' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Setup uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Install or update dependencies | |
| run: uv sync --frozen --all-extras --all-groups --python ${{ matrix.python-version }} | |
| - name: Run tests | |
| run: uv run coverage run -m pytest --color=yes tests/ | |
| - name: Display coverage | |
| run: uv run coverage report --no-skip-covered --show-missing --fail-under=0 | |
| - name: Rename .coverage file | |
| run: | | |
| mkdir coverage && \ | |
| mv .coverage ./coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }} | |
| - name: Store coverage files | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: coverage-${{ runner.os }}-py${{ matrix.python-version }} | |
| path: coverage | |
| include-hidden-files: true | |
| coverage-combine: | |
| needs: [tests] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Get coverage files | |
| uses: actions/download-artifact@v8 | |
| with: | |
| path: coverage | |
| pattern: coverage-* | |
| merge-multiple: true | |
| - name: Install dependencies | |
| run: uv sync --frozen --all-extras --all-groups | |
| - run: ls -la coverage | |
| - run: uv run coverage combine coverage | |
| - run: uv run coverage report --skip-covered --show-missing | |
| - run: uv run coverage json # json for coverage badge | |
| - name: Generate Coverage Badge | |
| if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) | |
| run: | | |
| COV=$(uv run python -c 'import json; print(json.load(open("coverage.json"))["totals"]["percent_covered_display"])') | |
| if [ "$COV" -ge 95 ]; then COLOR="brightgreen"; elif [ "$COV" -ge 80 ]; then COLOR="yellowgreen"; elif [ "$COV" -ge 60 ]; then COLOR="yellow"; else COLOR="red"; fi | |
| mkdir -p badges | |
| curl -s "https://img.shields.io/badge/coverage-${COV}%25-${COLOR}" > badges/coverage.svg | |
| - name: Publish Coverage Badge | |
| if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./badges | |
| publish_branch: gh-pages | |
| destination_dir: badges | |
| keep_files: true | |
| - name: Coverage summary report | |
| id: coverage_report | |
| if: always() | |
| run: | | |
| { | |
| echo "COVERAGE_REPORT<<EOF" | |
| uv run coverage report --format=markdown --show-missing --skip-covered | |
| echo "EOF" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Post coverage PR comment | |
| if: always() && github.event_name == 'pull_request' | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| const marker = '<!-- coverage-report -->'; | |
| const body = `${marker}\n## Coverage Report\n\n${{ steps.coverage_report.outputs.COVERAGE_REPORT }}`; | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| }); | |
| const previous = comments.find(c => c.body.includes(marker)); | |
| if (previous) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: previous.id, | |
| body, | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body, | |
| }); | |
| } |