Test Optimization #18319
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test Optimization | |
| on: | |
| pull_request: | |
| push: | |
| branches: [master, mq-working-branch-master-*] | |
| schedule: | |
| - cron: 0 4 * * * | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/master' && github.run_id || github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| # TODO: remove this once we have stable tests | |
| MOCHA_OPTIONS: --retries 2 | |
| jobs: | |
| benchmarks-e2e: | |
| name: Performance and correctness tests | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| steps: | |
| - uses: DataDog/dd-octo-sts-action@96a25462dbcb10ebf0bfd6e2ccc917d2ab235b9a # v1.0.4 | |
| id: octo-sts | |
| with: | |
| scope: DataDog/test-environment | |
| policy: dd-trace-js | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| token: ${{ steps.octo-sts.outputs.token }} | |
| - uses: ./.github/actions/node/oldest-maintenance-lts | |
| - name: Test Optimization Performance Overhead Test | |
| run: yarn bench:e2e:test-optimization | |
| env: | |
| GITHUB_TOKEN: ${{ steps.octo-sts.outputs.token }} | |
| TEST_ENVIRONMENT_REF_TO_TEST: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} | |
| TEST_ENVIRONMENT_REF_NAME: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref_name }} | |
| integration: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| version: [oldest, maintenance, active, latest] | |
| name: ${{ github.workflow }} / integration (node-${{ matrix.version }}) | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - uses: ./.github/actions/node | |
| with: | |
| version: ${{ matrix.version }} | |
| - uses: ./.github/actions/install | |
| - name: Get Playwright version from versions package.json | |
| id: playwright-version | |
| run: | | |
| PLAYWRIGHT_VERSION=$(node -p "require('./packages/dd-trace/test/plugins/versions/package.json').dependencies['@playwright/test']") | |
| echo "version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT | |
| echo "Playwright version: $PLAYWRIGHT_VERSION" | |
| - name: Cache Playwright browsers | |
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | |
| with: | |
| path: ~/.cache/ms-playwright | |
| key: playwright-browsers-${{ runner.os }}-${{ steps.playwright-version.outputs.version }} | |
| - run: yarn test:integration:testopt:coverage | |
| - uses: ./.github/actions/coverage | |
| with: | |
| flags: test-optimization-testopt-${{ matrix.version }} | |
| playwright-image: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| playwright-version: [oldest, latest] | |
| name: Ensure Playwright Docker image (${{ matrix.playwright-version }}) | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| outputs: | |
| # Both matrix jobs set this to the same value, so the last-writer-wins | |
| # behaviour of matrix outputs is safe here. | |
| images: ${{ steps.versions.outputs.images }} | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - name: Determine versions | |
| id: versions | |
| run: | | |
| LATEST=$(node -p "require('./integration-tests/playwright/versions').latest") | |
| OLDEST=$(node -p "require('./integration-tests/playwright/versions').oldest") | |
| DOCKER_HASH=$(sha256sum .github/playwright/Dockerfile | cut -c1-8) | |
| LATEST_TAG="${LATEST}-${DOCKER_HASH}" | |
| OLDEST_TAG="${OLDEST}-${DOCKER_HASH}" | |
| BASE="ghcr.io/datadog/dd-trace-js/playwright-tools" | |
| IMAGES=$(printf '{"latest":"%s:%s","oldest":"%s:%s"}' "$BASE" "$LATEST_TAG" "$BASE" "$OLDEST_TAG") | |
| PW_VERSION=$([ "${{ matrix.playwright-version }}" = "latest" ] && echo "$LATEST" || echo "$OLDEST") | |
| IMAGE_TAG=$([ "${{ matrix.playwright-version }}" = "latest" ] && echo "$LATEST_TAG" || echo "$OLDEST_TAG") | |
| echo "images=$IMAGES" >> $GITHUB_OUTPUT | |
| echo "pw-version=$PW_VERSION" >> $GITHUB_OUTPUT | |
| echo "image-tag=$IMAGE_TAG" >> $GITHUB_OUTPUT | |
| - name: Log in to GHCR | |
| uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Ensure image | |
| env: | |
| PW_VERSION: ${{ steps.versions.outputs.pw-version }} | |
| IMAGE_TAG: ${{ steps.versions.outputs.image-tag }} | |
| run: | | |
| IMAGE="ghcr.io/datadog/dd-trace-js/playwright-tools:${IMAGE_TAG}" | |
| if docker manifest inspect "${IMAGE}" > /dev/null 2>&1; then | |
| echo "Image ${IMAGE} already exists, skipping build" | |
| else | |
| docker build --build-arg PLAYWRIGHT_VERSION="${PW_VERSION}" \ | |
| -t "${IMAGE}" .github/playwright | |
| docker push "${IMAGE}" | |
| fi | |
| integration-playwright: | |
| needs: playwright-image | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| node-version: [oldest, latest] | |
| playwright-version: [oldest, latest] | |
| spec: | |
| - playwright-reporting | |
| - playwright-efd | |
| - playwright-atr | |
| - playwright-test-management | |
| - playwright-active-test-span | |
| - playwright-impacted-tests | |
| - playwright-final-status | |
| name: integration-playwright (${{ matrix.playwright-version}}, node-${{ matrix.node-version }}, ${{ matrix.spec }}) | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| container: | |
| image: ${{ fromJson(needs.playwright-image.outputs.images)[matrix.playwright-version] }} | |
| credentials: | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| env: | |
| DD_SERVICE: dd-trace-js-integration-tests | |
| DD_CIVISIBILITY_AGENTLESS_ENABLED: 1 | |
| OPTIONS_OVERRIDE: 1 | |
| PLAYWRIGHT_VERSION: ${{ matrix.playwright-version }} | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - uses: ./.github/actions/dd-sts-api-key | |
| id: dd-sts | |
| continue-on-error: true | |
| - uses: ./.github/actions/node | |
| with: | |
| version: ${{ matrix.node-version }} | |
| - uses: ./.github/actions/install | |
| - name: Configure Git safe directory | |
| # The Playwright job runs in a container where the checkout can be owned by a different UID. | |
| # Git rejects metadata commands in that checkout unless the workspace is marked as safe. | |
| run: git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
| - run: yarn test:integration:playwright:coverage | |
| env: | |
| NODE_OPTIONS: "-r ./ci/init" | |
| DD_API_KEY: ${{ steps.dd-sts.outputs.api_key }} | |
| SPEC: ${{ matrix.spec }} | |
| - uses: ./.github/actions/coverage | |
| with: | |
| flags: test-optimization-playwright-${{ matrix.node-version }}-${{ matrix.playwright-version }}-${{ matrix.spec }} | |
| integration-mocha: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| version: [oldest, latest] | |
| # "oldest" is 5.2.0 in <=5 and 8.0.0 in >=6 | |
| mocha-version: [oldest, latest] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| env: | |
| DD_SERVICE: dd-trace-js-integration-tests | |
| DD_CIVISIBILITY_AGENTLESS_ENABLED: 1 | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - uses: ./.github/actions/dd-sts-api-key | |
| id: dd-sts | |
| continue-on-error: true | |
| - uses: ./.github/actions/node | |
| with: | |
| version: ${{ matrix.version }} | |
| - uses: ./.github/actions/install | |
| - run: yarn test:integration:mocha:coverage | |
| env: | |
| NODE_OPTIONS: "-r ./ci/init" | |
| MOCHA_VERSION: ${{ matrix.mocha-version }} | |
| DD_API_KEY: ${{ steps.dd-sts.outputs.api_key }} | |
| - uses: ./.github/actions/coverage | |
| with: | |
| flags: test-optimization-mocha-${{ matrix.version }}-${{ matrix.mocha-version }} | |
| integration-jest: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| version: [oldest, latest] | |
| # "oldest" is 24.8.0 in <=5 and 28.0.0 in >=6 | |
| jest-version: [oldest, latest] | |
| spec: | |
| - jest.core | |
| - jest.tia-efd | |
| - jest.test-management | |
| name: integration-jest (${{ matrix.jest-version }}, node-${{ matrix.version }}, ${{ matrix.spec }}) | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| env: | |
| DD_SERVICE: dd-trace-js-integration-tests | |
| DD_CIVISIBILITY_AGENTLESS_ENABLED: 1 | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - uses: ./.github/actions/dd-sts-api-key | |
| id: dd-sts | |
| continue-on-error: true | |
| - uses: ./.github/actions/node | |
| with: | |
| version: ${{ matrix.version }} | |
| - uses: ./.github/actions/install | |
| - run: yarn test:integration:jest:coverage | |
| env: | |
| NODE_OPTIONS: "-r ./ci/init" | |
| JEST_VERSION: ${{ matrix.jest-version }} | |
| SPEC: ${{ matrix.spec }} | |
| DD_API_KEY: ${{ steps.dd-sts.outputs.api_key }} | |
| - uses: ./.github/actions/coverage | |
| with: | |
| flags: test-optimization-jest-${{ matrix.version }}-${{ matrix.jest-version }} | |
| # Unit tests for `packages/datadog-plugin-jest`. The `integration-jest` matrix above only runs | |
| # `integration-tests/jest/*.spec.js`, so this is the only CI invocation whose glob expands to | |
| # cover `packages/datadog-plugin-jest/test/util.spec.js`. | |
| jest: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| env: | |
| PLUGINS: jest | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - uses: ./.github/actions/plugins/test | |
| integration-cucumber: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| version: [oldest, latest] | |
| cucumber-version: [7.0.0, latest] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| env: | |
| DD_SERVICE: dd-trace-js-integration-tests | |
| DD_CIVISIBILITY_AGENTLESS_ENABLED: 1 | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - uses: ./.github/actions/dd-sts-api-key | |
| id: dd-sts | |
| continue-on-error: true | |
| - uses: ./.github/actions/node | |
| with: | |
| version: ${{ matrix.version }} | |
| - uses: ./.github/actions/install | |
| - run: yarn test:integration:cucumber:coverage | |
| env: | |
| NODE_OPTIONS: "-r ./ci/init" | |
| CUCUMBER_VERSION: ${{ matrix.cucumber-version }} | |
| DD_API_KEY: ${{ steps.dd-sts.outputs.api_key }} | |
| - uses: ./.github/actions/coverage | |
| with: | |
| flags: test-optimization-cucumber-${{ matrix.version }}-${{ matrix.cucumber-version }} | |
| selenium-image: | |
| name: Ensure Selenium Docker image | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| outputs: | |
| image: ${{ steps.image.outputs.image }} | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - name: Determine image tag | |
| id: image | |
| run: | | |
| DOCKER_HASH=$(sha256sum .github/selenium/Dockerfile | cut -c1-8) | |
| IMAGE="ghcr.io/datadog/dd-trace-js/selenium-tools:${DOCKER_HASH}" | |
| echo "image=$IMAGE" >> $GITHUB_OUTPUT | |
| - name: Log in to GHCR | |
| uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Ensure image | |
| env: | |
| IMAGE: ${{ steps.image.outputs.image }} | |
| run: | | |
| if docker manifest inspect "${IMAGE}" > /dev/null 2>&1; then | |
| echo "Image ${IMAGE} already exists, skipping build" | |
| else | |
| docker build -t "${IMAGE}" .github/selenium | |
| docker push "${IMAGE}" | |
| fi | |
| integration-selenium: | |
| needs: selenium-image | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| version: [oldest, latest] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| container: | |
| image: ${{ needs.selenium-image.outputs.image }} | |
| credentials: | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| env: | |
| DD_SERVICE: dd-trace-js-integration-tests | |
| DD_CIVISIBILITY_AGENTLESS_ENABLED: 1 | |
| OPTIONS_OVERRIDE: 1 | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - uses: ./.github/actions/dd-sts-api-key | |
| id: dd-sts | |
| continue-on-error: true | |
| - uses: ./.github/actions/node | |
| with: | |
| version: ${{ matrix.version }} | |
| - uses: ./.github/actions/install | |
| - name: Configure Git safe directory | |
| # The Selenium job runs in a container where the checkout can be owned by a different UID. | |
| # Git rejects metadata commands in that checkout unless the workspace is marked as safe. | |
| run: git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
| - run: yarn test:integration:selenium:coverage | |
| env: | |
| NODE_OPTIONS: "-r ./ci/init" | |
| DD_API_KEY: ${{ steps.dd-sts.outputs.api_key }} | |
| - uses: ./.github/actions/coverage | |
| with: | |
| flags: test-optimization-selenium-${{ matrix.version }} | |
| integration-cypress: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| version: [eol, oldest, latest] | |
| # 6.7.0 is the minimum version we support in <=5 | |
| # 12.0.0 is the minimum version we support in >=6 | |
| # 14.5.4 is the latest version that supports Node 18 | |
| # The logic to decide whether the tests run lives in the individual spec files | |
| cypress-version: [6.7.0, 12.0.0, 14.5.4, latest] | |
| module-type: ["commonJS", "esm"] | |
| spec: | |
| - cypress-reporting | |
| - cypress-reporting-instrumentation | |
| - cypress-itr | |
| - cypress-tia-code-coverage | |
| - cypress-efd | |
| - cypress-atr | |
| - cypress-test-management | |
| - cypress-final-status-impacted-tests | |
| exclude: | |
| # 6.7.0 only runs on DD_MAJOR <= 5 with Node 16/commonJS. | |
| # On DD_MAJOR >= 6, shouldTestsRun() skips this remaining matrix entry. | |
| - cypress-version: 6.7.0 | |
| module-type: esm | |
| - version: oldest | |
| cypress-version: 6.7.0 | |
| - version: latest | |
| cypress-version: 6.7.0 | |
| # eol = Node 16 only runs Cypress 6.7.0 for DD_MAJOR <= 5 | |
| - version: eol | |
| cypress-version: 12.0.0 | |
| - version: eol | |
| cypress-version: 14.5.4 | |
| - version: eol | |
| cypress-version: latest | |
| # Node 18 (oldest) only supports 12.0.0 and 14.5.4, not latest | |
| - version: oldest | |
| cypress-version: latest | |
| name: integration-cypress (${{ matrix.cypress-version }}, node-${{ matrix.version }}, ${{ matrix.module-type }}, ${{ matrix.spec }}) | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| env: | |
| DD_SERVICE: dd-trace-js-integration-tests | |
| DD_CIVISIBILITY_AGENTLESS_ENABLED: 1 | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - uses: ./.github/actions/dd-sts-api-key | |
| id: dd-sts | |
| continue-on-error: true | |
| - uses: ./.github/actions/node | |
| with: | |
| version: ${{ matrix.version }} | |
| - uses: ./.github/actions/install | |
| - name: Resolve Cypress version | |
| id: cypress-version | |
| run: | | |
| if [ "${{ matrix.cypress-version }}" = "latest" ]; then | |
| RESOLVED=$(node -p "require('./packages/dd-trace/test/plugins/versions/package.json').dependencies.cypress") | |
| else | |
| RESOLVED="${{ matrix.cypress-version }}" | |
| fi | |
| echo "resolved=$RESOLVED" >> $GITHUB_OUTPUT | |
| - name: Cache Cypress binary | |
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | |
| with: | |
| path: ~/.cache/Cypress | |
| key: cypress-binary-${{ steps.cypress-version.outputs.resolved }} | |
| - run: yarn config set ignore-engines true | |
| - run: yarn test:integration:cypress:coverage --ignore-engines | |
| env: | |
| CYPRESS_VERSION: ${{ matrix.cypress-version }} | |
| NODE_OPTIONS: "-r ./ci/init" | |
| CYPRESS_MODULE_TYPE: ${{ matrix.module-type }} | |
| OPTIONS_OVERRIDE: 1 | |
| SPEC: ${{ matrix.spec }} | |
| DD_API_KEY: ${{ steps.dd-sts.outputs.api_key }} | |
| - uses: ./.github/actions/coverage | |
| with: | |
| flags: test-optimization-cypress-${{ matrix.version }}-${{ matrix.cypress-version }}-${{ matrix.module-type }} | |
| integration-vitest: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| version: [oldest, latest] | |
| spec: | |
| - vitest.core | |
| - vitest.test-management | |
| - vitest.advanced | |
| - vitest.msw | |
| - vitest.no-worker-init | |
| name: integration-vitest (node-${{ matrix.version }}, ${{ matrix.spec }}) | |
| env: | |
| DD_SERVICE: dd-trace-js-integration-tests | |
| DD_CIVISIBILITY_AGENTLESS_ENABLED: 1 | |
| OPTIONS_OVERRIDE: 1 | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - uses: ./.github/actions/dd-sts-api-key | |
| id: dd-sts | |
| continue-on-error: true | |
| - uses: ./.github/actions/node | |
| with: | |
| version: ${{ matrix.version }} | |
| - uses: ./.github/actions/install | |
| - run: yarn test:integration:vitest:coverage | |
| env: | |
| NODE_OPTIONS: "-r ./ci/init" | |
| SPEC: ${{ matrix.spec }} | |
| DD_API_KEY: ${{ steps.dd-sts.outputs.api_key }} | |
| - uses: ./.github/actions/coverage | |
| with: | |
| flags: test-optimization-vitest-${{ matrix.version }} |