GitHub Actions integration

With the Allure Report plugin for GitHub Actions, you can automatically generate test reports and publish them to GitHub Pages.

To enable Allure support in your Bamboo installation, do the following under the repository's administrator account:

  1. add actions for building and publishing reports.
  2. enable write access for workflow runs,
  3. set up publishing to GitHub Pages.

1. Add actions for building and publishing reports

At the end of your repository's testing workflow, add three new steps that will load test report history, build test report and publish test report.

See below for more details on each step and its parameters.

Here is a full example of a workflow file for a Java project. The example assumes that the branch used for GitHub Pages is called gh-pages.

YAML
name: Run tests and publish report on: [push] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Set up JDK uses: actions/setup-java@v3 with: distribution: zulu java-version: 17 - name: Run tests run: ./gradlew clean test - name: Load test report history uses: actions/checkout@v3 if: always() continue-on-error: true with: ref: gh-pages path: gh-pages - name: Build test report uses: simple-elf/[email protected] if: always() with: gh_pages: gh-pages allure_history: allure-history allure_results: build/allure-results - name: Publish test report uses: peaceiris/actions-gh-pages@v3 if: always() with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_branch: gh-pages publish_dir: allure-history

Load test report history

As discussed in Tests history, Allure Report can include some data from previous reports into each new report. To do so, you need to provide it with the files published on GitHub Pages by previous runs. This step does it by doing a git checkout from the branch used for the GitHub Pages content.

In the workflow file, set the following values for this step:

  • name: any human-redable name, e.g., “Load test report history”.
  • uses: actions/checkout@v2.
  • if: always().
  • continue-on-error: true.
  • with:
    • ref: the branch used for the GitHub Pages content.
    • path: an arbitrary name for a directory to which the previous data will be saved.

Build test report

This step runs the Allure Report utility to build an HTML report, based on data from both the current and previous test launches. The new report, along with the copies of previous reports, will be saved into the directory specified in allure_history, ready to be published to GitHub Pages.

In the workflow file, set the following values for this step:

  • name: any human-readable name, e.g., “Build test report”.
  • uses: simple-elf/[email protected].
  • if: always().
  • with:
    • gh_pages: the directory name to which the previous data was downloaded. Must be the same as the path value from the Load test reports history step.
    • allure_results: path to the current test results directory. Depending on the framework you use and the Allure adapter configuration, an appropriate path may be allure-results, build/allure-results, or some custom path.
    • allure_history: an arbitrary name for a directory to which the result will be saved.

Publish test report

The final step of the workflow will push the generated directory to the branch used for GitHub Pages. This is supposed to trigger a second workflow run, called “pages build and deployment”, which, in turn, will update the actual contents on the GitHub Pages domain. (See Set up publishing to GitHub Pages below.)

In the workflow file, set the following values for this step:

2. Enable write access for workflow runs

When pushing files to the GitHub Pages branch, the workflow uses an authentication token generated by GitHub. However, the default configuration does not allow GitHub Actions to push files to the repository, and you may find errors like this in your workflow run's logs:

remote: Permission to ⟨USER⟩/⟨REPOSITORY⟩.git denied to github-actions[bot]. fatal: unable to access 'https://github.com/⟨USER⟩/⟨REPOSITORY⟩.git/': The requested URL returned error: 403

To fix this, you need to grant write permissions to the token.

  1. On the project's page on GitHub, go to Settings → Actions → General.

  2. Under the Workflow permissions section, select the Read and write permissions option.

  3. Click Save.

Allure Github configure workflow permissions

3. Set up publishing to GitHub Pages

After you've run the workflow for the first time, it will push the test report to a branch but will not actually publish it. For the report to be published, you need to enable an automatic second workflow settings.

  1. Make sure that the branch with the content exists (gh-pages in the example above).

  2. On the project's page on GitHub, go to Settings → Pages.

  3. Under the Build and deployment section, specify the options:

    • Source: “Deploy from a branch”.
    • Branch: the branch used for the GitHub Pages content. In the next dropdown list, select “/ (root)”.
  4. Click Save.

  5. Go to the Actions tab.

  6. Make sure that the workflow run called “pages build and deployment” was automatically created.

    Once the run is completed, the test report should appear on the GitHub Pages domain.

Allure Github configure github pages

Powered by
logo

Join our newsletter

Join our community

We aim to make Allure Report as reliable and user-friendly as possible, and together with the community, we're here to help when problems arise.

© 2024 Qameta Software Inc. All rights reserved.