GitHub Actions
Testmo comes with full GitHub Actions integration to submit test automation results from your CI pipelines to implement GitHub test management. This only requires a few lines of code and is easy to set up. Any test automation tool, framework and platform can be used.
Also works with GitHub Issues
You can also integrate Testmo with GitHub Issues to push, link and look up issues. Learn more about all GitHub integrations.
You can integrate simple GitHub Actions pipelines (such as running just a single test automation suite) as well as complex workflows with multiple test suites (e.g. frontend, backend, API etc.) and even parallel testing jobs with multiple threads.
Regardless of your specific configuration and workflow, the basic concept of integrating your GitHub Actions pipeline with Testmo is always the same:
  1. 1.
    You execute your automated tests as part of your GitHub Actions CI workflow. It doesn't matter if you run a single test suite, multiple test suites or even parallel testing jobs.
  2. 2.
    You configure your automated tests to generate a result file using the standard JUnit XML file format. This file format has become the de facto standard format to exchange test results between testing tools. So practically any test automation tool and framework either supports this format directly or can convert to this format.
  3. 3.
    You then use the Testmo CLI tool to easily submit the results to Testmo, enabling you to track your test suites over time, identify problematic test cases and improve testing performance.

Basic GitHub Actions & Testmo workflow

The following GitHub Actions workflow shows how to run a simple test automation run as part of your CI workflow and submit the test results to Testmo. In this example we are using a test suite with the Mocha/Chai (NodeJS/Javascript) testing framework. Remember that you can use any test automation tool and framework with Testmo and we are just using this framework for our example.
We are using the Testmo CLI tool here as it makes it very easy to run our tests and submit all results with a single command line call (using the automation:run:submit command).
We are also sending a few additional fields to Testmo here, such as a link back to the GitHub Actions workflow run as well as the Git commit hash. These details are then displayed in Testmo along with the test results, console output, exit code etc.
You can find the full code for this project on GitHub in the example project repository. You can also find a detailed explanation of this project along with more code samples and screenshots in our reference guide:
1
# .github/workflows/test.yml
2
name: Test
3
4
on: [push, workflow_dispatch]
5
6
jobs:
7
test:
8
name: Test
9
runs-on: ubuntu-latest
10
11
steps:
12
- uses: actions/[email protected]
13
- uses: actions/setup-[email protected]
14
with:
15
node-version: 16
16
cache: npm
17
- run: npm ci
18
- run: npm install --no-save @testmo/testmo-cli
19
20
# Optionally add a couple of fields such as the git hash and link to the build
21
- run: |
22
npx testmo automation:resources:add-field --name git --type string \
23
--value ${GITHUB_SHA:0:7} --resources resources.json
24
RUN_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
25
npx testmo automation:resources:add-link --name build \
26
--url $RUN_URL --resources resources.json
27
28
- run: |
29
npx testmo automation:run:submit \
30
--instance $TESTMO_URL \
31
--project-id 1 \
32
--name "Mocha test run" \
33
--source "unit-tests" \
34
--resources resources.json \
35
--results results/*.xml \
36
-- npm run mocha-junit # Note space after --
37
env:
38
TESTMO_URL: ${{ secrets.TESTMO_URL }}
39
TESTMO_TOKEN: ${{ secrets.TESTMO_TOKEN }}
Copied!

Advanced GitHub Actions workflows

We also support advanced GitHub Actions workflows. For example, you can submit test results for many test suites from a GitHub CI run and Testmo also fully supports parallel test runs.
  • Running multiple test suites in a build If you have multiple test suites for your project (such as frontend, backend, API, mobile tests etc.) you can simply submit these as separate test runs from the same GitHub Actions pipeline. You would just use multiple calls to automation:run:submit to submit each test suite separately. Important: if you have different test suites, you need to use different source names for the test runs in Testmo. This way Testmo can differentiate where the test results are coming from. Learn more about test automation sources.
  • Using parallel testing jobs with GitHub Actions Testmo also fully supports tracking test runs with multiple parallel test jobs. So if you have configured your GitHub Actions workflow to run multiple parallel jobs to speed up your test execution, you can also submit each job as a separate thread of the same run to Testmo. You can learn more about implementing this in the following example.

GitHub Actions parallel testing workflow

Testmo fully supports GitHub Actions workflows with parallel testing jobs, so you can submit the results as separate threads of the same run to Testmo. You can then see the results (and console output, exit codes & testing times) of each thread separately, as well as the overall results and statistics for the entire test run in Testmo. The following illustration shows how to implement the workflow with GitHub Actions.
Example parallel testing workflow
In this workflow we use separate jobs to set up our test run (test-setup), then submit a thread for each testing job of the run (test), and finally mark the test run as completed (test-complete).
We have a detailed guide with example code, screenshots and explanations on implementing this for GitHub ACtions. You can also find a complete example project repository on GitHub. You can find the full guide here:
1
# .github/workflows/build.yml
2
name: Build
3
4
on: [push, workflow_dispatch]
5
6
jobs:
7
build:
8
runs-on: ubuntu-latest
9
10
steps:
11
- run: echo "Building .."
12
13
test-setup:
14
needs: build
15
runs-on: ubuntu-latest
16
outputs:
17
testmo-run-id: ${{ steps.run-tests.outputs.testmo-run-id }}
18
19
steps:
20
- uses: actions/[email protected]
21
- uses: actions/setup-[email protected]
22
with:
23
node-version: 16
24
cache: npm
25
- run: npm ci
26
27
# Optionally add a couple of fields such as the git hash and link to the build
28
- run: |
29
npx testmo automation:resources:add-field --name git --type string \
30
--value ${GITHUB_SHA:0:7} --resources resources.json
31
RUN_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
32
npx testmo automation:resources:add-link --name build \
33
--url $RUN_URL --resources resources.json
34
35
- run: |
36
npx testmo automation:run:create \
37
--instance $TESTMO_URL \
38
--project-id 1 \
39
--name "Parallel mocha test run" \
40
--resources resources.json \
41
--source "unit-tests" > testmo-run-id.txt
42
ID=$(cat testmo-run-id.txt)
43
echo "::set-output name=testmo-run-id::$ID"
44
env:
45
TESTMO_URL: ${{ secrets.TESTMO_URL }}
46
TESTMO_TOKEN: ${{ secrets.TESTMO_TOKEN }}
47
id: run-tests
48
49
test:
50
needs: test-setup
51
runs-on: ubuntu-latest
52
53
strategy:
54
fail-fast: false
55
matrix:
56
ci_index: [0, 1, 2, 3]
57
ci_total: [4]
58
59
steps:
60
- uses: actions/[email protected]
61
- uses: actions/setup-[email protected]
62
with:
63
node-version: 16
64
cache: npm
65
- run: npm ci
66
- run: |
67
npx testmo automation:run:submit-thread \
68
--instance $TESTMO_URL \
69
--run-id ${{ needs.test-setup.outputs.testmo-run-id }} \
70
--results results/*.xml \
71
-- npm run mocha-junit-parallel # Note space after --
72
env:
73
CI_TOTAL: ${{ matrix.ci_total }}
74
CI_INDEX: ${{ matrix.ci_index }}
75
TESTMO_URL: ${{ secrets.TESTMO_URL }}
76
TESTMO_TOKEN: ${{ secrets.TESTMO_TOKEN }}
77
78
test-complete:
79
needs: [test-setup, test]
80
if: always()
81
runs-on: ubuntu-latest
82
83
steps:
84
- uses: actions/[email protected]
85
- uses: actions/setup-[email protected]
86
with:
87
node-version: 16
88
cache: npm
89
- run: npm ci
90
- run: |
91
npx testmo automation:run:complete \
92
--instance $TESTMO_URL \
93
--run-id ${{ needs.test-setup.outputs.testmo-run-id }} \
94
env:
95
TESTMO_URL: ${{ secrets.TESTMO_URL }}
96
TESTMO_TOKEN: ${{ secrets.TESTMO_TOKEN }}
97
98
deploy:
99
needs: [test, test-complete]
100
runs-on: ubuntu-latest
101
102
steps:
103
- run: echo "Deploying .."
Copied!

Important security considerations

When working with the Testmo API and CLI to submit test automation results to Testmo, you need to specify an API key for the authentication. You can learn more about generating API keys in Testmo here.
When integrating Testmo with your GitHub Actions workflows, it is important not to store the API key in your code repository. If you store the API key in your code repository, everyone with access to the repository would be able to access the key. You should never add and store your Testmo API key as part of your code repository.
Instead, use GitHub's encrypted secret feature to securely store keys and passwords. You can then make these secrets available as environment variables in your pipeline. You can see this in the example configuration above, as well as in our detailed GitHub Actions guide. You can also learn more about GitHub Actions secret management in the official documentation.
Last modified 17d ago