Add file caching to improvement performance when running uv-secure multiple times #67
Workflow file for this run
This file contains 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: Pytest | |
on: | |
pull_request: | |
jobs: | |
pytest-with-coverage: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: ["ubuntu-latest", "macos-latest", "windows-latest"] | |
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] | |
permissions: | |
contents: read | |
pull-requests: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v4 | |
with: | |
enable-cache: true | |
cache-dependency-glob: "uv.lock" | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install the project | |
run: uv sync --dev | |
- name: Run tests with Coverage | |
run: uv run pytest tests --cov=. --cov-report=term | |
- name: Upload coverage artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-${{ matrix.os }}-python-${{ matrix.python-version }} | |
path: .coverage | |
include-hidden-files: true | |
combine-and-comment: | |
runs-on: ubuntu-latest | |
needs: pytest-with-coverage | |
permissions: | |
contents: read | |
pull-requests: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.13" | |
- name: Install the project | |
run: uv sync --dev | |
- name: Download all coverage artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: coverage | |
- name: Combine coverage data | |
run: | | |
uv run coverage combine coverage/*-python-*/.coverage | |
uv run coverage report > coverage_summary.txt | |
- name: Prepare Comment Body | |
run: | | |
echo '### Coverage Report' >> comment_body.md | |
echo '```txt' >> comment_body.md | |
cat coverage_summary.txt >> comment_body.md | |
echo '' >> comment_body.md | |
echo '```' >> comment_body.md | |
- name: Find Coverage Report Comment | |
if: github.event.pull_request.head.repo.full_name == github.repository | |
id: find-comment | |
uses: peter-evans/find-comment@v3 | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: github-actions[bot] | |
body-includes: '### Coverage Report' | |
- name: Create or Update Coverage Comment | |
if: github.event.pull_request.head.repo.full_name == github.repository | |
uses: peter-evans/create-or-update-comment@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
issue-number: ${{ github.event.pull_request.number }} | |
body-path: comment_body.md | |
comment-id: ${{ steps.find-comment.outputs.comment-id }} | |
edit-mode: replace | |
- name: Display Coverage Report in Logs | |
run: cat comment_body.md |