From 7585204e0975ad8030edd26aad6460946400a664 Mon Sep 17 00:00:00 2001 From: Andrey Marchenko Date: Wed, 7 Oct 2026 14:39:10 +0200 Subject: [PATCH] QA: preserve first Datadog Mocha onboarding attempt --- .github/nyc-hook.js | 14 ++++++++++++++ .github/workflows/ci.yml | 33 ++++++++++++++++++++++++++++++++- .gitignore | 3 +++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 .github/nyc-hook.js diff --git a/.github/nyc-hook.js b/.github/nyc-hook.js new file mode 100644 index 00000000000..636b9350c93 --- /dev/null +++ b/.github/nyc-hook.js @@ -0,0 +1,14 @@ +'use strict' + +const NYC = require('nyc') + +const nyc = new NYC({ + cwd: process.cwd(), + tempDirectory: './.nyc_output', + exclude: ['examples/**', 'test/**', 'benchmarks/**'], + cache: false, + hookRequire: true, + instrument: true +}) + +nyc.wrap() diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e29004c274f..0db0a089a7f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -75,9 +75,40 @@ jobs: echo "Node.js version: $(node -v)" echo "NPM version: $(npm -v)" + - name: Install Datadog test runner + shell: bash + run: | + mkdir -p bin + if [ "$RUNNER_OS" = "Windows" ]; then + ddtest_bin=bin/ddtest.exe + ddtest_asset=ddtest-windows-amd64.exe + else + ddtest_bin=bin/ddtest + ddtest_asset=ddtest-linux-amd64 + fi + curl -fsSL "https://github.com/DataDog/ddtest/releases/latest/download/$ddtest_asset" -o "$ddtest_bin" + chmod +x "$ddtest_bin" + echo "DDTEST_BIN=$ddtest_bin" >> "$GITHUB_ENV" + + - name: Configure Datadog Test Optimization + uses: datadog/test-visibility-github-action@v3 + with: + languages: js + api_key: ${{ secrets.DD_API_KEY }} + site: datadoghq.com + js-tracer-version: 5.111.0 + - name: Run tests shell: bash - run: npm run test-ci + env: + NODE_OPTIONS: -r ${{ env.DD_TRACE_PACKAGE }} + DD_TRACE_DISABLED_PLUGINS: http,router + run: | + rm -rf .testoptimization + rm -rf .nyc_output + mkdir -p .nyc_output/processinfo + "$DDTEST_BIN" run --platform javascript --framework mocha --command "node_modules/.bin/mocha --require test/support/env --require .github/nyc-hook --reporter spec --check-leaks test/ test/acceptance/" --min-parallelism 1 --max-parallelism 4 + node_modules/.bin/nyc report --reporter=lcovonly --reporter=text - name: Upload code coverage uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 diff --git a/.gitignore b/.gitignore index 768368cd652..92c6a7ecdc9 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,9 @@ yarn.lock .nyc_output coverage +# Datadog Test Optimization +.testoptimization/ + # Benchmarking benchmarks/graphs