Skip to content

Commit

Permalink
Merge pull request #21 from caas-team/fix/workflow-cobertura-report-o…
Browse files Browse the repository at this point in the history
…n-pr

Fix Workflow Failures on Pull Requests from Forks by Splitting Workflows
  • Loading branch information
Fovty authored Jun 4, 2024
2 parents c8ee7b4 + f0e49bc commit 8f7800b
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 17 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/coverage-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Coverage Report

on:
workflow_run:
workflows: ["Python Tests"]
types:
- completed

permissions:
contents: read
issues: write
checks: write
pull-requests: write

jobs:
coverage:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.event == 'pull_request' }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.workflow_run.head_commit.id }}
- name: Download Coverage Artifacts
uses: dawidd6/action-download-artifact@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: ${{ github.event.workflow_run.workflow_id }}
commit: ${{ github.event.workflow_run.head_commit.id }}
name: coverage
path: coverage
- name: Produce Coverage report
uses: 5monkeys/cobertura-action@master
with:
path: coverage/coverage.xml
minimum_coverage: 70
skip_covered: false
34 changes: 17 additions & 17 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Python Tests
on:
push:
pull_request:
types: [opened, synchronize, reopened]

permissions:
contents: read
Expand All @@ -13,21 +14,20 @@ permissions:
jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install dependencies
run: |
pip install poetry
poetry install
- name: Run pytest with coverage and generate report
run: poetry run pytest --cov=tests --cov-report=xml tests/
- name: Upload coverage to Cobertura
uses: 5monkeys/cobertura-action@master
with:
path: coverage.xml
minimum_coverage: 70
skip_covered: false
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install dependencies
run: |
pip install poetry
poetry install
- name: Run pytest with coverage and generate report
run: poetry run pytest --cov=tests --cov-report=xml tests/
- uses: actions/upload-artifact@v4
with:
name: coverage
path: coverage.xml

0 comments on commit 8f7800b

Please sign in to comment.