Skip to content

Commit

Permalink
Merge pull request #297 from zowe/fix/ze-coverage-metrics
Browse files Browse the repository at this point in the history
Update coverage metrics for ZE V3
  • Loading branch information
t1m0thyj authored Nov 25, 2024
2 parents 83f5101 + 3e4d470 commit b67724f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
14 changes: 4 additions & 10 deletions coverage-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ projects:
unit-vsce:
junit-artifact: main.yml/ubuntu-latest-20.x-results/vsce/__tests__/__results__/unit
system:
test-count: npm-jest:packages/cli:packages/sdk
test-count: npm-jest:packages/cli,packages/sdk
"zowe/zowe-cli-db2-plugin":
unit:
junit-artifact: zowe-cli-plugin.yml/ubuntu-latest-20.x-results/unit
Expand All @@ -38,21 +38,15 @@ projects:
junit-artifact: zowe-cli-plugin.yml/ubuntu-latest-20.x-results/integration
system:
test-count: npm-jest
"zowe/zowe-cli-scs-plugin":
unit:
junit-artifact: zowe-cli-plugin.yml/ubuntu-latest-20.x-results/unit
lcov-artifact: zowe-cli-plugin.yml/ubuntu-latest-20.x-results/unit/coverage
system:
test-count: npm-jest
"zowe/zowe-explorer-vscode#main":
unit:
junit-artifact: zowe-explorer-ci.yml/zowe-explorer-results/unit
lcov-artifact: zowe-explorer-ci.yml/zowe-explorer-results/unit/coverage
junit-artifact: zowe-explorer-ci.yml/zowe-explorer-results/results/unit
lcov-artifact: zowe-explorer-ci.yml/zowe-explorer-results/results/unit/coverage
unit-api:
junit-artifact: zowe-explorer-ci.yml/zowe-explorer-api-results/unit
lcov-artifact: zowe-explorer-ci.yml/zowe-explorer-api-results/unit/coverage
unit-ftp:
junit-artifact: zowe-explorer-ftp-ci.yml/zowe-explorer-ftp-extension-results/unit
lcov-artifact: zowe-explorer-ftp-ci.yml/zowe-explorer-ftp-extension-results/unit/coverage
integration:
junit-artifact: theia-zowe-explorer-ci.yml/theia-zowe-explorer-results/integration
wdio-artifact: zowe-explorer-ci.yml/zowe-explorer-results/__tests__/__integration__/bdd/results
19 changes: 15 additions & 4 deletions scripts/coverage-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const path = require("path");
const exec = require("@actions/exec");
const github = require("@actions/github");
const AdmZip = require("adm-zip");
const glob = require("glob");
const jsYaml = require("js-yaml");
const parseLcov = require("parse-lcov");
const stripComments = require("strip-comments");
Expand Down Expand Up @@ -75,9 +76,16 @@ async function checkJunitArtifact(repo, type, workflow, artifact, dirname) {
if (tempDir == null) {
return {};
}
const junitFile = path.join(tempDir, dirname, "junit.xml");
const junitInfo = xmlJs.xml2js(fs.readFileSync(junitFile, "utf-8"), { compact: true });
const numTests = parseInt(junitInfo.testsuites._attributes.tests);
const junitFiles = [];
if (type === "wdio") {
junitFiles.push(...glob.sync(path.join(tempDir, dirname, "wdio-*-junit-reporter.log")));
} else {
junitFiles.push(path.join(tempDir, dirname, "junit.xml"));
}
const numTests = junitFiles.reduce((sum, filePath) => {
const junitInfo = xmlJs.xml2js(fs.readFileSync(filePath, "utf-8"), { compact: true });
return sum + parseInt(junitInfo.testsuites._attributes.tests);
}, 0);
return { numTests };
};

Expand Down Expand Up @@ -135,7 +143,10 @@ async function checkTestCount(repo, type, tools, ...subDirs) {
covData = { ...covData, ...await checkLcovArtifact(repoName, testType, ...splitAndAppend(covConfig, "/", 3)) };
break;
case "test-count":
covData = { ...covData, ...await checkTestCount(repoName, testType, ...covConfig.split(":")) };
covData = { ...covData, ...await checkTestCount(repoName, testType, ...covConfig.split(/[:,]/)) };
break;
case "wdio-artifact":
covData = { ...covData, ...await checkJunitArtifact(repoName, "wdio", ...splitAndAppend(covConfig, "/", 3)) };
break;
default:
throw new Error("Unsupported coverage type " + covType);
Expand Down

0 comments on commit b67724f

Please sign in to comment.