Skip to content

EFS-948: Fixing jest being torn down issue in testcases #6471

EFS-948: Fixing jest being torn down issue in testcases

EFS-948: Fixing jest being torn down issue in testcases #6471

Workflow file for this run

# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Node.js CI
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
lint:
runs-on: ubuntu-latest
name: lint
steps:
- uses: actions/checkout@v4
- name: Use Node.js 20.11.1
uses: actions/setup-node@v4
with:
node-version: 20.11.1
- run: | # retry since mongo memory server fails to download sometimes
yarn install || yarn install
- run: npm run build --if-present
- name: lint
run: |
npm run lint
build:
runs-on: ubuntu-latest
name: test (chunk ${{ matrix.chunk }})
strategy:
matrix:
shard: [ 1, 2, 3, 4, 5, 6, 7, 8 ]
fail-fast: false
outputs:
jest_outcome: ${{ steps.output_variables.outputs.jest_outcome }}
coverage_line: ${{ steps.output_variables.outputs.coverage_line }}
coverage_statement: ${{ steps.output_variables.outputs.coverage_statement }}
coverage_branch: ${{ steps.output_variables.outputs.coverage_branch }}
coverage_function: ${{ steps.output_variables.outputs.coverage_function }}
steps:
- uses: actions/checkout@v4
- name: Use Node.js 20.11.1
uses: actions/setup-node@v4
with:
node-version: 20.11.1
- run: | # retry since mongo memory server fails to download sometimes
yarn install || yarn install
- run: npm run build --if-present
- name: show memory
run: |
export NODE_OPTIONS="--max-old-space-size=8192"
NODE_OPTIONS=--max-old-space-size=8192 node --max-old-space-size=8192 ./src/utils/showMemory.js
env:
NODE_OPTIONS: "--max-old-space-size=10240"
- name: jest
id: jest
run: |
export NODE_OPTIONS="--max-old-space-size=8192"
NODE_OPTIONS=--max-old-space-size=8192 node --max-old-space-size=8192 ./node_modules/.bin/jest --no-watchman --silent --logHeapUsage --runInBand --forceExit --shard=${{ matrix.shard }}/${{ strategy.job-total }} --coverage
env:
NODE_OPTIONS: "--max-old-space-size=10240"
- name: Set output variables for badges
id: output_variables
run: |
echo "jest_outcome=${{ steps.jest.outcome }}" >> $GITHUB_OUTPUT
coverage_line=$(jq -r '.total.lines.pct' coverage/coverage-summary.json)
coverage_statement=$(jq -r '.total.statements.pct' coverage/coverage-summary.json)
coverage_branch=$(jq -r '.total.branches.pct' coverage/coverage-summary.json)
coverage_function=$(jq -r '.total.functions.pct' coverage/coverage-summary.json)
echo "coverage_line=$coverage_line" >> $GITHUB_OUTPUT
echo "coverage_statement=$coverage_statement" >> $GITHUB_OUTPUT
echo "coverage_branch=$coverage_branch" >> $GITHUB_OUTPUT
echo "coverage_function=$coverage_function" >> $GITHUB_OUTPUT
- name: Rename coverage file name
if: github.ref == 'refs/heads/main'
run: mv coverage/coverage-final.json coverage/${{matrix.shard}}.json
- name: Upload coverage file
uses: actions/upload-artifact@v3
if: github.ref == 'refs/heads/main'
with:
name: coverage-artifacts
path: coverage/
create-badges:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: build
steps:
- name: Create Test Cases Status & Coverage Badges
uses: peterrhodesdev/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
filename: ("testcases_status" "testcases_coverage_line" "testcases_coverage_statement" "testcases_coverage_branch" "testcases_coverage_function")
label: ("Test cases status" "Test cases coverage [Line]" "Test cases coverage [Statement]" "Test cases coverage [Branch]" "Test cases coverage [Function]")
message: (${{ needs.build.outputs.jest_outcome }} ${{ needs.build.outputs.coverage_line }} ${{ needs.build.outputs.coverage_statement }} ${{ needs.build.outputs.coverage_branch }} ${{ needs.build.outputs.coverage_function }})
color: (${{ needs.build.outputs.jest_outcome == 'success' && "009900" || "FF0000" }} "993366" "993366" "993366" "993366")

Check failure on line 99 in .github/workflows/node.js.yml

View workflow run for this annotation

GitHub Actions / Node.js CI

Invalid workflow file

The workflow is not valid. .github/workflows/node.js.yml (Line: 99, Col: 18): Unexpected symbol: '"009900"'. Located at position 50 within expression: needs.build.outputs.jest_outcome == 'success' && "009900" || "FF0000"