Skip to content

Commit

Permalink
Make coverage files optional
Browse files Browse the repository at this point in the history
  • Loading branch information
lmd59 committed Nov 11, 2024
1 parent 460275b commit 5eecee7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 30 deletions.
55 changes: 29 additions & 26 deletions regression/regression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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'));
11 changes: 7 additions & 4 deletions regression/run-regression.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ GREEN='\033[0;32m'
NC='\033[0m'

VERBOSE=false
INTERNAL=false
BASE_BRANCH="master"

function usage() {
cat <<USAGE
Usage: $0 [-b|--base-branch <branch-name>] [-v|--verbose]
Usage: $0 [-b|--base-branch <branch-name>] [-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
}
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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"
Expand Down

0 comments on commit 5eecee7

Please sign in to comment.