GitHub Action: Publish test results to the CloudBees platform

2 minute read

Use this action to publish test results to the CloudBees platform if you are using a GitHub Actions (GHA) workflow. This action supports many popular testing tools, and enables testing results from running a GHA workflow to be displayed in the Test results tab of Run details and in the Test insights analytics dashboard.

This action is available on the GitHub marketplace.

Prerequisites

Set up the CloudBees platform and GHA to work together, providing key features of the platform to GHA workflows. Refer to Getting started for more information.

Inputs

Table 1. Input details
Input name Data type Required? Description

results-path

String

Yes

The pattern, file, or directory path of the test report to convert.

test-type

String

Yes

The name of the testing tool[1].

cloudbees-url

String

No

The CloudBees platform URL. The default value is "https://api.cloudbees.io".

[1] The testing tool name must be formatted correctly, in either all lowercase, or all uppercase.

Supported testing tools

Only the testing tools listed in the table below are supported for use in this action.

Use the given test-type input format to specify a testing tool.

Table 2. Supported testing tool names and test-type format

Supported tool name

Accepted test-type input formats

lowercase

UPPERCASE

GO

go

GO

Jest

jest

JEST

JUnit

junit

JUNIT

MSTest

mstest

MSTEST

Playwright

playwright

PLAYWRIGHT

ProdPerfect

prodperfect

PRODPERFECT

Selenium

selenium

SELENIUM

TestNG

testng

TESTNG

Tosca

tosca

TOSCA

This action uses GitHub OIDC authentication to securely communicate with the CloudBees platform. Be sure to set permissions to id-token: write in your workflow.

Usage examples

Basic example

The following is a basic example of using the v2 action:

permissions: id-token: write contents: read steps: - name: publish GHA run test results uses: cloudbees-io-gha/publish-test-results@v2 with: test-type: junit results-path: /example-dir/my-test-results

Full workflow and run example

The following GHA workflow example uses the v2 action to publish test results to the CloudBees platform.

Example GHA workflow YAML file
name: GHA Workflow on: workflow_dispatch: jobs: build: runs-on: ubuntu-latest permissions: id-token: write contents: read steps: - name: Compile code run: echo "Compiling..." - name: Produce binary run: sleep 10 - name: Push binary run: echo "Pushing binary to ECR..." - name: Register build artifacts in Cloudbees platform uses: cloudbees-io-gha/register-build-artifact@v3 id: go-action with: name: "GHA app" version: 1.0.0 url: "docker.io/example:latest" digest: "sha256:1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqr" type: "docker" cloudbees-url: "https://api.cloudbees.io" test: runs-on: ubuntu-latest needs: [build] # Depends on 'build' job steps: - name: Run tests run: echo "Running tests..." - name: Checkout to collect test results uses: actions/checkout@v3 - name: Publish test results in Cloudbees platform uses: cloudbees-io-gha/publish-test-results@v2 with: test-type: GO results-path: test_reports/* cloudbees-url: "https://api.cloudbees.io" deploy: runs-on: ubuntu-latest needs: [build,test] # Depends on 'build' and 'test' jobs steps: - name: Checkout to prepare manifest uses: actions/checkout@v3 - name: Trigger deployment run: echo "Invoking CBP deploy workflow..."

After the run has completed, the testing results are collected and displayed in the Test results tab of Run details and in the Test insights dashboard.

Test results
Figure 1. Example test results in Run details