From ce9fdaddc9fbba78cccd721c3203b3daf57f0bcf Mon Sep 17 00:00:00 2001 From: Doug Goldstein Date: Thu, 7 Nov 2024 12:56:34 -0600 Subject: [PATCH] ci: split up code coverage reporting to support forks Make it possible to support forks by splitting the code coverage reporting into two steps. Forks cannot make changes against the main repo so they cannot update the ticket so it must be split into two parts. Simplify the reporting as well by merging it together into one coverage file. --- .github/workflows/code-test.yaml | 27 +++++++++++++++++++------- .github/workflows/coverage-report.yaml | 27 ++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/coverage-report.yaml diff --git a/.github/workflows/code-test.yaml b/.github/workflows/code-test.yaml index 3af3e2b3..72b2e243 100644 --- a/.github/workflows/code-test.yaml +++ b/.github/workflows/code-test.yaml @@ -21,10 +21,6 @@ concurrency: jobs: python: - permissions: - contents: read - pull-requests: write - runs-on: ubuntu-latest strategy: @@ -48,7 +44,24 @@ jobs: - run: poetry install --sync --with test - run: poetry build - run: "poetry run pytest --cov --cov-report xml:coverage.xml" - - uses: orgoro/coverage@3f13a558c5af7376496aa4848bf0224aead366ac # v3.2 + - uses: actions/upload-artifact@v4 + with: + name: coverage-${{ matrix.project }} + path: python/${{ matrix.project }}/coverage.xml + retention-days: 1 + + coverage-upload: + needs: python + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v4 + with: + pattern: coverage-* + merge-multiple: true + - run: | + npx cobertura-merge-globby -o output.xml --files=python/**/coverage.xml + - uses: actions/upload-artifact@v4 with: - coverageFile: python/${{ matrix.project }}/coverage.xml - token: ${{ secrets.GITHUB_TOKEN }} + name: coverage.xml + path: coverage.xml + retention-days: 1 diff --git a/.github/workflows/coverage-report.yaml b/.github/workflows/coverage-report.yaml new file mode 100644 index 00000000..d4f0caba --- /dev/null +++ b/.github/workflows/coverage-report.yaml @@ -0,0 +1,27 @@ +name: Coverage Report + +on: + workflow_run: + workflows: ["code tests"] + types: + - completed + +permissions: + actions: read + contents: read + pull-requests: write + +jobs: + coverage-report: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - uses: actions/download-artifact@v4 + with: + name: coverage.xml + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ secrets.GITHUB_TOKEN }} + - uses: orgoro/coverage@3f13a558c5af7376496aa4848bf0224aead366ac # v3.2 + with: + coverageFile: coverage.xml + token: ${{ secrets.GITHUB_TOKEN }}