Test results upload from GitHub
GitHub upload workflow uses allurectl. to upload the test results.
Authenticate GitHub build jobs
Authentication token
For a user on Allure TestOps side you need to create API token.
This API token will be used by GitHub to authenticate on Allure TestOps server.
- Log in to Allure TestOps with account you are going to use to upload test results.
- Go to user's profile.
- In the section API tokens click a green button that says Create.
- Name your API token and click Submit. Always give meaningful names to all the configuration parameters.
Allure will randomly generate the token and show you in modal window.
- Copy the token and save it in a safe place as it cannot be retrieved by Allure TestOps means.
Authenticate your workflows in Allure TestOps server
Add your Allure server instance information to GitHub configuration.
Navigate to the Settings of your repository.
Navigate to Secrets section.
Create 3 variables in Repository secrets as shown below:
ALLURE_ENDPOINT
- Allure TestOps URL (for example: http://allure.company.com).ALLURE_TOKEN
- Allure TestOps token you generated recently.ALLURE_PROJECT_ID
- Allure TestOps project ID to which you are going to upload the results of your tests.
4. These secrets will be used then in your workflows to define environment variables.
Configure GitLab workflow
Here is an example of GitHub workflow you can use with Allure TestOps and allurectl
.
We've defined inputs that can be changed by an end user prior to running the workflow, these input then will be used as environment variables to provide various data like browser name or URL which tests will use as a target.
All the variables starting with ALLURE
are needed to run allurectl
properly.
name: Name your workflow
on:
push:
workflow_dispatch:
inputs:
TEST_ENDPOINT: #this is used as ENV variable to provide host to run tests for
description: "Endpoint for tests"
required: true
default: https://dev.github.com
TEST_BROWSER: #this is used as ENV variable to browser to run tests with
description: "Browser for tests"
required: true
default: chrome
ALLURE_JOB_RUN_ID: # this will be used to generate Launch name on Allure TestOps side
description: "Allure TestOps service parameter, leave blank"
required: false
ALLURE_USERNAME:
description: "Allure TestOps service parameter, leave blank"
required: false
env:
ALLURE_ENDPOINT: ${{ secrets.ALLURE_ENDPOINT }}
ALLURE_TOKEN: ${{ secrets.ALLURE_TOKEN }}
ALLURE_PROJECT_ID: ${{ secrets.ALLURE_PROJECT_ID }}
ALLURE_TESTPLAN_PATH: "./testplan.json" # needed to filter the tests
ALLURE_RESULTS: "allure-results" # folder with the test results
ALLURE_JOB_RUN_ID: ${{ github.event.inputs.ALLURE_JOB_RUN_ID }}
jobs:
all-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Set up JDK 1.8
uses: actions/[email protected]
with:
java-version: 1.8
- uses: actions/[email protected]
id: allure-job-uid
with:
result-encoding: string
script: |
const result = await github.actions.getWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId,
});
return `${context.repo.owner}/${context.repo.repo}/actions/workflows/${result.data.workflow_id}`
- name: Download allurectl
run: |
wget https://github.com/allure-framework/allurectl/releases/latest/download/allurectl_linux_386 -O ./allurectl
chmod +x ./allurectl
- name: Prepare TestPlan
run: ./allurectl job-run plan --output-file ${ALLURE_TESTPLAN_PATH}
- name: Build with Gradle
run: ./allurectl watch -- ./gradlew test # allows sending the test results in the real time
env:
ALLURE_JOB_UID: ${{steps.allure-job-uid.outputs.result}}
TEST_ENDPOINT: ${{ github.event.inputs.TEST_ENDPOINT }}
TEST_BROWSER: ${{ github.event.inputs.TEST_BROWSER }}