Skip to content

Commit

Permalink
testing code coverage logic on ci
Browse files Browse the repository at this point in the history
  • Loading branch information
aldousalvarez committed May 17, 2024
1 parent caa2b3a commit c811060
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 2 deletions.
112 changes: 111 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ jobs:
FULL_BUILD_DISABLED: true
JEST_TEST_PATTERN: packages/cactus-api-client/src/test/typescript/(unit|integration|benchmark)/.*/*.test.ts
JEST_TEST_RUNNER_DISABLED: false
JEST_TEST_COVERAGE_PATH: ./code-coverage-ts/cactus-api-client
JEST_TEST_CODE_COVERAGE_DISABLED: false
TAPE_TEST_PATTERN: ./packages/cactus-api-client/src/test/typescript/integration/default-consortium-provider.test.ts
TAPE_TEST_RUNNER_DISABLED: false
needs: build-dev
Expand All @@ -363,6 +365,13 @@ jobs:
${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }}
- run: ./tools/ci.sh

- name: Upload coverage reports as artifacts
uses: actions/upload-artifact@v4.3.3
with:
name: coverage-reports-1
path: ./code-coverage-ts/**/coverage-final.json

cactus-cmd-api-server:
continue-on-error: false
needs:
Expand Down Expand Up @@ -433,6 +442,8 @@ jobs:
FULL_BUILD_DISABLED: true
JEST_TEST_PATTERN: packages/cactus-cmd-socketio-server/src/test/typescript/(unit|integration|benchmark)/.*/*.test.ts
JEST_TEST_RUNNER_DISABLED: false
JEST_TEST_COVERAGE_PATH: ./code-coverage-ts/cactus-cmd-socketio-server
JEST_TEST_CODE_COVERAGE_DISABLED: false
TAPE_TEST_RUNNER_DISABLED: true
needs: build-dev
runs-on: ubuntu-22.04
Expand All @@ -454,13 +465,21 @@ jobs:
- run: ./tools/ci.sh

- name: Upload coverage reports as artifacts
uses: actions/upload-artifact@v4.3.3
with:
name: coverage-reports-2
path: ./code-coverage-ts/**/coverage-final.json

cactus-common:
continue-on-error: false
env:
DEV_BUILD_DISABLED: false
FULL_BUILD_DISABLED: true
JEST_TEST_PATTERN: packages/cactus-common/src/test/typescript/(unit|integration|benchmark)/.*/*.test.ts
JEST_TEST_RUNNER_DISABLED: false
JEST_TEST_COVERAGE_PATH: ./code-coverage-ts/cactus-common
JEST_TEST_CODE_COVERAGE_DISABLED: false
TAPE_TEST_PATTERN: '--files={./packages/cactus-common/src/test/typescript/unit/key-converter.test.ts,./packages/cactus-common/src/test/typescript/unit/logging/logger.test.ts}'
TAPE_TEST_RUNNER_DISABLED: false
needs: build-dev
Expand All @@ -482,12 +501,21 @@ jobs:
${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }}
- run: ./tools/ci.sh

- name: Upload coverage reports as artifacts
uses: actions/upload-artifact@v4.3.3
with:
name: coverage-reports-3
path: ./code-coverage-ts/**/coverage-final.json

cactus-core:
continue-on-error: false
env:
FULL_BUILD_DISABLED: true
JEST_TEST_PATTERN: packages/cactus-core/src/test/typescript/(unit|integration|benchmark)/.*/*.test.ts
JEST_TEST_RUNNER_DISABLED: false
JEST_TEST_COVERAGE_PATH: ./code-coverage-ts/cactus-core
JEST_TEST_CODE_COVERAGE_DISABLED: false
TAPE_TEST_RUNNER_DISABLED: true
needs: build-dev
runs-on: ubuntu-22.04
Expand All @@ -507,12 +535,21 @@ jobs:
restore-keys: |
${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }}
- run: ./tools/ci.sh

- name: Upload coverage reports as artifacts
uses: actions/upload-artifact@v4.3.3
with:
name: coverage-reports-4
path: ./code-coverage-ts/**/coverage-final.json

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: false
TAPE_TEST_RUNNER_DISABLED: true
needs: build-dev
runs-on: ubuntu-22.04
Expand All @@ -532,12 +569,21 @@ jobs:
restore-keys: |
${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }}
- run: ./tools/ci.sh

- name: Upload coverage reports as artifacts
uses: actions/upload-artifact@v4.3.3
with:
name: coverage-reports-5
path: ./code-coverage-ts/**/coverage-final.json

cactus-example-carbon-accounting-backend:
continue-on-error: false
env:
FULL_BUILD_DISABLED: true
JEST_TEST_PATTERN: examples/cactus-example-carbon-accounting-backend/src/test/typescript/(unit|integration|benchmark)/.*/*.test.ts
JEST_TEST_RUNNER_DISABLED: false
JEST_TEST_COVERAGE_PATH: ./code-coverage-ts/cactus-example-carbon-accounting-backend
JEST_TEST_CODE_COVERAGE_DISABLED: false
TAPE_TEST_PATTERN: ./examples/cactus-example-carbon-accounting-backend/src/test/typescript/integration/admin-enroll-v1-endpoint.test.ts
TAPE_TEST_RUNNER_DISABLED: false
needs: build-dev
Expand All @@ -558,12 +604,21 @@ jobs:
restore-keys: |
${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }}
- run: ./tools/ci.sh

- name: Upload coverage reports as artifacts
uses: actions/upload-artifact@v4.3.3
with:
name: coverage-reports-6
path: ./code-coverage-ts/**/coverage-final.json

cactus-example-carbon-accounting-business-logic-plugin:
continue-on-error: false
env:
FULL_BUILD_DISABLED: true
JEST_TEST_PATTERN: examples/cactus-example-carbon-accounting-business-logic-plugin/src/test/typescript/(unit|integration|benchmark)/.*/*.test.ts
JEST_TEST_RUNNER_DISABLED: false
JEST_TEST_COVERAGE_PATH: ./code-coverage-ts/cactus-example-carbon-accounting-business-logic-plugin
JEST_TEST_CODE_COVERAGE_DISABLED: false
TAPE_TEST_RUNNER_DISABLED: true
needs: build-dev
runs-on: ubuntu-22.04
Expand All @@ -583,6 +638,13 @@ jobs:
restore-keys: |
${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }}
- run: ./tools/ci.sh

- name: Upload coverage reports as artifacts
uses: actions/upload-artifact@v4.3.3
with:
name: coverage-reports-7
path: ./code-coverage-ts/**/coverage-final.json

cactus-example-carbon-accounting-frontend:
continue-on-error: false
env:
Expand Down Expand Up @@ -1813,6 +1875,7 @@ jobs:
restore-keys: |
${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }}
- run: ./tools/ci.sh

cactus-test-cmd-api-server:
continue-on-error: false
needs:
Expand Down Expand Up @@ -2346,6 +2409,53 @@ jobs:
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'
generate_coverage_report:
runs-on: ubuntu-22.04
needs: build-dev
steps:
- name: Use Node.js ${{ env.NODEJS_VERSION }}
uses: actions/setup-node@v4.0.2
with:
node-version: ${{ env.NODEJS_VERSION }}

- uses: actions/checkout@v4.1.1

- id: yarn-cache
name: Restore Yarn Cache
uses: actions/cache@v4.0.1
with:
key: ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }}
path: ./.yarn/
restore-keys: |
${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }}
- name: Install istanbul-merge
run: yarn add istanbul-merge --dev

- name: Run Configure
run: npm run configure

- name: Download coverage reports
uses: actions/download-artifact@v4.1.1
with:
path: ./code-coverage-ts/

- name: Display structure of downloaded files
run: ls -R ./code-coverage-ts/**/**/coverage-final.json

- name: Merge coverage reports
run: npx istanbul-merge --out coverage.json ./code-coverage-ts/coverage-reports-*/coverage-final.json

- name: Generate HTML report
run: npx istanbul report --include coverage.json --dir cacti html

- name: Output text report
run: npx istanbul report --include coverage.json --dir cacti text

- name: Output text-summary report
run: npx istanbul report --include coverage.json --dir cacti text-summary


name: Cactus_CI
'on':
pull_request:
Expand All @@ -2356,4 +2466,4 @@ name: Cactus_CI
push:
branches:
- main
- dev
- dev
2 changes: 1 addition & 1 deletion packages/cactus-cmd-api-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SHELL ["/bin/bash", "-c"]
ARG APP=/usr/src/app/
ENV APP_USER=appuser

# GUI: 3000, API: 4000, gRPC 5000
# GUI: 3000, API: 4000, gRPC 50008
EXPOSE 3000 4000 5000

RUN groupadd --gid 1000 appuser \
Expand Down
2 changes: 2 additions & 0 deletions tools/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:-true}" = "false" ]; then
yarn jest $JEST_TEST_PATTERN --coverage --coverageDirectory=$JEST_TEST_COVERAGE_PATH
else
yarn test:jest:all $JEST_TEST_PATTERN
fi
Expand Down

0 comments on commit c811060

Please sign in to comment.