Skip to content

Commit

Permalink
⚗️ Test for CI System (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
soo-bak committed Jul 7, 2024
1 parent c85ed43 commit f1719a7
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions .github/workflows/UnitTestsAndCodeCoverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,28 @@ jobs:
name: Badge coverage report for ${{ matrix.testMode }}
path: CodeCoverage/Report/badge_linecoverage.svg

- name: Comment on PR with Coverage Results
uses: actions/github-script@v4
if: always()
- name: Setup Node.js
uses: actions/setup-node@v2
with:
script: |
node-version: '14'

- name: Install xml2js
run: npm install xml2js

- name: Comment on PR with Coverage Results
run: |
node -e "
const fs = require('fs');
const xml2js = require('xml2js');
const parser = new xml2js.Parser();
const xml = fs.readFileSync('CodeCoverage/Summary.xml', 'utf8');
parser.parseString(xml, function (err, result) {
parser.parseString(xml, (err, result) => {
if (err) throw err;
const summary = result.CoverageReport.Summary[0];
const commentBody = `
## Code Coverage Summary
- **Generated on**: ${summary.Generatedon[0]}
- **Parser**: ${summary.Parser[0]}
- **Assemblies**: ${summary.Assemblies[0]}
- **Classes**: ${summary.Classes[0]}
- **Files**: ${summary.Files[0]}
Expand All @@ -106,14 +112,20 @@ jobs:
- **Coverable Lines**: ${summary.Coverallines[0]}
- **Total Lines**: ${summary.Totallines[0]}
- **Line Coverage**: ${summary.Linecoverage[0]}%
- **Covered Branches**: ${summary.Coveredbranches[0]}
- **Total Branches**: ${summary.Totalbranches[0]}
- **Covered Methods**: ${summary.Coveredmethods[0]}
- **Total Methods**: ${summary.Totalmethods[0]}
- **Method Coverage**: ${summary.Methodcoverage[0]}%
`;
const { context, github } = require('@actions/github');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
});
});
"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit f1719a7

Please sign in to comment.