Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add Run Tests from Github Actions Page #4021

Merged
merged 9 commits into from
Jun 12, 2023
143 changes: 143 additions & 0 deletions docs/docs/articles/run-tests-with-github-actions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# Run Tests with GitHub Actions

**Run on Testkube** is a GitHub Action for running tests on the Testkube platform.

Use it to run tests and test suites and obtain results directly in the GitHub's workflow.

## Usage
To use the action in your GitHub workflow, use kubeshop/testkube-run-action@v1 action. The configuration options are described in the Inputs section and may vary depending on the Testkube solution you are using (cloud or self-hosted) and your needs.
jfermi marked this conversation as resolved.
Show resolved Hide resolved

The most important options you will need are test and testSuite - you should pass a test or test suite name there.
jfermi marked this conversation as resolved.
Show resolved Hide resolved

### Testkube Cloud
To use this GitHub Action for the Testkube Cloud, you need to create an API token.

Then, pass the **organization** and **environment** IDs for the test, along with the **token** and other parameters specific for your use case:

```sh
jfermi marked this conversation as resolved.
Show resolved Hide resolved
uses: kubeshop/testkube-run-action@v1
with:
# Instance
organization: tkcorg_0123456789abcdef
environment: tkcenv_fedcba9876543210
token: tkcapi_0123456789abcdef0123456789abcd
# Options
test: some-test-id-to-run
```

It will probably be unsafe to keep this directly in the workflow's YAML configuration, so you may want to use [GitHub's secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets) instead.

```sh
uses: kubeshop/testkube-run-action@v1
with:
# Instance
organization: ${{ secrets.TkOrganization }}
environment: ${{ secrets.TkEnvironment }}
token: ${{ secrets.TkToken }}
# Options
test: some-test-id-to-run
```

### Self-hosted Instance


To run the test on self-hosted instance, simply pass url that points to the API, i.e.:
jfermi marked this conversation as resolved.
Show resolved Hide resolved

```sh
uses: kubeshop/testkube-run-action@v1
with:
# Instance
url: https://demo.testkube.io/results/v1
# Options
test: some-test-id-to-run
```

### Examples

Run a test on a self-hosted instance:
```sh
uses: kubeshop/testkube-run-action@v1
with:
url: https://demo.testkube.io/results/v1
test: container-executor-curl-smoke
```
Run a test suite on a self-hosted instance:
```sh
uses: kubeshop/testkube-run-action@v1
with:
url: https://demo.testkube.io/results/v1
testSuite: executor-soapui-smoke-tests
```
Run tests from a local repository for the PR:
```sh
uses: kubeshop/testkube-run-action@v1
with:
organization: ${{ secrets.TkOrganization }}
environment: ${{ secrets.TkEnvironment }}
token: ${{ secrets.TkToken }}
test: e2e-dashboard-tests
ref: ${{ github.head_ref }}
```

Run tests with custom environment variables:

```sh
uses: kubeshop/testkube-run-action@v1
with:
organization: ${{ secrets.TkOrganization }}
environment: ${{ secrets.TkEnvironment }}
token: ${{ secrets.TkToken }}
test: e2e-dashboard-tests
variables: |
URL="https://some.domain.com"
EXECUTED_FROM="${{ github.head_ref }}"
secretVariables: |
SOME_SECRET_ENV="abc"
OTHER_ENV="${{ secrets.ExternalToken }}"
```

## Inputs
There are different inputs available for tests and test suites, as well as for Cloud and your own instance.

### Test

Required Name Description
jfermi marked this conversation as resolved.
Show resolved Hide resolved
✓ test Test name in the Testkube environment
✗ ref Override Git reference (branch, commit, tag) for the test
✗ preRunScript Override pre-run script for the test
✗ variables Basic variables in the dotenv format
✗ secretVariables Secret variables in the dotenv format
✗ executionName Override execution name, so you may i.e. mention the PR
✗ namespace Set namespace to run test in

### Test Suite

```sh
| Required | Name | Description
jfermi marked this conversation as resolved.
Show resolved Hide resolved
+----------+-----------------+---------------------------------------------------------
| ✓ | testSuite | Test suite name in the Testkube environment.
| ✗ | variables | Basic variables in the dotenv format.
| ✗ | secretVariables | Variables Secret variables in the dotenv format.
| ✗ | executionName | Override execution name, so you may i.e. mention the PR.
| ✗ | namespace | Set namespace to run test suite in.
```

### Cloud and Enterprise

```sh
| Required | Name | Description
+----------+--------------+------------------------------------------------------------------------------------------------------------------------------
| ✓ | organization | The organization ID from Testkube Cloud or Enterprise - it starts with tkc_org, you may find it i.e. in the dashboard's URL.
| ✓ | environment | The environment ID from Testkube Cloud or Enterprise - it starts with tkc_env, you may find it i.e. in the dashboard's URL.
| ✓ | token | API token that has at least a permission to run specific test or test suite. Read more about creating API token in Testkube Cloud or Enterprise.
| ✗ | url | URL of the Testkube Enterprise instance, if applicable.
```

### Own Instance

```sh
| Required | Name | Description
+----------+--------------+-------------------------------------------------------------------
| ✓ | url | URL for the API of the own Testkube instance.
| ✗ | ws | Override WebSocket API URL of the own Testkube instance (use it only if auto-detection doesn't work).
jfermi marked this conversation as resolved.
Show resolved Hide resolved
```
1 change: 1 addition & 0 deletions docs/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const sidebars = {
},
items: [
"articles/github-actions",
"articles/run-tests-with-github-actions",
{
type: "category",
label: "GitOps",
Expand Down