diff --git a/.github/workflows/build_and_test_workflow.yml b/.github/workflows/build_and_test_workflow.yml index 231b33e9de4..633640f6d16 100644 --- a/.github/workflows/build_and_test_workflow.yml +++ b/.github/workflows/build_and_test_workflow.yml @@ -29,11 +29,12 @@ env: jobs: build-lint-test: - name: Build and Verify on ${{ matrix.name }} + name: Build and Verify on ${{ matrix.name }} batch ${{ matrix.ci-batch }} strategy: fail-fast: false matrix: os: [ubuntu-latest, windows-latest] + ci-batch: [1, 2, 3] include: - os: ubuntu-latest name: Linux @@ -95,10 +96,12 @@ jobs: run: yarn osd bootstrap || yarn osd bootstrap - name: Run linter + if: matrix.ci-batch == 3 id: linter run: yarn lint - name: Validate NOTICE file + if: matrix.ci-batch == 3 id: notice-validate run: yarn notice:validate @@ -107,6 +110,7 @@ jobs: run: yarn test:jest:ci:coverage - name: Run mocha tests with coverage + if: matrix.ci-batch == 3 id: mocha-tests run: yarn test:mocha:coverage @@ -115,9 +119,10 @@ jobs: uses: codecov/codecov-action@v3 with: directory: ./target/opensearch-dashboards-coverage - flags: ${{ matrix.name }} + flags: ${{ matrix.name }} b${{ matrix.ci-batch }} - name: Run integration tests + if: matrix.ci-batch == 3 id: integration-tests run: yarn test:jest_integration:ci diff --git a/src/dev/jest/config.js b/src/dev/jest/config.js index c7e31c37f7e..61b8a144340 100644 --- a/src/dev/jest/config.js +++ b/src/dev/jest/config.js @@ -30,25 +30,56 @@ import { RESERVED_DIR_JEST_INTEGRATION_TESTS } from '../constants'; -export default { - rootDir: '../../..', - roots: [ - '/src/plugins', - '/src/legacy/ui', - '/src/core', - '/src/legacy/server', - '/src/cli', +const rootBatches = [ + [ + /* CI Batch 0 is left empty to make numbering natural */ + ], + [ + // CI Batch 1 + '/src/plugins', //800 + ], + [ + // CI Batch 2 + '/src/cli', //48 '/src/cli_keystore', '/src/cli_plugin', + '/src/legacy/ui', + '/src/core', //340 + '/src/legacy/server', //5 '/packages/osd-test/target/functional_test_runner', - '/src/dev', + '/src/dev', //7 '/src/optimize', '/src/legacy/utils', - '/src/setup_node_env', - '/packages', + ], + [ + // CI Batch 3 + '/src/setup_node_env', //150 + '/packages', //242 '/src/test_utils', '/test/functional/services/remote', ], +]; + +const roots = []; + +// Looks for --ci-batch= and captures the number +const ciBatchPattern = /^--ci-batch=(\d+)$/; +const ciBatches = process.argv.reduce((acc, arg) => { + const match = arg.match(ciBatchPattern); + if (isFinite(match?.[1])) acc.push(parseInt(match[1], 10)); + return acc; +}, []); + +if (ciBatches.length > 0) { + console.log(`Requested batch${ciBatches.length === 1 ? '' : 'es'}: ${ciBatches.join(', ')}`); + ciBatches.forEach((id) => roots.push(...rootBatches[id])); +} else { + roots.push(...rootBatches.flat()); +} + +export default { + rootDir: '../../..', + roots, moduleNameMapper: { '@elastic/eui$': '/node_modules/@elastic/eui/test-env', '@elastic/eui/lib/(.*)?': '/node_modules/@elastic/eui/test-env/$1',