Skip to content

Commit e009732

Browse files
committed
Update variable name
1 parent 52e9158 commit e009732

File tree

6 files changed

+63
-63
lines changed

6 files changed

+63
-63
lines changed

.github/workflows/test.yaml

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,51 +7,51 @@ jobs:
77
runs-on: ubuntu-latest
88
env:
99
K6_CLOUD_TOKEN: ${{ secrets.K6_CLOUD_TOKEN }}
10-
K6_CLOUD_PROJECT_ID: ${{ secrets.K6_CLOUD_PROJECT_ID }}
10+
K6_CLOUD_PROJECT_ID: ${{ secrets.K6_CLOUD_PROJECT_ID }}
1111
steps:
12-
- uses: actions/checkout@v4
13-
- name: Setup Grafana k6
14-
uses: grafana/setup-k6-action@main
15-
- uses: ./
16-
continue-on-error: true
17-
with:
18-
path: |
19-
./dev/protocol*.js
20-
flags: --vus 10 --duration 30s
21-
parallel: true
22-
cloud-run-locally: false
12+
- uses: actions/checkout@v4
13+
- name: Setup Grafana k6
14+
uses: grafana/setup-k6-action@main
15+
- uses: ./
16+
continue-on-error: true
17+
with:
18+
path: |
19+
./dev/protocol*.js
20+
flags: --vus 10 --duration 30s
21+
parallel: true
22+
cloud-run-locally: false
2323
protocol-without-flags:
2424
runs-on: ubuntu-latest
2525
steps:
26-
- uses: actions/checkout@v4
27-
- name: Setup Grafana k6
28-
uses: grafana/setup-k6-action@main
29-
- uses: ./
30-
continue-on-error: true
31-
with:
32-
path: |
33-
./dev/protocol*.js
26+
- uses: actions/checkout@v4
27+
- name: Setup Grafana k6
28+
uses: grafana/setup-k6-action@main
29+
- uses: ./
30+
continue-on-error: true
31+
with:
32+
path: |
33+
./dev/protocol*.js
3434
show-complete-k6-output:
3535
runs-on: ubuntu-latest
3636
steps:
37-
- uses: actions/checkout@v4
38-
- name: Setup Grafana k6
39-
uses: grafana/setup-k6-action@main
40-
- uses: ./
41-
with:
42-
path: |
43-
./dev/protocol.js
44-
flags: --vus 10 --duration 30s
45-
show-k6-progress-output: true
37+
- uses: actions/checkout@v4
38+
- name: Setup Grafana k6
39+
uses: grafana/setup-k6-action@main
40+
- uses: ./
41+
with:
42+
path: |
43+
./dev/protocol.js
44+
flags: --vus 10 --duration 30s
45+
debug: true
4646
verify-scripts:
4747
runs-on: ubuntu-latest
4848
steps:
49-
- uses: actions/checkout@v4
50-
- name: Setup Grafana k6
51-
uses: grafana/setup-k6-action@main
52-
- uses: ./
53-
continue-on-error: true
54-
with:
55-
path: |
56-
./dev/verify-script-tests/**.js
57-
only-verify-scripts: true
49+
- uses: actions/checkout@v4
50+
- name: Setup Grafana k6
51+
uses: grafana/setup-k6-action@main
52+
- uses: ./
53+
continue-on-error: true
54+
with:
55+
path: |
56+
./dev/verify-script-tests/**.js
57+
only-verify-scripts: true

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ It is a wrapper over `k6 run`, with support for globs, parallel execution, fail-
2222

2323
The following inputs can be used as `step.with` key:
2424

25-
| Name | Type | Required | Default | Description |
26-
| ------------------------- | ------- | -------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
27-
| `path` | string | `true` | `''` | Glob pattern to select one or multiple test scripts to run. <br/> e.g. `./tests/api*.js` <br/> One can also supply multiple patterns by separating them with new line.<br/><code>path: \|<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;./tests/api*.js<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;./tests/app*.js</code> |
28-
| `cloud-run-locally` | boolean | `false` | `true` | If `true`, the tests are executed locally and the results are uploaded to Grafana Cloud k6 |
29-
| `parallel` | boolean | `false` | `false` | If `true` and multiple tests are executed, all them run in parallel. |
30-
| `fail-fast` | boolean | `false` | `false` | If `true`, the whole pipeline fails as soon as the first test fails |
31-
| `flags` | string | `false` | `''` | Additional flags to be passed on to the `k6 run` command.<br/>e.g. `--vus 10 --duration 20s` |
32-
| `cloud-comment-on-pr` | boolean | `false` | `true` | If `true`, the workflow comments a link to the cloud test run on the pull request (if present) |
33-
| `only-verify-scripts` | boolean | `false` | `false` | If `true`, only check if the test scripts are valid and skip the test execution |
34-
| `show-k6-progress-output` | boolean | `false` | `false` | If true, the output from k6 will be shown in the action logs, else only the summary will be shown. |
25+
| Name | Type | Required | Default | Description |
26+
| --------------------- | ------- | -------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
27+
| `path` | string | `true` | `''` | Glob pattern to select one or multiple test scripts to run. <br/> e.g. `./tests/api*.js` <br/> One can also supply multiple patterns by separating them with new line.<br/><code>path: \|<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;./tests/api*.js<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;./tests/app*.js</code> |
28+
| `cloud-run-locally` | boolean | `false` | `true` | If `true`, the tests are executed locally and the results are uploaded to Grafana Cloud k6 |
29+
| `parallel` | boolean | `false` | `false` | If `true` and multiple tests are executed, all them run in parallel. |
30+
| `fail-fast` | boolean | `false` | `false` | If `true`, the whole pipeline fails as soon as the first test fails |
31+
| `flags` | string | `false` | `''` | Additional flags to be passed on to the `k6 run` command.<br/>e.g. `--vus 10 --duration 20s` |
32+
| `cloud-comment-on-pr` | boolean | `false` | `true` | If `true`, the workflow comments a link to the cloud test run on the pull request (if present) |
33+
| `only-verify-scripts` | boolean | `false` | `false` | If `true`, only check if the test scripts are valid and skip the test execution |
34+
| `debug` | boolean | `false` | `false` | If true, the output from k6 will be shown in the action logs, else only the summary will be shown. |
3535
## Usage
3636

3737
Following are some examples of using the workflow.

action.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ inputs:
3434
description: 'If true, only check if the test scripts are valid and skip test execution'
3535
default: "false"
3636
required: false
37-
show-k6-progress-output:
37+
debug:
3838
description: 'If true, the output from k6 will be shown in the action logs, else only the summary will be shown'
3939
default: "false"
4040
required: false

dist/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34364,9 +34364,9 @@ async function run() {
3436434364
const cloudRunLocally = core.getInput('cloud-run-locally', { required: false }) === 'true';
3436534365
const onlyVerifyScripts = core.getInput('only-verify-scripts', { required: false }) === 'true';
3436634366
const shouldCommentCloudTestRunUrlOnPR = core.getInput('cloud-comment-on-pr', { required: false }) === 'true';
34367-
const showK6ProgressOutput = core.getInput('show-k6-progress-output', { required: false }) === 'true';
34367+
const debug = core.getInput('debug', { required: false }) === 'true';
3436834368
const allPromises = [];
34369-
core.debug(`Flag to show k6 progress output set to: ${showK6ProgressOutput}`);
34369+
core.debug(`Flag to show k6 progress output set to: ${debug}`);
3437034370
core.debug(`🔍 Found following ${testPaths.length} test run files:`);
3437134371
testPaths.forEach((testPath, index) => {
3437234372
core.debug(`${index + 1}. ${testPath}`);
@@ -34517,7 +34517,7 @@ async function run() {
3451734517
});
3451834518
// Parse k6 command output and extract test run URLs if running in cloud mode.
3451934519
// Also, print the output to the console, excluding the progress lines.
34520-
child.stdout?.on('data', (data) => (0, k6OutputParser_1.parseK6Output)(data, TEST_RESULT_URLS_MAP, TOTAL_TEST_RUNS, showK6ProgressOutput));
34520+
child.stdout?.on('data', (data) => (0, k6OutputParser_1.parseK6Output)(data, TEST_RESULT_URLS_MAP, TOTAL_TEST_RUNS, debug));
3452134521
return child;
3452234522
}
3452334523
}
@@ -34669,7 +34669,7 @@ function checkIfK6ASCIIArt(data) {
3466934669
return true;
3467034670
}
3467134671
}
34672-
function parseK6Output(data, testRunUrlsMap, totalTestRuns, showK6ProgressOutput) {
34672+
function parseK6Output(data, testRunUrlsMap, totalTestRuns, debug) {
3467334673
/*
3467434674
* This function is responsible for parsing the output of the k6 command.
3467534675
* It filters out the progress lines and logs the rest of the output.
@@ -34678,23 +34678,23 @@ function parseK6Output(data, testRunUrlsMap, totalTestRuns, showK6ProgressOutput
3467834678
* @param {Buffer} data - The k6 command output data
3467934679
* @param {TestRunUrlsMap | null} testRunUrlsMap - The map containing the script path and output URL. If null, the function will not extract test run URLs.
3468034680
* @param {number} totalTestRuns - The total number of test runs. This is used to determine when all test run URLs have been extracted.
34681-
* @param {boolean} showK6ProgressOutput - A flag to determine if the k6 progress output should be shown or not.
34681+
* @param {boolean} debug - A flag to determine if the k6 progress output should be shown or not.
3468234682
*
3468334683
* @returns {void}
3468434684
*/
3468534685
const dataString = data.toString(), lines = dataString.split('\n');
3468634686
// Extract test run URLs
3468734687
if (testRunUrlsMap && Object.keys(testRunUrlsMap).length < totalTestRuns) {
3468834688
const testRunUrlExtracted = extractTestRunUrl(dataString, testRunUrlsMap), k6ASCIIArt = checkIfK6ASCIIArt(dataString);
34689-
if ((testRunUrlExtracted || k6ASCIIArt) && !showK6ProgressOutput) {
34689+
if ((testRunUrlExtracted || k6ASCIIArt) && !debug) {
3469034690
/*
3469134691
If either the test run URL was extracted successfully or the k6 ASCII art was found,
3469234692
and the k6 progress output is not to be shown, then return.
3469334693
*/
3469434694
return;
3469534695
}
3469634696
}
34697-
if (showK6ProgressOutput) {
34697+
if (debug) {
3469834698
console.log(dataString);
3469934699
}
3470034700
else {

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ export async function run(): Promise<void> {
2424
const cloudRunLocally = core.getInput('cloud-run-locally', { required: false }) === 'true'
2525
const onlyVerifyScripts = core.getInput('only-verify-scripts', { required: false }) === 'true'
2626
const shouldCommentCloudTestRunUrlOnPR = core.getInput('cloud-comment-on-pr', { required: false }) === 'true'
27-
const showK6ProgressOutput = core.getInput('show-k6-progress-output', { required: false }) === 'true'
27+
const debug = core.getInput('debug', { required: false }) === 'true'
2828
const allPromises: Promise<void>[] = [];
2929

30-
core.debug(`Flag to show k6 progress output set to: ${showK6ProgressOutput}`);
30+
core.debug(`Flag to show k6 progress output set to: ${debug}`);
3131

3232
core.debug(`🔍 Found following ${testPaths.length} test run files:`);
3333
testPaths.forEach((testPath, index) => {
@@ -193,7 +193,7 @@ export async function run(): Promise<void> {
193193
});
194194
// Parse k6 command output and extract test run URLs if running in cloud mode.
195195
// Also, print the output to the console, excluding the progress lines.
196-
child.stdout?.on('data', (data) => parseK6Output(data, TEST_RESULT_URLS_MAP, TOTAL_TEST_RUNS, showK6ProgressOutput));
196+
child.stdout?.on('data', (data) => parseK6Output(data, TEST_RESULT_URLS_MAP, TOTAL_TEST_RUNS, debug));
197197

198198
return child;
199199
}

src/k6OutputParser.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function checkIfK6ASCIIArt(data: string): boolean {
110110
}
111111
}
112112

113-
export function parseK6Output(data: Buffer, testRunUrlsMap: TestRunUrlsMap | null, totalTestRuns: number, showK6ProgressOutput: boolean): void {
113+
export function parseK6Output(data: Buffer, testRunUrlsMap: TestRunUrlsMap | null, totalTestRuns: number, debug: boolean): void {
114114
/*
115115
* This function is responsible for parsing the output of the k6 command.
116116
* It filters out the progress lines and logs the rest of the output.
@@ -119,7 +119,7 @@ export function parseK6Output(data: Buffer, testRunUrlsMap: TestRunUrlsMap | nul
119119
* @param {Buffer} data - The k6 command output data
120120
* @param {TestRunUrlsMap | null} testRunUrlsMap - The map containing the script path and output URL. If null, the function will not extract test run URLs.
121121
* @param {number} totalTestRuns - The total number of test runs. This is used to determine when all test run URLs have been extracted.
122-
* @param {boolean} showK6ProgressOutput - A flag to determine if the k6 progress output should be shown or not.
122+
* @param {boolean} debug - A flag to determine if the k6 progress output should be shown or not.
123123
*
124124
* @returns {void}
125125
*/
@@ -132,7 +132,7 @@ export function parseK6Output(data: Buffer, testRunUrlsMap: TestRunUrlsMap | nul
132132
const testRunUrlExtracted = extractTestRunUrl(dataString, testRunUrlsMap),
133133
k6ASCIIArt = checkIfK6ASCIIArt(dataString);
134134

135-
if ((testRunUrlExtracted || k6ASCIIArt) && !showK6ProgressOutput) {
135+
if ((testRunUrlExtracted || k6ASCIIArt) && !debug) {
136136
/*
137137
If either the test run URL was extracted successfully or the k6 ASCII art was found,
138138
and the k6 progress output is not to be shown, then return.
@@ -141,7 +141,7 @@ export function parseK6Output(data: Buffer, testRunUrlsMap: TestRunUrlsMap | nul
141141
}
142142
}
143143

144-
if (showK6ProgressOutput) {
144+
if (debug) {
145145
console.log(dataString);
146146
} else {
147147
const filteredLines = lines.filter((line) => {

0 commit comments

Comments
 (0)