From 023d1af1894148ed9f94314ad10961d7e2a4f74e Mon Sep 17 00:00:00 2001 From: Luis Barroso-Luque Date: Thu, 28 Sep 2023 12:39:21 -0700 Subject: [PATCH 1/3] DEV: separate test and cov --- .github/workflows/coverage.yml | 43 ++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..7a77831 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,43 @@ +name: report coverage + +on: + workflow_run: + workflows: [test] + types: + - completed + +jobs: + report-coverage: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + + steps: + - name: download coverage artifact + uses: actions/github-script@v6 + with: + script: | + let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: context.payload.workflow_run.id, + }); + let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { + return artifact.name == "pr_number" + })[0]; + let download = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }); + let fs = require('fs'); + fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_number.zip`, Buffer.from(download.data)); + + - name: unzip artifact + run: unzip coverage.zip + + - name: run codacy-coverage-reporter + uses: codacy/codacy-coverage-reporter-action@v1 + with: + project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} + coverage-reports: coverage.xml From b3d5cab45cf1c3aef03f7d91f5c448872dd34ca2 Mon Sep 17 00:00:00 2001 From: Luis Barroso-Luque Date: Thu, 28 Sep 2023 12:42:25 -0700 Subject: [PATCH 2/3] DEV: upload coverage artifact --- .github/workflows/test.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 30c6cd3..2a05218 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,9 +45,9 @@ jobs: run: | pytest tests --cov=sparselm --cov-report=xml - - if: ${{ matrix.python_version == 3.11 && github.event_name == 'push' }} - name: codacy-coverage-reporter - uses: codacy/codacy-coverage-reporter-action@v1 + - if: matrix.python_version == '3.11' + name: upload coverage report + uses: actions/upload-artifact@v3 with: - project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} - coverage-reports: coverage.xml + name: coverage + path: coverage.xml From 95558d6a4dc3d0d8509c6e6cdf36e1c7cdce16d2 Mon Sep 17 00:00:00 2001 From: Luis Barroso-Luque Date: Thu, 28 Sep 2023 12:52:05 -0700 Subject: [PATCH 3/3] DEV: fix artifact download --- .github/workflows/coverage.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 7a77831..289e605 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -22,7 +22,7 @@ jobs: run_id: context.payload.workflow_run.id, }); let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { - return artifact.name == "pr_number" + return artifact.name == "coverage" })[0]; let download = await github.rest.actions.downloadArtifact({ owner: context.repo.owner, @@ -31,7 +31,7 @@ jobs: archive_format: 'zip', }); let fs = require('fs'); - fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_number.zip`, Buffer.from(download.data)); + fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/coverage.zip`, Buffer.from(download.data)); - name: unzip artifact run: unzip coverage.zip