From f610b92473a9755135e670783f3b0d6a79376f9f Mon Sep 17 00:00:00 2001 From: Lucas Li <35748253+yzlucas@users.noreply.github.com> Date: Tue, 17 Sep 2024 22:20:20 -0700 Subject: [PATCH] Test scan (#50) * test * try use node version 18 * trigger test * Remove package-lock.json * trigger test * Update the browsers property to use ChromeHeadless instead of Chrome * trigger p * update unit test * run unit test * missing fi * test scan * change the path of converage-summary * teigger * print out the coverage-summary.json * trigger * update grep script * trigger * modify check code coverage part * modify check code coverage part --- .github/workflows/test.yml | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f45f28e18..43c3c3f2f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Run Tests +name: Run Tests env: NPMRC: ${{ secrets.NPMRC }} @@ -52,12 +52,16 @@ jobs: working-directory: client/wfprev-war/src/main/angular # Ensure coverage meets the required threshold - - name: Check code coverage - run: | - if grep -q '"statements":.*"pct": \([8-9][0-9]\|100\)' coverage/wfprev/coverage-summary.json; then - echo "Test passed"; - else - echo "Code coverage is less than 80%! Exiting..."; - exit 1; - fi - working-directory: client/wfprev-war/src/main/angular + - name: Check code coverage + run: | + # Extract the "pct" value for "statements" using jq + statements_pct=$(jq '.total.statements.pct' coverage/wfprev/coverage-summary.json) + + # Check if the percentage is greater than or equal to 80 + if (( $(echo "$statements_pct >= 80" | bc -l) )); then + echo "Test passed. Code coverage for statements is $statements_pct%"; + else + echo "Code coverage for statements is less than 80%! Exiting... ($statements_pct%)"; + exit 1; + fi + working-directory: client/wfprev-war/src/main/angular \ No newline at end of file