diff --git a/.github/workflows/build_and_test_workflow.yml b/.github/workflows/build_and_test_workflow.yml index 231b33e9de43..56fff84d57b5 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.group }} strategy: fail-fast: false matrix: os: [ubuntu-latest, windows-latest] + group: [1, 2] include: - os: ubuntu-latest name: Linux @@ -95,18 +96,21 @@ jobs: run: yarn osd bootstrap || yarn osd bootstrap - name: Run linter + if: matrix.group == 2 && matrix.os == 'ubuntu-latest' id: linter run: yarn lint - name: Validate NOTICE file + if: matrix.group == 2 && matrix.os == 'ubuntu-latest' id: notice-validate run: yarn notice:validate - - name: Run unit tests with coverage + - name: Run unit tests group ${{ matrix.group }} with coverage id: unit-tests - run: yarn test:jest:ci:coverage + run: yarn test:jest:ci:coverage --ci-group=${{ matrix.group }} - name: Run mocha tests with coverage + if: matrix.group == 2 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 }} ciGroup$${{ matrix.group }} - name: Run integration tests + if: matrix.group == 2 id: integration-tests run: yarn test:jest_integration:ci diff --git a/src/dev/jest/config.js b/src/dev/jest/config.js index c7e31c37f7e2..431063e72313 100644 --- a/src/dev/jest/config.js +++ b/src/dev/jest/config.js @@ -30,16 +30,22 @@ import { RESERVED_DIR_JEST_INTEGRATION_TESTS } from '../constants'; -export default { - rootDir: '../../..', - roots: [ +const rootGroups = [ + [ + /* CI Group 0 is left empty to make numbering natural */ + ], + [ + // CI Group 1 '/src/plugins', - '/src/legacy/ui', - '/src/core', - '/src/legacy/server', + ], + [ + // CI Group 2 '/src/cli', '/src/cli_keystore', '/src/cli_plugin', + '/src/legacy/ui', + '/src/core', + '/src/legacy/server', '/packages/osd-test/target/functional_test_runner', '/src/dev', '/src/optimize', @@ -49,6 +55,30 @@ export default { '/src/test_utils', '/test/functional/services/remote', ], +]; + +const roots = []; + +// Looks for --ci-group= and captures the number +const ciGroupPattern = /^--ci-group=(\d+)$/; +const ciGroup = process.argv.reduce((acc, arg) => { + const match = arg.match(ciGroupPattern); + if (isFinite(match?.[1])) acc.push(parseInt(match[1], 10)); + return acc; +}, []); + +if (ciGroup.length > 0) { + console.log(`Requested group${ciGroup.length === 1 ? '' : 's'}: ${ciGroup.join(', ')}`); + ciGroup.forEach((id) => { + if (Array.isArray(rootGroups[id])) roots.push(...rootGroups[id]); + }); +} else { + roots.push(...rootGroups.flat()); +} + +export default { + rootDir: '../../..', + roots, moduleNameMapper: { '@elastic/eui$': '/node_modules/@elastic/eui/test-env', '@elastic/eui/lib/(.*)?': '/node_modules/@elastic/eui/test-env/$1',