Skip to content
This repository was archived by the owner on Jul 23, 2025. It is now read-only.

Commit bdb1c69

Browse files
authored
feat(core): print additional debugging information about platform & CPU arch
1 parent 8fcc0aa commit bdb1c69

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/main.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type { ExecOptions } from '@actions/exec/lib/interfaces.js';
88
import { context } from '@actions/github';
99
import * as glob from '@actions/glob';
1010
import {
11+
amICurrentlyBeingTestedByTap,
1112
downloadToFile,
1213
getOptionalString,
1314
getSupportedEnvironmentInfo,
@@ -213,6 +214,12 @@ export async function run({
213214
verifyEnvironment = DEFAULT_VERIFY_ENVIRONMENT,
214215
batchSize,
215216
}: ActionArguments = {}): Promise<void> {
217+
/* c8 ignore start */
218+
if (!amICurrentlyBeingTestedByTap) {
219+
debug(`ℹ️ Environment data: ${JSON.stringify(CURRENT_ENVIRONMENT)}`);
220+
}
221+
/* c8 ignore stop */
222+
216223
let lastExitCode = 1;
217224
if (verifyEnvironment === 'true') {
218225
debug('ℹ️ Verifying environment...');

src/utils.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { createHash, timingSafeEqual } from 'node:crypto';
22
import { createWriteStream, readFile } from 'node:fs';
3-
import { platform } from 'node:os';
3+
import { platform, arch as nodeArch } from 'node:os';
4+
import { platform as nodePlatform, release, config } from 'node:process';
45
import { promisify } from 'node:util';
56
import { getInput } from '@actions/core';
67
import arch from 'arch';
@@ -274,13 +275,31 @@ export function getSupportedEnvironmentInfo() {
274275
};
275276

276277
return {
278+
/** Returns `true` if the CodeClimate test reporter is actually supported on this environment. */
277279
supported: !UNSUPPORTED_ENVIRONMENTS.some((e) => {
278280
return (
279281
e.architecture === currentEnvironment.architecture &&
280282
e.platform === currentEnvironment.platform
281283
);
282284
}),
285+
/** The platform that the action is running on. */
283286
platform: currentEnvironment.platform,
287+
/** The CPU architecture that the action is running on. */
284288
architecture: currentEnvironment.architecture,
289+
/** The platform that the current Node.js binary was compiled for. */
290+
nodePlatform: nodePlatform,
291+
/** The CPU architecture that the current Node.js binary was compiled for. */
292+
nodeArchitecture: nodeArch,
293+
/** The CPU architecture of the host machine that compiled the current Node.js binary. */
294+
nodeHostArchitecture: config.variables.host_arch,
295+
nodeRelease: release,
285296
};
286297
}
298+
299+
/**
300+
* Detects if the logic is being currently executed inside a `tap` test.
301+
*/
302+
export function amICurrentlyBeingTestedByTap() {
303+
// REFER: https://node-tap.org/environment/#environment-variables-used-by-tap
304+
return Object.prototype.hasOwnProperty.call(process.env, 'TAP_CHILD_ID');
305+
}

0 commit comments

Comments
 (0)