From 2eda1f855552a0b8441164d30d0ca5ecfa6da549 Mon Sep 17 00:00:00 2001 From: heorhi-deriv Date: Sat, 16 Nov 2024 16:28:57 +0300 Subject: [PATCH] feat: improve coverall workflow --- .github/workflows/coveralls.yml | 32 +++++++++++++++---- package.json | 1 + packages/appstore/jest.config.js | 1 + .../cashier/__tests__/cashier.spec.tsx | 2 ++ packages/cfd/jest.config.js | 1 + packages/core/jest.config.js | 1 + 6 files changed, 31 insertions(+), 7 deletions(-) diff --git a/.github/workflows/coveralls.yml b/.github/workflows/coveralls.yml index 94139a4332b0..f91556963f85 100644 --- a/.github/workflows/coveralls.yml +++ b/.github/workflows/coveralls.yml @@ -4,11 +4,15 @@ on: - master pull_request: types: [opened, synchronize, edited] -name: Coveralls +name: Reporter jobs: - build: - name: Reporter + test: + name: Run tests in parallel runs-on: Runner_16cores_Deriv-app + strategy: + matrix: + shard: [1,2,3,4,5,6,7,8,9,10] + fail-fast: true steps: - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 @@ -16,9 +20,23 @@ jobs: uses: './.github/actions/setup_node' - name: Install dependencies uses: "./.github/actions/npm_install_from_cache" - - name: Build - uses: "./.github/actions/build" + - name: Build components package + working-directory: packages/components + run: npm run build - name: Test - run: JEST_MAX_WORKERS=95% npm run test:jest -- --collectCoverage - - name: Coveralls + run: JEST_MAX_WORKERS=95% SHARD_INDEX=${{ matrix.shard }} SHARD_COUNT=10 npm run test:shard -- --collectCoverage + - name: Coveralls Parallel uses: coverallsapp/github-action@3dfc5567390f6fa9267c0ee9c251e4c8c3f18949 + with: + flag-name: ${{ matrix.shard}} + parallel: true + + finish: + name: Coveralls Finished + needs: [test] + runs-on: Runner_16cores_Deriv-app + steps: + - name: Coveralls Finished + uses: coverallsapp/github-action@3dfc5567390f6fa9267c0ee9c251e4c8c3f18949 + with: + parallel-finished: true \ No newline at end of file diff --git a/package.json b/package.json index 8eaa8a30b715..7731dcca2fc2 100644 --- a/package.json +++ b/package.json @@ -96,6 +96,7 @@ "test": "f () { npm run test:stylelint && npm run test:eslint-all && npm run test:jest ;}; f", "test:stylelint": "stylelint \"./packages/*/src/**/*.s(a|c)ss\"", "test:ci": "f () { npm run test:stylelint && npm run test:eslint-all ;}; f", + "test:shard": "jest --all --shard=${SHARD_INDEX}/${SHARD_COUNT} --maxWorkers=${JEST_MAX_WORKERS:-'50%'} --coverage", "test:jest": "jest --all --maxWorkers=${JEST_MAX_WORKERS:-'50%'}", "test:performance": "cd e2e-tests && jest -c ./jest.config.js --detectOpenHandles performance", "stylelint:fix": "stylelint \"./packages/*/src/**/*.s(a|c)ss\" --fix", diff --git a/packages/appstore/jest.config.js b/packages/appstore/jest.config.js index 30f0e20d7639..50e9aefcc5e4 100644 --- a/packages/appstore/jest.config.js +++ b/packages/appstore/jest.config.js @@ -7,6 +7,7 @@ module.exports = { '\\.s(c|a)ss$': '/../../__mocks__/styleMock.js', '^.+\\.svg$': '/../../__mocks__/fileMock.js', '@deriv-com/translations': '/../../__mocks__/translation.mock.js', + '^@deriv/account$': '/../account/src', '@deriv-com/ui': '/../../__mocks__/deriv-com.ui.mock.js', '^Assets/(.*)$': '/src/assets/$1', '^Components/(.*)$': '/src/components/$1', diff --git a/packages/cashier/src/containers/cashier/__tests__/cashier.spec.tsx b/packages/cashier/src/containers/cashier/__tests__/cashier.spec.tsx index 082e88127758..cd059e4cfa5c 100644 --- a/packages/cashier/src/containers/cashier/__tests__/cashier.spec.tsx +++ b/packages/cashier/src/containers/cashier/__tests__/cashier.spec.tsx @@ -14,6 +14,8 @@ jest.mock('@deriv-com/ui', () => ({ useDevice: jest.fn(() => ({ isDesktop: true })), })); +jest.mock('@deriv/p2p', () => jest.fn(() =>
P2P
)); + jest.mock('@deriv/hooks', () => { return { ...jest.requireActual('@deriv/hooks'), diff --git a/packages/cfd/jest.config.js b/packages/cfd/jest.config.js index 5d82f30d188d..29129d24f455 100644 --- a/packages/cfd/jest.config.js +++ b/packages/cfd/jest.config.js @@ -7,6 +7,7 @@ module.exports = { '\\.s(c|a)ss$': '/../../__mocks__/styleMock.js', '^.+\\.svg$': '/../../__mocks__/styleMock.js', '@deriv-com/translations': '/../../__mocks__/translation.mock.js', + '^@deriv/account$': '/../account/src', '@deriv-com/ui': '/../../__mocks__/deriv-com.ui.mock.js', '^_common/(.*)$': '/src/_common/$1', '^App/(.*)$': '/src/App/$1', diff --git a/packages/core/jest.config.js b/packages/core/jest.config.js index c487bf44cac0..7290179e255a 100644 --- a/packages/core/jest.config.js +++ b/packages/core/jest.config.js @@ -7,6 +7,7 @@ module.exports = { '\\.s(c|a)ss$': '/../../__mocks__/styleMock.js', '^.+\\.svg$': '/../../__mocks__/styleMock.js', '@deriv-com/translations': '/../../__mocks__/translation.mock.js', + '^@deriv/account$': '/../account/src', '@deriv-com/ui': '/../../__mocks__/deriv-com.ui.mock.js', '^_common/(.*)$': '/src/_common/$1', '^App/(.*)$': '/src/App/$1',