mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-09-02 09:38:05 +00:00
[workflow]auto comment with test coverage report (#2419)
* [workflow]auto comment with test coverage report * polish code * polish yaml
This commit is contained in:
69
.github/workflows/report_test_coverage.yml
vendored
Normal file
69
.github/workflows/report_test_coverage.yml
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
name: Report Test Coverage
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: [Build]
|
||||
types:
|
||||
- completed
|
||||
|
||||
jobs:
|
||||
report-test-coverage:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 'Download 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 == "report"
|
||||
})[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}/report.zip`, Buffer.from(download.data));
|
||||
|
||||
- name: 'Unzip artifact'
|
||||
run: |
|
||||
unzip report.zip
|
||||
|
||||
- name: Code Coverage Report
|
||||
uses: irongut/CodeCoverageSummary@v1.3.0
|
||||
with:
|
||||
filename: coverage.xml
|
||||
badge: true
|
||||
fail_below_min: true
|
||||
format: markdown
|
||||
hide_branch_rate: false
|
||||
hide_complexity: false
|
||||
indicators: true
|
||||
output: both
|
||||
thresholds: '80 90'
|
||||
|
||||
- name: 'Comment on PR'
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
let fs = require('fs');
|
||||
let issue_number = Number(fs.readFileSync('./pr_number'));
|
||||
let owner = context.repo.owner;
|
||||
let repo = context.repo.repo;
|
||||
let run_id = context.payload.workflow_run.id;
|
||||
let run_url = `https://github.com/${owner}/${repo}/actions/runs/${run_id}`
|
||||
let body = fs.readFileSync('./code-coverage-results.md', {encoding:'utf8', flag:'r'})
|
||||
|
||||
await github.rest.issues.createComment({
|
||||
owner: owner,
|
||||
repo: repo,
|
||||
issue_number: issue_number,
|
||||
body: body
|
||||
});
|
Reference in New Issue
Block a user