Unverified Commit 534414d5 authored by OJ Kwon's avatar OJ Kwon Committed by GitHub

ci(workflow): enable test trace again (#50817)



### What?

Another attempt to https://github.com/vercel/next.js/pull/50619 and WEB-1150, trying to apply setup guard more throughly.

I still do not know why original PR passed CI but fails to subsequent PRs after merge, but hope this could be a right guard to prevent unexpected failures.
parent f4f34e42
...@@ -22,6 +22,8 @@ env: ...@@ -22,6 +22,8 @@ env:
# we build a dev binary for use in CI so skip downloading # we build a dev binary for use in CI so skip downloading
# canary next-swc binaries in the monorepo # canary next-swc binaries in the monorepo
NEXT_SKIP_NATIVE_POSTINSTALL: 1 NEXT_SKIP_NATIVE_POSTINSTALL: 1
DATADOG_API_KEY: ${{ secrets.DATA_DOG_API_KEY }}
DD_ENV: 'ci'
TEST_TIMINGS_TOKEN: ${{ secrets.TEST_TIMINGS_TOKEN }} TEST_TIMINGS_TOKEN: ${{ secrets.TEST_TIMINGS_TOKEN }}
NEXT_TEST_JOB: 1 NEXT_TEST_JOB: 1
......
...@@ -44,6 +44,8 @@ env: ...@@ -44,6 +44,8 @@ env:
# we build a dev binary for use in CI so skip downloading # we build a dev binary for use in CI so skip downloading
# canary next-swc binaries in the monorepo # canary next-swc binaries in the monorepo
NEXT_SKIP_NATIVE_POSTINSTALL: 1 NEXT_SKIP_NATIVE_POSTINSTALL: 1
DATADOG_API_KEY: ${{ secrets.DATA_DOG_API_KEY }}
DD_ENV: 'ci'
TEST_TIMINGS_TOKEN: ${{ secrets.TEST_TIMINGS_TOKEN }} TEST_TIMINGS_TOKEN: ${{ secrets.TEST_TIMINGS_TOKEN }}
NEXT_TEST_JOB: 1 NEXT_TEST_JOB: 1
......
...@@ -137,7 +137,7 @@ ...@@ -137,7 +137,7 @@
"critters": "0.0.6", "critters": "0.0.6",
"cross-env": "6.0.3", "cross-env": "6.0.3",
"cross-spawn": "6.0.5", "cross-spawn": "6.0.5",
"dd-trace": "2.3.0", "dd-trace": "4.1.0",
"es5-ext": "0.10.53", "es5-ext": "0.10.53",
"escape-string-regexp": "2.0.0", "escape-string-regexp": "2.0.0",
"eslint": "7.24.0", "eslint": "7.24.0",
......
This diff is collapsed.
...@@ -322,6 +322,33 @@ async function main() { ...@@ -322,6 +322,33 @@ async function main() {
const shouldRecordTestWithReplay = process.env.RECORD_REPLAY && isRetry const shouldRecordTestWithReplay = process.env.RECORD_REPLAY && isRetry
let shouldEnableTestTrace = false
let traceInitPath = null
try {
traceInitPath = require.resolve('dd-trace/ci/init')
// Enable trace only if tracer (dd-trace) can be resolved
shouldEnableTestTrace =
process.env.DATADOG_API_KEY && process.env.DATADOG_TRACE_NEXTJS_TEST
} catch (e) {
shouldEnableTestTrace = false
}
const traceEnv =
shouldEnableTestTrace && traceInitPath
? {
DD_API_KEY: process.env.DATADOG_API_KEY,
DD_CIVISIBILITY_AGENTLESS_ENABLED: 1,
DD_ENV: 'ci',
DD_SERVICE: 'nextjs',
NODE_OPTIONS: `-r ${traceInitPath}`,
}
: {}
if (shouldEnableTestTrace) {
console.log(`Running test with Datadog tracing enabled`)
}
const child = spawn( const child = spawn(
jestPath, jestPath,
[ [
...@@ -341,6 +368,7 @@ async function main() { ...@@ -341,6 +368,7 @@ async function main() {
stdio: ['ignore', 'pipe', 'pipe'], stdio: ['ignore', 'pipe', 'pipe'],
env: { env: {
...process.env, ...process.env,
...traceEnv,
RECORD_REPLAY: shouldRecordTestWithReplay, RECORD_REPLAY: shouldRecordTestWithReplay,
// run tests in headless mode by default // run tests in headless mode by default
HEADLESS: 'true', HEADLESS: 'true',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment