From e220d786a434eac978bf01aed58f3428031a264a Mon Sep 17 00:00:00 2001 From: Andrey Marchenko Date: Wed, 30 Sep 2026 12:30:25 +0200 Subject: [PATCH 1/7] ci: reproduce DDTest action preload with Express Mocha --- .github/workflows/ddtest-action-preload.yml | 68 +++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/ddtest-action-preload.yml diff --git a/.github/workflows/ddtest-action-preload.yml b/.github/workflows/ddtest-action-preload.yml new file mode 100644 index 00000000000..aae0ae24068 --- /dev/null +++ b/.github/workflows/ddtest-action-preload.yml @@ -0,0 +1,68 @@ +name: DDTest action preload + +on: + pull_request: + workflow_dispatch: + +permissions: + contents: read + +jobs: + mocha: + if: github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == 'anmarchenko/express' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - uses: actions/setup-node@v4 + with: + node-version: '22' + - name: Install Express dependencies + run: npm install --include=dev + - uses: actions/checkout@v4 + with: + repository: DataDog/ddtest + ref: 77a23f4c8b7688defaaa8477ec298c523101c210 + path: ddtest-src + persist-credentials: false + - uses: actions/setup-go@v5 + with: + go-version-file: ddtest-src/go.mod + - name: Build DDTest from the reproduction PR + working-directory: ddtest-src + run: go build -o "$GITHUB_WORKSPACE/ddtest" . + - name: Remove the nested DDTest checkout + run: rm -rf ddtest-src + - name: Configure Datadog Test Optimization + uses: datadog/test-visibility-github-action@v3 + with: + languages: js + api_key: ${{ secrets.DD_API_KEY }} + service: express-ddtest-action + - name: Check the action preload is outside the project + shell: bash + run: | + test -n "$DD_TRACE_PACKAGE" + NODE_OPTIONS= node -e "require.resolve(process.env.DD_TRACE_PACKAGE)" + if NODE_OPTIONS= node -e "require.resolve('dd-trace/ci/init')" 2>/dev/null; then + echo 'dd-trace unexpectedly resolves from the Express project' + exit 1 + fi + - name: Run Mocha directly with the action preload + env: + NODE_OPTIONS: -r ${{ env.DD_TRACE_PACKAGE }} + run: ./node_modules/.bin/mocha --require test/support/env --reporter dot --check-leaks test/app.js + - name: Plan Mocha tests with DDTest + env: + NODE_OPTIONS: -r ${{ env.DD_TRACE_PACKAGE }} + run: | + ./ddtest plan --platform javascript --framework mocha \ + --min-parallelism 1 --max-parallelism 1 \ + --command "./node_modules/.bin/mocha --require test/support/env --reporter spec --check-leaks test/ test/acceptance/" + - name: Run planned Mocha tests with DDTest + env: + NODE_OPTIONS: -r ${{ env.DD_TRACE_PACKAGE }} + run: | + ./ddtest run --platform javascript --framework mocha --ci-node 0 \ + --command "./node_modules/.bin/mocha --require test/support/env --reporter spec --check-leaks test/ test/acceptance/" From 888b134d345e4dbad1d1f360640d6b2865d81d8d Mon Sep 17 00:00:00 2001 From: Andrey Marchenko Date: Wed, 30 Sep 2026 12:31:23 +0200 Subject: [PATCH 2/7] ci: explain missing Datadog secret in the fork --- .github/workflows/ddtest-action-preload.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/ddtest-action-preload.yml b/.github/workflows/ddtest-action-preload.yml index aae0ae24068..be6a8eb1076 100644 --- a/.github/workflows/ddtest-action-preload.yml +++ b/.github/workflows/ddtest-action-preload.yml @@ -34,6 +34,14 @@ jobs: run: go build -o "$GITHUB_WORKSPACE/ddtest" . - name: Remove the nested DDTest checkout run: rm -rf ddtest-src + - name: Require the Datadog API key + env: + DD_API_KEY: ${{ secrets.DD_API_KEY }} + run: | + if [ -z "$DD_API_KEY" ]; then + echo 'Add DD_API_KEY as an Actions repository secret in anmarchenko/express' + exit 1 + fi - name: Configure Datadog Test Optimization uses: datadog/test-visibility-github-action@v3 with: From 17b9d50ff733fbdf4be4f62abd1bddeecae0aad4 Mon Sep 17 00:00:00 2001 From: Andrey Marchenko Date: Wed, 30 Sep 2026 15:42:29 +0200 Subject: [PATCH 3/7] ci: verify ddtest platform refactor with action preloads --- .github/workflows/ddtest-action-preload.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ddtest-action-preload.yml b/.github/workflows/ddtest-action-preload.yml index be6a8eb1076..4c402b6a32d 100644 --- a/.github/workflows/ddtest-action-preload.yml +++ b/.github/workflows/ddtest-action-preload.yml @@ -11,6 +11,10 @@ jobs: mocha: if: github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == 'anmarchenko/express' runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + preload: [explicit, automatic] steps: - uses: actions/checkout@v4 with: @@ -23,15 +27,17 @@ jobs: - uses: actions/checkout@v4 with: repository: DataDog/ddtest - ref: 77a23f4c8b7688defaaa8477ec298c523101c210 + ref: 6be0856cd19f5e0e3831baec7bfcd34cccd73b6a # DataDog/ddtest#163: anmarchenko/framework-platform-link path: ddtest-src persist-credentials: false - uses: actions/setup-go@v5 with: go-version-file: ddtest-src/go.mod - - name: Build DDTest from the reproduction PR + - name: Build DDTest from the platform refactoring PR working-directory: ddtest-src - run: go build -o "$GITHUB_WORKSPACE/ddtest" . + run: | + git rev-parse HEAD + go build -o "$GITHUB_WORKSPACE/ddtest" . - name: Remove the nested DDTest checkout run: rm -rf ddtest-src - name: Require the Datadog API key @@ -63,14 +69,14 @@ jobs: run: ./node_modules/.bin/mocha --require test/support/env --reporter dot --check-leaks test/app.js - name: Plan Mocha tests with DDTest env: - NODE_OPTIONS: -r ${{ env.DD_TRACE_PACKAGE }} + NODE_OPTIONS: ${{ matrix.preload == 'explicit' && format('-r "{0}"', env.DD_TRACE_PACKAGE) || '' }} run: | ./ddtest plan --platform javascript --framework mocha \ --min-parallelism 1 --max-parallelism 1 \ --command "./node_modules/.bin/mocha --require test/support/env --reporter spec --check-leaks test/ test/acceptance/" - name: Run planned Mocha tests with DDTest env: - NODE_OPTIONS: -r ${{ env.DD_TRACE_PACKAGE }} + NODE_OPTIONS: ${{ matrix.preload == 'explicit' && format('-r "{0}"', env.DD_TRACE_PACKAGE) || '' }} run: | ./ddtest run --platform javascript --framework mocha --ci-node 0 \ --command "./node_modules/.bin/mocha --require test/support/env --reporter spec --check-leaks test/ test/acceptance/" From a6f9f307bcb6e0c9896b8e76b273f0a0352eea12 Mon Sep 17 00:00:00 2001 From: Andrey Marchenko Date: Wed, 30 Sep 2026 15:56:01 +0200 Subject: [PATCH 4/7] ci: verify corrected discovery prerequisites --- .github/workflows/ddtest-action-preload.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ddtest-action-preload.yml b/.github/workflows/ddtest-action-preload.yml index 4c402b6a32d..54611b92b77 100644 --- a/.github/workflows/ddtest-action-preload.yml +++ b/.github/workflows/ddtest-action-preload.yml @@ -27,7 +27,7 @@ jobs: - uses: actions/checkout@v4 with: repository: DataDog/ddtest - ref: 6be0856cd19f5e0e3831baec7bfcd34cccd73b6a # DataDog/ddtest#163: anmarchenko/framework-platform-link + ref: 0568f5af56718622e914176674ea1e88a73949ec # DataDog/ddtest#163: anmarchenko/framework-platform-link path: ddtest-src persist-credentials: false - uses: actions/setup-go@v5 From 3f1b2cc45ca6db9ec1d36b48f53946620ee7985a Mon Sep 17 00:00:00 2001 From: Andrey Marchenko Date: Wed, 30 Sep 2026 16:18:18 +0200 Subject: [PATCH 5/7] ci: isolate Express test tracing from router wrapping --- .github/workflows/ddtest-action-preload.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ddtest-action-preload.yml b/.github/workflows/ddtest-action-preload.yml index 54611b92b77..eb50876955c 100644 --- a/.github/workflows/ddtest-action-preload.yml +++ b/.github/workflows/ddtest-action-preload.yml @@ -11,6 +11,10 @@ jobs: mocha: if: github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == 'anmarchenko/express' runs-on: ubuntu-latest + env: + # Express asserts middleware next-function identity. dd-trace's router + # wrapping breaks those assertions; retain Mocha tracing for this test. + DD_TRACE_ROUTER_ENABLED: 'false' strategy: fail-fast: false matrix: @@ -66,7 +70,7 @@ jobs: - name: Run Mocha directly with the action preload env: NODE_OPTIONS: -r ${{ env.DD_TRACE_PACKAGE }} - run: ./node_modules/.bin/mocha --require test/support/env --reporter dot --check-leaks test/app.js + run: ./node_modules/.bin/mocha --require test/support/env --reporter dot --check-leaks test/ test/acceptance/ - name: Plan Mocha tests with DDTest env: NODE_OPTIONS: ${{ matrix.preload == 'explicit' && format('-r "{0}"', env.DD_TRACE_PACKAGE) || '' }} From c3f5964ed198fbfefaa0ef16f17bb35bc0613958 Mon Sep 17 00:00:00 2001 From: Andrey Marchenko Date: Wed, 30 Sep 2026 16:23:57 +0200 Subject: [PATCH 6/7] ci: define preload options in the matrix --- .github/workflows/ddtest-action-preload.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ddtest-action-preload.yml b/.github/workflows/ddtest-action-preload.yml index eb50876955c..1d382aec3ac 100644 --- a/.github/workflows/ddtest-action-preload.yml +++ b/.github/workflows/ddtest-action-preload.yml @@ -9,6 +9,7 @@ permissions: jobs: mocha: + name: mocha (${{ matrix.preload }}) if: github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == 'anmarchenko/express' runs-on: ubuntu-latest env: @@ -18,7 +19,11 @@ jobs: strategy: fail-fast: false matrix: - preload: [explicit, automatic] + include: + - preload: explicit + node-options: '-r "{0}"' + - preload: automatic + node-options: '' steps: - uses: actions/checkout@v4 with: @@ -73,14 +78,14 @@ jobs: run: ./node_modules/.bin/mocha --require test/support/env --reporter dot --check-leaks test/ test/acceptance/ - name: Plan Mocha tests with DDTest env: - NODE_OPTIONS: ${{ matrix.preload == 'explicit' && format('-r "{0}"', env.DD_TRACE_PACKAGE) || '' }} + NODE_OPTIONS: ${{ format(matrix.node-options, env.DD_TRACE_PACKAGE) }} run: | ./ddtest plan --platform javascript --framework mocha \ --min-parallelism 1 --max-parallelism 1 \ --command "./node_modules/.bin/mocha --require test/support/env --reporter spec --check-leaks test/ test/acceptance/" - name: Run planned Mocha tests with DDTest env: - NODE_OPTIONS: ${{ matrix.preload == 'explicit' && format('-r "{0}"', env.DD_TRACE_PACKAGE) || '' }} + NODE_OPTIONS: ${{ format(matrix.node-options, env.DD_TRACE_PACKAGE) }} run: | ./ddtest run --platform javascript --framework mocha --ci-node 0 \ --command "./node_modules/.bin/mocha --require test/support/env --reporter spec --check-leaks test/ test/acceptance/" From 67891fc4d92904797f8e572e808cbc839fe2b8ea Mon Sep 17 00:00:00 2001 From: Andrey Marchenko Date: Wed, 30 Sep 2026 16:26:54 +0200 Subject: [PATCH 7/7] ci: use latest ddtest prerelease with automatic tracer discovery --- .github/workflows/ddtest-action-preload.yml | 39 ++++++--------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/.github/workflows/ddtest-action-preload.yml b/.github/workflows/ddtest-action-preload.yml index 1d382aec3ac..3554300001f 100644 --- a/.github/workflows/ddtest-action-preload.yml +++ b/.github/workflows/ddtest-action-preload.yml @@ -9,21 +9,12 @@ permissions: jobs: mocha: - name: mocha (${{ matrix.preload }}) if: github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == 'anmarchenko/express' runs-on: ubuntu-latest env: # Express asserts middleware next-function identity. dd-trace's router # wrapping breaks those assertions; retain Mocha tracing for this test. DD_TRACE_ROUTER_ENABLED: 'false' - strategy: - fail-fast: false - matrix: - include: - - preload: explicit - node-options: '-r "{0}"' - - preload: automatic - node-options: '' steps: - uses: actions/checkout@v4 with: @@ -33,22 +24,18 @@ jobs: node-version: '22' - name: Install Express dependencies run: npm install --include=dev - - uses: actions/checkout@v4 - with: - repository: DataDog/ddtest - ref: 0568f5af56718622e914176674ea1e88a73949ec # DataDog/ddtest#163: anmarchenko/framework-platform-link - path: ddtest-src - persist-credentials: false - - uses: actions/setup-go@v5 - with: - go-version-file: ddtest-src/go.mod - - name: Build DDTest from the platform refactoring PR - working-directory: ddtest-src + - name: Install latest DDTest prerelease + shell: bash + env: + GH_TOKEN: ${{ github.token }} run: | - git rev-parse HEAD - go build -o "$GITHUB_WORKSPACE/ddtest" . - - name: Remove the nested DDTest checkout - run: rm -rf ddtest-src + download_url=$(gh api --paginate --slurp 'repos/DataDog/ddtest/releases?per_page=100' | \ + jq -er 'add | map(select(.prerelease and (.draft | not))) | max_by(.published_at) | .assets[] | select(.name == "ddtest-linux-amd64") | .browser_download_url') + test -n "$download_url" + echo "Installing $download_url" + curl --fail --location --retry 3 "$download_url" --output ddtest + chmod +x ddtest + ./ddtest --version - name: Require the Datadog API key env: DD_API_KEY: ${{ secrets.DD_API_KEY }} @@ -77,15 +64,11 @@ jobs: NODE_OPTIONS: -r ${{ env.DD_TRACE_PACKAGE }} run: ./node_modules/.bin/mocha --require test/support/env --reporter dot --check-leaks test/ test/acceptance/ - name: Plan Mocha tests with DDTest - env: - NODE_OPTIONS: ${{ format(matrix.node-options, env.DD_TRACE_PACKAGE) }} run: | ./ddtest plan --platform javascript --framework mocha \ --min-parallelism 1 --max-parallelism 1 \ --command "./node_modules/.bin/mocha --require test/support/env --reporter spec --check-leaks test/ test/acceptance/" - name: Run planned Mocha tests with DDTest - env: - NODE_OPTIONS: ${{ format(matrix.node-options, env.DD_TRACE_PACKAGE) }} run: | ./ddtest run --platform javascript --framework mocha --ci-node 0 \ --command "./node_modules/.bin/mocha --require test/support/env --reporter spec --check-leaks test/ test/acceptance/"