From 7d6ef030acbd79ff655746b3ea5580c528df2d08 Mon Sep 17 00:00:00 2001 From: aldousalvarez Date: Mon, 29 Apr 2024 15:27:08 +0800 Subject: [PATCH] testing code coverage logic on ci --- .github/workflows/ci.yaml | 19 +++++++++++++++++++ tools/ci.sh | 2 ++ 2 files changed, 21 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c3cb1d89769..5061d7c0abc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -363,6 +363,7 @@ jobs: ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }} - run: ./tools/ci.sh + cactus-cmd-api-server: continue-on-error: false needs: @@ -482,6 +483,7 @@ jobs: ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }} - run: ./tools/ci.sh + cactus-core: continue-on-error: false env: @@ -507,12 +509,15 @@ jobs: restore-keys: | ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }} - run: ./tools/ci.sh + cactus-core-api: continue-on-error: false env: FULL_BUILD_DISABLED: true JEST_TEST_PATTERN: packages/cactus-core-api/src/test/typescript/(unit|integration|benchmark)/.*/*.test.ts JEST_TEST_RUNNER_DISABLED: false + JEST_TEST_COVERAGE_PATH: ./code-coverage-ts/cactus-core-api + JEST_TEST_CODE_COVERAGE_DISABLED: true TAPE_TEST_RUNNER_DISABLED: true needs: build-dev runs-on: ubuntu-22.04 @@ -532,6 +537,16 @@ jobs: restore-keys: | ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }} - run: ./tools/ci.sh + + - name: Merge coverage reports + run: npx istanbul-merge --out coverage.json ./code-coverage-ts/cactus-core-api/coverage-final.json + + - name: Upload coverage reports as artifacts + uses: actions/upload-artifact@v2 + with: + name: coverage-reports + path: ./code-coverage-ts/cactus-core-api + cactus-example-carbon-accounting-backend: continue-on-error: false env: @@ -558,6 +573,7 @@ jobs: restore-keys: | ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }} - run: ./tools/ci.sh + cactus-example-carbon-accounting-business-logic-plugin: continue-on-error: false env: @@ -583,6 +599,7 @@ jobs: restore-keys: | ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }} - run: ./tools/ci.sh + cactus-example-carbon-accounting-frontend: continue-on-error: false env: @@ -2313,6 +2330,8 @@ jobs: ignore-unfixed: true vuln-type: 'os,library' severity: 'CRITICAL,HIGH' + + name: Cactus_CI 'on': pull_request: diff --git a/tools/ci.sh b/tools/ci.sh index 305f8d424c4..bb91152a3cf 100755 --- a/tools/ci.sh +++ b/tools/ci.sh @@ -146,6 +146,8 @@ function mainTask() if [ "${JEST_TEST_RUNNER_DISABLED:-false}" = "true" ]; then echo "$(date +%FT%T%z) [CI] Jest test runner disabled. Skipping..." + elif [ "${JEST_TEST_CODE_COVERAGE_DISABLED:-false}" = "false" ]; then + yarn test:jest:all $JEST_TEST_PATTERN --coverage --coverageDirectory=$JEST_TEST_COVERAGE_PATH else yarn test:jest:all $JEST_TEST_PATTERN fi