From 27591f064aeab8d83d1e143ae143100f9fbfac92 Mon Sep 17 00:00:00 2001 From: Johannes Thiem Date: Tue, 4 Jun 2024 11:02:06 +0200 Subject: [PATCH 1/2] Restricting the types of PRs, formatting & only create artifact --- .github/workflows/python-tests.yml | 34 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 1f495c3..a7dce6f 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -3,6 +3,7 @@ name: Python Tests on: push: pull_request: + types: [opened, synchronize, reopened] permissions: contents: read @@ -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 \ No newline at end of file + - 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 From f0e49bc9bf3f4e1cae66fa8ecd0a108ca06fbb9c Mon Sep 17 00:00:00 2001 From: Johannes Thiem Date: Tue, 4 Jun 2024 11:02:13 +0200 Subject: [PATCH 2/2] coverage report creation --- .github/workflows/coverage-report.yml | 38 +++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/coverage-report.yml diff --git a/.github/workflows/coverage-report.yml b/.github/workflows/coverage-report.yml new file mode 100644 index 0000000..4027a7a --- /dev/null +++ b/.github/workflows/coverage-report.yml @@ -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