Browse Source

CI: only enable why-is-node-running in GHA debug logging mode

SukkaW 1 year ago
parent
commit
44e6c3f062
2 changed files with 10 additions and 3 deletions
  1. 5 1
      Build/index.ts
  2. 5 2
      Build/trace/index.ts

+ 5 - 1
Build/index.ts

@@ -30,6 +30,7 @@ import { createSpan, printTraceResult, whyIsNodeRunning } from './trace';
 import { buildDeprecateFiles } from './build-deprecate-files';
 import path from 'node:path';
 import { ROOT_DIR } from './constants/dir';
+import { isCI } from 'ci-info';
 
 process.on('uncaughtException', (error) => {
   console.error('Uncaught exception:', error);
@@ -69,7 +70,10 @@ const buildFinishedLock = path.join(ROOT_DIR, '.BUILD_FINISHED');
   }
 
   try {
-    await import('why-is-node-running');
+    // only enable why-is-node-running in GitHub Actions debug mode
+    if (isCI && process.env.RUNNER_DEBUG === '1') {
+      await import('why-is-node-running');
+    }
 
     const downloadPreviousBuildPromise = downloadPreviousBuild(rootSpan);
     const buildCommonPromise = downloadPreviousBuildPromise.then(() => buildCommon(rootSpan));

+ 5 - 2
Build/trace/index.ts

@@ -1,3 +1,4 @@
+import { isCI } from 'ci-info';
 import { noop } from 'foxts/noop';
 import { basename, extname } from 'node:path';
 import process from 'node:process';
@@ -134,8 +135,10 @@ export function task(importMetaMain: boolean, importMetaPath: string) {
 }
 
 export async function whyIsNodeRunning() {
-  const mod = await import('why-is-node-running');
-  return mod.default();
+  if (isCI && process.env.RUNNER_DEBUG === '1') {
+    const mod = await import('why-is-node-running');
+    return mod.default();
+  }
 }
 
 // const isSpan = (obj: any): obj is Span => {