diff --git a/.github/workflows/UnitTestsAndCodeCoverage.yml b/.github/workflows/UnitTestsAndCodeCoverage.yml index 2b6b12d..590789d 100644 --- a/.github/workflows/UnitTestsAndCodeCoverage.yml +++ b/.github/workflows/UnitTestsAndCodeCoverage.yml @@ -89,7 +89,6 @@ jobs: echo "SUMMARY_EXISTS=true" >> $GITHUB_ENV else echo "SUMMARY_EXISTS=false" >> $GITHUB_ENV - fi - name: Setup Node.js if: env.SUMMARY_EXISTS == 'true' @@ -105,41 +104,41 @@ jobs: if: env.SUMMARY_EXISTS == 'true' run: | echo "const fs = require('fs'); - const xml2js = require('xml2js'); - const parser = new xml2js.Parser(); - const xml = fs.readFileSync('CodeCoverage/Report/Summary.xml', 'utf8'); - const { context, getOctokit } = require('@actions/github'); - const github = getOctokit(process.env.GITHUB_TOKEN); - - 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]} - - **Covered Lines**: ${summary.Coveredlines[0]} - - **Uncovered Lines**: ${summary.Uncoveredlines[0]} - - **Coverable Lines**: ${summary.Coverablelines[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]}% - `; - - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: commentBody - }); - });" > script.js +const xml2js = require('xml2js'); +const parser = new xml2js.Parser(); +const xml = fs.readFileSync('CodeCoverage/Report/Summary.xml', 'utf8'); +const { context, getOctokit } = require('@actions/github'); +const github = getOctokit(process.env.GITHUB_TOKEN); + +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]} + - **Covered Lines**: ${summary.Coveredlines[0]} + - **Uncovered Lines**: ${summary.Uncoveredlines[0]} + - **Coverable Lines**: ${summary.Coverablelines[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]}% + `; + + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: commentBody + }); +});" > script.js - name: Run Node.js Script if: env.SUMMARY_EXISTS == 'true'