Skip to content

Commit 76d74c9

Browse files
authored
Merge pull request #1 from dreamhaven/inspect-flags
Add inspect flags
2 parents 575942d + f95127c commit 76d74c9

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

action.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ inputs:
2222
flags:
2323
description: 'Additional flags to pass to k6 tests'
2424
required: false
25+
inspect-flags:
26+
description: 'Additional flags to pass to k6 inspection step'
27+
required: false
2528
cloud-run-locally:
2629
description: 'If true, run tests locally instead and upload results to Grafana Cloud k6'
2730
default: "true"

dist/index.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -34361,6 +34361,7 @@ async function run() {
3436134361
const parallel = core.getInput('parallel', { required: false }) === 'true';
3436234362
const failFast = core.getInput('fail-fast', { required: false }) === 'true';
3436334363
const flags = core.getInput('flags', { required: false });
34364+
const inspectFlags = core.getInput('inspect-flags', { required: false });
3436434365
const cloudRunLocally = core.getInput('cloud-run-locally', { required: false }) === 'true';
3436534366
const onlyVerifyScripts = core.getInput('only-verify-scripts', { required: false }) === 'true';
3436634367
const shouldCommentCloudTestRunUrlOnPR = core.getInput('cloud-comment-on-pr', { required: false }) === 'true';
@@ -34372,7 +34373,7 @@ async function run() {
3437234373
if (testPaths.length === 0) {
3437334374
throw new Error('No test files found');
3437434375
}
34375-
const verifiedTestPaths = await (0, k6helper_1.validateTestPaths)(testPaths);
34376+
const verifiedTestPaths = await (0, k6helper_1.validateTestPaths)(testPaths, inspectFlags ? inspectFlags.split(' ') : []);
3437634377
if (verifiedTestPaths.length === 0) {
3437734378
throw new Error('No valid test files found');
3437834379
}
@@ -34721,7 +34722,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
3472134722
exports.cleanScriptPath = exports.validateTestPaths = void 0;
3472234723
// Common helper functions used in the action
3472334724
const child_process_1 = __nccwpck_require__(2081);
34724-
async function validateTestPaths(testPaths) {
34725+
async function validateTestPaths(testPaths, flags) {
3472534726
/**
3472634727
* Validates the test paths by running `k6 inspect --execution-requirements` on each test file.
3472734728
* A test path is considered valid if the command returns an exit code of 0.
@@ -34734,7 +34735,7 @@ async function validateTestPaths(testPaths) {
3473434735
throw new Error('No test files found');
3473534736
}
3473634737
console.log(`🔍 Validating test run files.`);
34737-
const validK6TestPaths = [], command = "k6", defaultArgs = ["inspect", "--execution-requirements"];
34738+
const validK6TestPaths = [], command = "k6", defaultArgs = ["inspect", "--execution-requirements", ...flags];
3473834739
const allPromises = [];
3473934740
testPaths.forEach(async (testPath) => {
3474034741
const args = [...defaultArgs, testPath];

src/index.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export async function run(): Promise<void> {
2121
const parallel = core.getInput('parallel', { required: false }) === 'true'
2222
const failFast = core.getInput('fail-fast', { required: false }) === 'true'
2323
const flags = core.getInput('flags', { required: false })
24+
const inspectFlags = core.getInput('inspect-flags', { required: false })
2425
const cloudRunLocally = core.getInput('cloud-run-locally', { required: false }) === 'true'
2526
const onlyVerifyScripts = core.getInput('only-verify-scripts', { required: false }) === 'true'
2627
const shouldCommentCloudTestRunUrlOnPR = core.getInput('cloud-comment-on-pr', { required: false }) === 'true'
@@ -35,7 +36,11 @@ export async function run(): Promise<void> {
3536
throw new Error('No test files found')
3637
}
3738

38-
const verifiedTestPaths = await validateTestPaths(testPaths);
39+
40+
const verifiedTestPaths = await validateTestPaths(
41+
testPaths,
42+
inspectFlags ? inspectFlags.split(' ') : []
43+
);
3944

4045
if (verifiedTestPaths.length === 0) {
4146
throw new Error('No valid test files found')

src/k6helper.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Common helper functions used in the action
22
import { spawn } from 'child_process';
33

4-
export async function validateTestPaths(testPaths: string[]): Promise<string[]> {
4+
export async function validateTestPaths(testPaths: string[], flags: string[]): Promise<string[]> {
55
/**
66
* Validates the test paths by running `k6 inspect --execution-requirements` on each test file.
77
* A test path is considered valid if the command returns an exit code of 0.
@@ -19,7 +19,7 @@ export async function validateTestPaths(testPaths: string[]): Promise<string[]>
1919

2020
const validK6TestPaths: string[] = [],
2121
command = "k6",
22-
defaultArgs = ["inspect", "--execution-requirements"];
22+
defaultArgs = ["inspect", "--execution-requirements", ...flags];
2323

2424
const allPromises = [] as any[];
2525

0 commit comments

Comments
 (0)