Skip to content

Commit

Permalink
Merge pull request #108 from lbluque/main
Browse files Browse the repository at this point in the history
separate test and coverage reporting
  • Loading branch information
lbluque authored Sep 28, 2023
2 parents 936c90c + 95558d6 commit c9dd678
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 5 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -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 == "coverage"
})[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}/coverage.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
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c9dd678

Please sign in to comment.