From 5eecee732bc7ba9582d398cf255e3b303033132d Mon Sep 17 00:00:00 2001 From: LaurenD Date: Mon, 11 Nov 2024 14:51:13 -0500 Subject: [PATCH] Make coverage files optional --- regression/regression.ts | 55 +++++++++++++++++++----------------- regression/run-regression.sh | 11 +++++--- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/regression/regression.ts b/regression/regression.ts index 49f31da0..24178871 100644 --- a/regression/regression.ts +++ b/regression/regression.ts @@ -4,6 +4,7 @@ import { Calculator } from '../src'; const regressionBaseName = process.argv[2] ?? 'regression-output'; const verbose = process.argv[3] === 'true'; +const internal = process.argv[4] === 'true'; const REGRESSION_OUTPUT_DIR = path.join(__dirname, `./output/${regressionBaseName}`); const CTHON_BASE_PATH = path.join(__dirname, './connectathon/fhir401/bundles/measure'); @@ -119,32 +120,34 @@ async function main() { await calculateRegression(filesPath, testFilePaths, measureBundle, dir.shortName); } - // coverage directory organized with multiple measures for each set of test files - const covDirs = fs.readdirSync(COVERAGE_BASE_PATH).map(f => ({ - shortName: f, - fullPath: path.join(COVERAGE_BASE_PATH, f) - })); - for (const dir of covDirs) { - const basePath = dir.fullPath; - - const patientDirectoryPath = path.join(basePath, `${dir.shortName}-TestCases`); - // Skip measures with no `*-TestCases` directory - if (!fs.existsSync(patientDirectoryPath)) continue; - const testFilePaths = findPatientBundlePathsInDirectory(patientDirectoryPath); - // Skip measures with no test patients in the `*-files` directory - if (testFilePaths.length === 0) continue; - - // Two versions of measure - const measureBundle314 = JSON.parse( - fs.readFileSync(path.join(basePath, `${dir.shortName}-v314.json`), 'utf8') - ) as fhir4.Bundle; - await calculateRegression(patientDirectoryPath, testFilePaths, measureBundle314, `${dir.shortName}-v314`); - - const measureBundle332 = JSON.parse( - fs.readFileSync(path.join(basePath, `${dir.shortName}-v332.json`), 'utf8') - ) as fhir4.Bundle; - await calculateRegression(patientDirectoryPath, testFilePaths, measureBundle332, `${dir.shortName}-v332`); - } + if (internal){ + // coverage directory organized with multiple measures for each set of test files + const covDirs = fs.readdirSync(COVERAGE_BASE_PATH).map(f => ({ + shortName: f, + fullPath: path.join(COVERAGE_BASE_PATH, f) + })); + for (const dir of covDirs) { + const basePath = dir.fullPath; + + const patientDirectoryPath = path.join(basePath, `${dir.shortName}-TestCases`); + // Skip measures with no `*-TestCases` directory + if (!fs.existsSync(patientDirectoryPath)) continue; + const testFilePaths = findPatientBundlePathsInDirectory(patientDirectoryPath); + // Skip measures with no test patients in the `*-files` directory + if (testFilePaths.length === 0) continue; + + // Two versions of measure + const measureBundle314 = JSON.parse( + fs.readFileSync(path.join(basePath, `${dir.shortName}-v314.json`), 'utf8') + ) as fhir4.Bundle; + await calculateRegression(patientDirectoryPath, testFilePaths, measureBundle314, `${dir.shortName}-v314`); + + const measureBundle332 = JSON.parse( + fs.readFileSync(path.join(basePath, `${dir.shortName}-v332.json`), 'utf8') + ) as fhir4.Bundle; + await calculateRegression(patientDirectoryPath, testFilePaths, measureBundle332, `${dir.shortName}-v332`); + } + } } main().then(() => console.log('done')); diff --git a/regression/run-regression.sh b/regression/run-regression.sh index 6e60c735..833498aa 100755 --- a/regression/run-regression.sh +++ b/regression/run-regression.sh @@ -10,16 +10,18 @@ GREEN='\033[0;32m' NC='\033[0m' VERBOSE=false +INTERNAL=false BASE_BRANCH="master" function usage() { cat <] [-v|--verbose] + Usage: $0 [-b|--base-branch ] [-v|--verbose] [-i|--internal] Options: -b/--base-branch: Base branch to compare results with (default: master) -v/--verbose: Use verbose regression. Will print out diffs of failing JSON files with spacing (default: false) + -i/--internal: Include limited-access internal resources in the test files (default: false) USAGE exit 1 } @@ -28,6 +30,7 @@ while test $# != 0 do case "$1" in -v | --verbose) VERBOSE=true ;; + -i | --internal) INTERNAL=true ;; -b | --base-branch) shift BASE_BRANCH=$1 @@ -49,7 +52,7 @@ if [ ! -d "regression/ecqm-content-qicore-2022" ]; then git clone https://github.com/cqframework/ecqm-content-qicore-2022.git regression/ecqm-content-qicore-2022 fi -if [ ! -d "regression/coverage-script-bundles" ]; then +if [ $INTERNAL = "true" ] && [ ! -d "regression/coverage-script-bundles" ]; then git clone https://gitlab.mitre.org/flame/coverage-script-bundles.git regression/coverage-script-bundles fi @@ -67,13 +70,13 @@ TIMESTAMP=$(date +%s) echo "Gathering results on current branch '$CURRENT_BRANCH'" npm i -npx ts-node --files ./regression/regression.ts "$CURRENT_BRANCH-$TIMESTAMP" $VERBOSE +npx ts-node --files ./regression/regression.ts "$CURRENT_BRANCH-$TIMESTAMP" $VERBOSE $INTERNAL echo "Gathering results on base branch '$BASE_BRANCH'" git checkout $BASE_BRANCH npm i -npx ts-node --files ./regression/regression.ts "$BASE_BRANCH-$TIMESTAMP" $VERBOSE +npx ts-node --files ./regression/regression.ts "$BASE_BRANCH-$TIMESTAMP" $VERBOSE $INTERNAL FAILURES=() BASE_BRANCH_BASE_PATH="regression/output/$BASE_BRANCH-$TIMESTAMP"