From faae8c777f7e9969aea61bde9ade07435b76b30b Mon Sep 17 00:00:00 2001 From: Heitor Tashiro Sergent Date: Fri, 10 Jan 2025 14:03:46 -0600 Subject: [PATCH 1/3] Add Use Chai with k6 testing guide (#1835) * Add Use Chai with k6 testing guide Import the Use Chai with k6 blog post to the docs * Skip example code blocks * Skip code block in k6chaijs index file * Apply to v0.56.x --- .../javascript-api/jslib/k6chaijs/_index.md | 8 +- .../next/testing-guides/use-chai-with-k6.md | 231 ++++++++++++++++++ .../javascript-api/jslib/k6chaijs/_index.md | 8 +- .../testing-guides/use-chai-with-k6.md | 231 ++++++++++++++++++ 4 files changed, 472 insertions(+), 6 deletions(-) create mode 100644 docs/sources/k6/next/testing-guides/use-chai-with-k6.md create mode 100644 docs/sources/k6/v0.56.x/testing-guides/use-chai-with-k6.md diff --git a/docs/sources/k6/next/javascript-api/jslib/k6chaijs/_index.md b/docs/sources/k6/next/javascript-api/jslib/k6chaijs/_index.md index 4cc30d8788..e6e05cf257 100644 --- a/docs/sources/k6/next/javascript-api/jslib/k6chaijs/_index.md +++ b/docs/sources/k6/next/javascript-api/jslib/k6chaijs/_index.md @@ -24,10 +24,12 @@ With this library, you get the following: ## Installation -This library is hosted on [jslib](https://jslib.k6.io/) and can be imported in directly in your k6 script. +This library is hosted on [jslib](https://jslib.k6.io/) and can be imported directly in your k6 script. + + ```javascript -import { describe, expect } from 'https://jslib.k6.io/k6chaijs/4.3.4.3/index.js'; +import { describe, expect } from 'https://jslib.k6.io/k6chaijs/4.5.0.1/index.js'; ``` Alternatively, you can use a copy of this file stored locally. The source code is available on [GitHub](https://github.com/grafana/k6-jslib-k6chaijs). @@ -80,4 +82,4 @@ It's possible to extend the default functionality with [Chai plugins](https://ww ## Read more -- [Using chai with k6](https://k6.io/blog/k6-chai-js/) +- [Use chai with k6](https://grafana.com/docs/k6//testing-guides/use-chai-with-k6/) diff --git a/docs/sources/k6/next/testing-guides/use-chai-with-k6.md b/docs/sources/k6/next/testing-guides/use-chai-with-k6.md new file mode 100644 index 0000000000..f5604e1834 --- /dev/null +++ b/docs/sources/k6/next/testing-guides/use-chai-with-k6.md @@ -0,0 +1,231 @@ +--- +title: 'Use Chai with k6' +description: 'Use Chai with k6 by using the k6chaijs library. Leverage BDD assertions to write tests that scale and are easier to maintain.' +weight: 100 +--- + +# Use Chai with k6 + +As a codebase grows, engineering teams might adopt frameworks or libraries that can help them write more readable and maintainable code. Similarly, as teams write new k6 test scripts, or expand existing tests, you might start looking for ways to keep them readable and organized, so that they're easier to update in the future. + +[Chai](https://www.chaijs.com/) is a BDD/TDD assertion library that's commonly used with testing frameworks. You can use Chai with k6 by using the k6chaijs library. With k6chaijs, you get: + +- BDD, or Behavior-Driven Development, style of assertions for more expressive language +- Chainable assertions +- More powerful assertions functions such as: `deep`, `nested`, `ordered`, etc. +- Automatic assertion messages +- [Exception handling](https://grafana.com/docs/k6//javascript-api/jslib/k6chaijs/error-handling) for better test stability + +You can use k6chaijs as an alternative to the [check](https://grafana.com/docs/k6//javascript-api/k6/check) and [group](https://grafana.com/docs/k6//javascript-api/k6/group) functions. + +## Installation + +The k6chaijs library is hosted on [jslib](https://jslib.k6.io/) and can be imported directly in your k6 script. + + + +```javascript +import { describe, expect } from 'https://jslib.k6.io/k6chaijs/4.5.0.1/index.js'; +``` + +Alternatively, you can use a copy of this file stored locally. The source code is available on [GitHub](https://github.com/grafana/k6-jslib-k6chaijs). + +## Benefits of k6chaijs + +Here are some of the ways you can use k6chaijs to write better tests. + +### Expressive language + +Using the `expect` and `describe` methods can make code easier to read and maintain. For example, writing a code snippet to check if a string length is equal to five can look like the following: + + + +```javascript +if ('Hello'.length !== 5) { + throw new Error(`Expected 'Hello' to have a length of 5 but got ${'Hello'.length}`); +} +``` + +With Chai, that can be rewritten as follows: + + + +```javascript +import { describe, expect } from 'https://jslib.k6.io/k6chaijs/4.5.0.1/index.js'; + +describe('should match expected length', () => { + expect('Hello').to.have.lengthOf(5); +}); +``` + +### Automatic messages + +Chai can also help make your code more concise by providing automatic error messages. For example, the following code triggers an error when executed: + + + +```javascript +import { describe, expect } from 'https://jslib.k6.io/k6chaijs/4.5.0.1/index.js'; + +describe('should match expected length', () => { + expect('Goodbye').to.have.lengthOf(6); +}); +``` + +And when you run that code, you automatically get an error message without writing any additional code that says: + + + +```javascript +// 🔥 AssertionError: expected 'Goodbye' to have a length of 6 but got 7 +``` + +### Structure tests + +Through encapsulation, your tests can define sections for your application. This makes it easier to: + +- Locate tests. +- Spot missing edge cases. +- Keep everything tidy. +- Provide a logical format for adding additional tests. + +For example, you can encapsulate your tests for two different services in your test script as the following: + + + +```javascript +import { describe } from 'https://jslib.k6.io/k6chaijs/4.5.0.1/index.js'; + +describe('service A', () => { + describe('should do x from service A', () => { + /*...*/ + }); + describe('should do y from service A', () => { + /*...*/ + }); +}); + +describe('service B', () => { + describe('should do x from service B', () => { + /*...*/ + }); + describe('should do y from service B', () => { + /*...*/ + }); +}); +``` + +### Assert API responses + +Assertion libraries are typically used to write mocked unit/integration tests, but you can also use it to test any API response. For example: + + + +```javascript +import expect from 'https://jslib.k6.io/k6chaijs/4.5.0.1/index.js'; +import http from 'k6/http'; + +const expected = { foo: 'Hello', bar: 'World' }; +const response = http.get('https://your.example.domain'); + +expect(response.body).to.deep.equal(expected); +``` + +### Error handling with `describe` + +The `check` function doesn't protect your tests against unsafe code. If a check fails, k6 throws an exception and restarts the script execution from the beginning. For example: + + + +```javascript +import { check } from 'k6'; +import http from 'k6/http'; + +export default function () { + const response = http.get('https://your.example.domain'); // 🙈 could return Error 503 + + check(response, { + 'got more than 5 items': (res) => { + // 🙉 `.json()` might be undefined + return res.json().length > 5; + }, + }); // 🙊 k6 will throw an exception and restarts execution from the beginning. + + // 💀 RIP + check(response, { + /*...*/ + }); +} +``` + +With k6chaijs, error handling is provided automatically. Script errors are caught by the describe block and execution can proceed to the next set of tests. For example: + + + +```javascript +import { describe, expect } from 'https://jslib.k6.io/k6chaijs/4.5.0.1/index.js'; +import http from 'k6/http'; + +export default function () { + // 😇 You are safe now + describe('got more than 5 items', () => { + const response = http.get('https://your.example.domain'); // 🙈 could return Error 503 + + // 🙉 `.json()` might be undefined + expect(response.json()).to.have.lengthOf(5); + }); + + describe('hooray I still get a turn!', () => { + /*...*/ + }); +} +``` + +## Example + +The following script incorporates thresholds with three test cases that use Chai: + +- One `describe` function creates sections and groups tests together. +- Another `describe` provides clear instructions on what we hope to achieve from each test. +- Chai's BDD-style `expect` function is used to write the tests in an expressive, readable way. + +```javascript +import { describe, expect } from 'https://jslib.k6.io/k6chaijs/4.5.0.1/index.js'; +import http from 'k6/http'; + +export default function () { + describe('crocodiles API', () => { + describe('should fetch a list of public crocodiles', () => { + const response = http.get('https://test-api.k6.io/public/crocodiles'); + + expect(response.status, 'response status').to.equal(200); + expect(response).to.have.validJsonBody(); + expect(response.json().length, 'number of crocs').to.be.above(4); + }); + + describe('should respond with status 200, when a valid user id is provided', () => { + const expected = { + id: 6, + name: 'Sang Buaya', + sex: 'F', + date_of_birth: '2006-01-28', + age: 16, + }; + + const response = http.get('https://test-api.k6.io/public/crocodiles/6'); + + expect(response.status, 'status').to.equal(200); + expect(JSON.parse(response.body), 'response body').to.deep.equal(expected); + }); + + describe('should respond with status 404, when an invalid user id is provided', () => { + const response = http.get('https://test-api.k6.io/public/crocodiles/9999999'); + + expect(response.status, 'status').to.equal(404); + expect(JSON.parse(response.body).detail, 'error message').to.equal('Not found.'); + }); + }); +} +``` + +k6 users will use the `group` function to perform this type of operation, however, for users of Javascript testing frameworks, `describe` is the familiar term. Under the hood, k6chaijs still calls `group`, but it's wrapped with a additional extra logic. The same is true for the `expect` function. That can help users who are already familiar with testing frameworks, and still provide the same output summaries you expect from the built-in k6 functions. diff --git a/docs/sources/k6/v0.56.x/javascript-api/jslib/k6chaijs/_index.md b/docs/sources/k6/v0.56.x/javascript-api/jslib/k6chaijs/_index.md index 4cc30d8788..e6e05cf257 100644 --- a/docs/sources/k6/v0.56.x/javascript-api/jslib/k6chaijs/_index.md +++ b/docs/sources/k6/v0.56.x/javascript-api/jslib/k6chaijs/_index.md @@ -24,10 +24,12 @@ With this library, you get the following: ## Installation -This library is hosted on [jslib](https://jslib.k6.io/) and can be imported in directly in your k6 script. +This library is hosted on [jslib](https://jslib.k6.io/) and can be imported directly in your k6 script. + + ```javascript -import { describe, expect } from 'https://jslib.k6.io/k6chaijs/4.3.4.3/index.js'; +import { describe, expect } from 'https://jslib.k6.io/k6chaijs/4.5.0.1/index.js'; ``` Alternatively, you can use a copy of this file stored locally. The source code is available on [GitHub](https://github.com/grafana/k6-jslib-k6chaijs). @@ -80,4 +82,4 @@ It's possible to extend the default functionality with [Chai plugins](https://ww ## Read more -- [Using chai with k6](https://k6.io/blog/k6-chai-js/) +- [Use chai with k6](https://grafana.com/docs/k6//testing-guides/use-chai-with-k6/) diff --git a/docs/sources/k6/v0.56.x/testing-guides/use-chai-with-k6.md b/docs/sources/k6/v0.56.x/testing-guides/use-chai-with-k6.md new file mode 100644 index 0000000000..f5604e1834 --- /dev/null +++ b/docs/sources/k6/v0.56.x/testing-guides/use-chai-with-k6.md @@ -0,0 +1,231 @@ +--- +title: 'Use Chai with k6' +description: 'Use Chai with k6 by using the k6chaijs library. Leverage BDD assertions to write tests that scale and are easier to maintain.' +weight: 100 +--- + +# Use Chai with k6 + +As a codebase grows, engineering teams might adopt frameworks or libraries that can help them write more readable and maintainable code. Similarly, as teams write new k6 test scripts, or expand existing tests, you might start looking for ways to keep them readable and organized, so that they're easier to update in the future. + +[Chai](https://www.chaijs.com/) is a BDD/TDD assertion library that's commonly used with testing frameworks. You can use Chai with k6 by using the k6chaijs library. With k6chaijs, you get: + +- BDD, or Behavior-Driven Development, style of assertions for more expressive language +- Chainable assertions +- More powerful assertions functions such as: `deep`, `nested`, `ordered`, etc. +- Automatic assertion messages +- [Exception handling](https://grafana.com/docs/k6//javascript-api/jslib/k6chaijs/error-handling) for better test stability + +You can use k6chaijs as an alternative to the [check](https://grafana.com/docs/k6//javascript-api/k6/check) and [group](https://grafana.com/docs/k6//javascript-api/k6/group) functions. + +## Installation + +The k6chaijs library is hosted on [jslib](https://jslib.k6.io/) and can be imported directly in your k6 script. + + + +```javascript +import { describe, expect } from 'https://jslib.k6.io/k6chaijs/4.5.0.1/index.js'; +``` + +Alternatively, you can use a copy of this file stored locally. The source code is available on [GitHub](https://github.com/grafana/k6-jslib-k6chaijs). + +## Benefits of k6chaijs + +Here are some of the ways you can use k6chaijs to write better tests. + +### Expressive language + +Using the `expect` and `describe` methods can make code easier to read and maintain. For example, writing a code snippet to check if a string length is equal to five can look like the following: + + + +```javascript +if ('Hello'.length !== 5) { + throw new Error(`Expected 'Hello' to have a length of 5 but got ${'Hello'.length}`); +} +``` + +With Chai, that can be rewritten as follows: + + + +```javascript +import { describe, expect } from 'https://jslib.k6.io/k6chaijs/4.5.0.1/index.js'; + +describe('should match expected length', () => { + expect('Hello').to.have.lengthOf(5); +}); +``` + +### Automatic messages + +Chai can also help make your code more concise by providing automatic error messages. For example, the following code triggers an error when executed: + + + +```javascript +import { describe, expect } from 'https://jslib.k6.io/k6chaijs/4.5.0.1/index.js'; + +describe('should match expected length', () => { + expect('Goodbye').to.have.lengthOf(6); +}); +``` + +And when you run that code, you automatically get an error message without writing any additional code that says: + + + +```javascript +// 🔥 AssertionError: expected 'Goodbye' to have a length of 6 but got 7 +``` + +### Structure tests + +Through encapsulation, your tests can define sections for your application. This makes it easier to: + +- Locate tests. +- Spot missing edge cases. +- Keep everything tidy. +- Provide a logical format for adding additional tests. + +For example, you can encapsulate your tests for two different services in your test script as the following: + + + +```javascript +import { describe } from 'https://jslib.k6.io/k6chaijs/4.5.0.1/index.js'; + +describe('service A', () => { + describe('should do x from service A', () => { + /*...*/ + }); + describe('should do y from service A', () => { + /*...*/ + }); +}); + +describe('service B', () => { + describe('should do x from service B', () => { + /*...*/ + }); + describe('should do y from service B', () => { + /*...*/ + }); +}); +``` + +### Assert API responses + +Assertion libraries are typically used to write mocked unit/integration tests, but you can also use it to test any API response. For example: + + + +```javascript +import expect from 'https://jslib.k6.io/k6chaijs/4.5.0.1/index.js'; +import http from 'k6/http'; + +const expected = { foo: 'Hello', bar: 'World' }; +const response = http.get('https://your.example.domain'); + +expect(response.body).to.deep.equal(expected); +``` + +### Error handling with `describe` + +The `check` function doesn't protect your tests against unsafe code. If a check fails, k6 throws an exception and restarts the script execution from the beginning. For example: + + + +```javascript +import { check } from 'k6'; +import http from 'k6/http'; + +export default function () { + const response = http.get('https://your.example.domain'); // 🙈 could return Error 503 + + check(response, { + 'got more than 5 items': (res) => { + // 🙉 `.json()` might be undefined + return res.json().length > 5; + }, + }); // 🙊 k6 will throw an exception and restarts execution from the beginning. + + // 💀 RIP + check(response, { + /*...*/ + }); +} +``` + +With k6chaijs, error handling is provided automatically. Script errors are caught by the describe block and execution can proceed to the next set of tests. For example: + + + +```javascript +import { describe, expect } from 'https://jslib.k6.io/k6chaijs/4.5.0.1/index.js'; +import http from 'k6/http'; + +export default function () { + // 😇 You are safe now + describe('got more than 5 items', () => { + const response = http.get('https://your.example.domain'); // 🙈 could return Error 503 + + // 🙉 `.json()` might be undefined + expect(response.json()).to.have.lengthOf(5); + }); + + describe('hooray I still get a turn!', () => { + /*...*/ + }); +} +``` + +## Example + +The following script incorporates thresholds with three test cases that use Chai: + +- One `describe` function creates sections and groups tests together. +- Another `describe` provides clear instructions on what we hope to achieve from each test. +- Chai's BDD-style `expect` function is used to write the tests in an expressive, readable way. + +```javascript +import { describe, expect } from 'https://jslib.k6.io/k6chaijs/4.5.0.1/index.js'; +import http from 'k6/http'; + +export default function () { + describe('crocodiles API', () => { + describe('should fetch a list of public crocodiles', () => { + const response = http.get('https://test-api.k6.io/public/crocodiles'); + + expect(response.status, 'response status').to.equal(200); + expect(response).to.have.validJsonBody(); + expect(response.json().length, 'number of crocs').to.be.above(4); + }); + + describe('should respond with status 200, when a valid user id is provided', () => { + const expected = { + id: 6, + name: 'Sang Buaya', + sex: 'F', + date_of_birth: '2006-01-28', + age: 16, + }; + + const response = http.get('https://test-api.k6.io/public/crocodiles/6'); + + expect(response.status, 'status').to.equal(200); + expect(JSON.parse(response.body), 'response body').to.deep.equal(expected); + }); + + describe('should respond with status 404, when an invalid user id is provided', () => { + const response = http.get('https://test-api.k6.io/public/crocodiles/9999999'); + + expect(response.status, 'status').to.equal(404); + expect(JSON.parse(response.body).detail, 'error message').to.equal('Not found.'); + }); + }); +} +``` + +k6 users will use the `group` function to perform this type of operation, however, for users of Javascript testing frameworks, `describe` is the familiar term. Under the hood, k6chaijs still calls `group`, but it's wrapped with a additional extra logic. The same is true for the `expect` function. That can help users who are already familiar with testing frameworks, and still provide the same output summaries you expect from the built-in k6 functions. From 4a1ce307010c5a2ce8ca02f6f106dfa52048a9e4 Mon Sep 17 00:00:00 2001 From: atilbian <99178555+atilbian@users.noreply.github.com> Date: Tue, 14 Jan 2025 21:49:10 +0000 Subject: [PATCH 2/3] Fixed docker command in get started doc (#1838) * Fixed docker command in get started doc * refactor: rewrite docker cmd to init k6 --- docs/sources/k6/next/get-started/running-k6.md | 2 +- docs/sources/k6/v0.48.x/get-started/running-k6.md | 2 +- docs/sources/k6/v0.49.x/get-started/running-k6.md | 2 +- docs/sources/k6/v0.50.x/get-started/running-k6.md | 2 +- docs/sources/k6/v0.51.x/get-started/running-k6.md | 2 +- docs/sources/k6/v0.52.x/get-started/running-k6.md | 2 +- docs/sources/k6/v0.53.x/get-started/running-k6.md | 2 +- docs/sources/k6/v0.54.x/get-started/running-k6.md | 2 +- docs/sources/k6/v0.55.x/get-started/running-k6.md | 2 +- docs/sources/k6/v0.56.x/get-started/running-k6.md | 2 +- .../translated-guides/en/01 Get started/03 Running k6.md | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/sources/k6/next/get-started/running-k6.md b/docs/sources/k6/next/get-started/running-k6.md index 719372a797..59dd258153 100644 --- a/docs/sources/k6/next/get-started/running-k6.md +++ b/docs/sources/k6/next/get-started/running-k6.md @@ -33,7 +33,7 @@ To run a simple local script: ``` ```docker - $ docker run --rm -i -v $PWD:/app -w /app grafana/k6 new + $ docker run --rm -u $(id -u) -v $PWD:/app -w /app grafana/k6 new ``` ```windows diff --git a/docs/sources/k6/v0.48.x/get-started/running-k6.md b/docs/sources/k6/v0.48.x/get-started/running-k6.md index 8a50e8fd32..ff0ea18813 100644 --- a/docs/sources/k6/v0.48.x/get-started/running-k6.md +++ b/docs/sources/k6/v0.48.x/get-started/running-k6.md @@ -29,7 +29,7 @@ To run a simple local script: ``` ```docker - $ docker run --rm -i -v $PWD:/app -w /app grafana/k6 new + $ docker run --rm -u $(id -u) -v $PWD:/app -w /app grafana/k6 new ``` ```windows diff --git a/docs/sources/k6/v0.49.x/get-started/running-k6.md b/docs/sources/k6/v0.49.x/get-started/running-k6.md index 8a50e8fd32..ff0ea18813 100644 --- a/docs/sources/k6/v0.49.x/get-started/running-k6.md +++ b/docs/sources/k6/v0.49.x/get-started/running-k6.md @@ -29,7 +29,7 @@ To run a simple local script: ``` ```docker - $ docker run --rm -i -v $PWD:/app -w /app grafana/k6 new + $ docker run --rm -u $(id -u) -v $PWD:/app -w /app grafana/k6 new ``` ```windows diff --git a/docs/sources/k6/v0.50.x/get-started/running-k6.md b/docs/sources/k6/v0.50.x/get-started/running-k6.md index f313f97fa4..8822bc1edd 100644 --- a/docs/sources/k6/v0.50.x/get-started/running-k6.md +++ b/docs/sources/k6/v0.50.x/get-started/running-k6.md @@ -33,7 +33,7 @@ To run a simple local script: ``` ```docker - $ docker run --rm -i -v $PWD:/app -w /app grafana/k6 new + $ docker run --rm -u $(id -u) -v $PWD:/app -w /app grafana/k6 new ``` ```windows diff --git a/docs/sources/k6/v0.51.x/get-started/running-k6.md b/docs/sources/k6/v0.51.x/get-started/running-k6.md index f313f97fa4..8822bc1edd 100644 --- a/docs/sources/k6/v0.51.x/get-started/running-k6.md +++ b/docs/sources/k6/v0.51.x/get-started/running-k6.md @@ -33,7 +33,7 @@ To run a simple local script: ``` ```docker - $ docker run --rm -i -v $PWD:/app -w /app grafana/k6 new + $ docker run --rm -u $(id -u) -v $PWD:/app -w /app grafana/k6 new ``` ```windows diff --git a/docs/sources/k6/v0.52.x/get-started/running-k6.md b/docs/sources/k6/v0.52.x/get-started/running-k6.md index f313f97fa4..8822bc1edd 100644 --- a/docs/sources/k6/v0.52.x/get-started/running-k6.md +++ b/docs/sources/k6/v0.52.x/get-started/running-k6.md @@ -33,7 +33,7 @@ To run a simple local script: ``` ```docker - $ docker run --rm -i -v $PWD:/app -w /app grafana/k6 new + $ docker run --rm -u $(id -u) -v $PWD:/app -w /app grafana/k6 new ``` ```windows diff --git a/docs/sources/k6/v0.53.x/get-started/running-k6.md b/docs/sources/k6/v0.53.x/get-started/running-k6.md index 719372a797..59dd258153 100644 --- a/docs/sources/k6/v0.53.x/get-started/running-k6.md +++ b/docs/sources/k6/v0.53.x/get-started/running-k6.md @@ -33,7 +33,7 @@ To run a simple local script: ``` ```docker - $ docker run --rm -i -v $PWD:/app -w /app grafana/k6 new + $ docker run --rm -u $(id -u) -v $PWD:/app -w /app grafana/k6 new ``` ```windows diff --git a/docs/sources/k6/v0.54.x/get-started/running-k6.md b/docs/sources/k6/v0.54.x/get-started/running-k6.md index 719372a797..59dd258153 100644 --- a/docs/sources/k6/v0.54.x/get-started/running-k6.md +++ b/docs/sources/k6/v0.54.x/get-started/running-k6.md @@ -33,7 +33,7 @@ To run a simple local script: ``` ```docker - $ docker run --rm -i -v $PWD:/app -w /app grafana/k6 new + $ docker run --rm -u $(id -u) -v $PWD:/app -w /app grafana/k6 new ``` ```windows diff --git a/docs/sources/k6/v0.55.x/get-started/running-k6.md b/docs/sources/k6/v0.55.x/get-started/running-k6.md index 719372a797..59dd258153 100644 --- a/docs/sources/k6/v0.55.x/get-started/running-k6.md +++ b/docs/sources/k6/v0.55.x/get-started/running-k6.md @@ -33,7 +33,7 @@ To run a simple local script: ``` ```docker - $ docker run --rm -i -v $PWD:/app -w /app grafana/k6 new + $ docker run --rm -u $(id -u) -v $PWD:/app -w /app grafana/k6 new ``` ```windows diff --git a/docs/sources/k6/v0.56.x/get-started/running-k6.md b/docs/sources/k6/v0.56.x/get-started/running-k6.md index 719372a797..59dd258153 100644 --- a/docs/sources/k6/v0.56.x/get-started/running-k6.md +++ b/docs/sources/k6/v0.56.x/get-started/running-k6.md @@ -33,7 +33,7 @@ To run a simple local script: ``` ```docker - $ docker run --rm -i -v $PWD:/app -w /app grafana/k6 new + $ docker run --rm -u $(id -u) -v $PWD:/app -w /app grafana/k6 new ``` ```windows diff --git a/src/data/markdown/translated-guides/en/01 Get started/03 Running k6.md b/src/data/markdown/translated-guides/en/01 Get started/03 Running k6.md index 6f85eef30a..50df6b44d6 100644 --- a/src/data/markdown/translated-guides/en/01 Get started/03 Running k6.md +++ b/src/data/markdown/translated-guides/en/01 Get started/03 Running k6.md @@ -26,7 +26,7 @@ To run a simple local script: ``` ```bash - $ docker run --rm -i -v $PWD:/app -w /app grafana/k6 new + $ docker run --rm -u $(id -u) -v $PWD:/app -w /app grafana/k6 new ``` ```bash From 78aeac201d4e4d90d8c477c232a1e56e2370b382 Mon Sep 17 00:00:00 2001 From: Jack Baldry Date: Tue, 14 Jan 2025 22:07:46 +0000 Subject: [PATCH 3/3] Add workflow that builds the website with both documentation sets (#1840) Signed-off-by: Jack Baldry --- .github/workflows/build-website.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/build-website.yml diff --git a/.github/workflows/build-website.yml b/.github/workflows/build-website.yml new file mode 100644 index 0000000000..77dc5dd7f3 --- /dev/null +++ b/.github/workflows/build-website.yml @@ -0,0 +1,29 @@ +name: build-website + +on: + push: + paths: + - "docs/sources/k6/**" + - "docs/sources/k6-studio/**" + - ".github/workflows/build-website.yml" + workflow_dispatch: + +jobs: + build-website: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + persist-credentials: false + + - name: Build website with k6 docs + uses: grafana/writers-toolkit/build-website@4b1248585248751e3b12fd020cf7ac91540ca09c # build-website/v1.0.1 + with: + source_directory: docs/sources/k6 + website_directory: content/docs/k6/next + + - name: Build website with k6 Studio docs + uses: grafana/writers-toolkit/build-website@4b1248585248751e3b12fd020cf7ac91540ca09c # build-website/v1.0.1 + with: + source_directory: docs/sources/k6-studio + website_directory: content/docs/k6-studio