actions-hottest🚀: GitHub Actions for Commenting on Golang Unit Test Results in Pull Requests

nchika

nchika

Posted on December 2, 2023

actions-hottest🚀: GitHub Actions for Commenting on Golang Unit Test Results in Pull Requests

Make the test results more user-friendly

I previously introduced a feature in the go-spectest/spectest, which extracts error messages from Golang unit test results.

I have now separated that functionality into the nao1215/hottest command.

The 'hottest' command can use the same options as 'go test':

demo

hottest on GitHub Actions

Many people run unit tests using GitHub Actions. Therefore, I created nao1215/actions-hottest to make it easy to execute 'hottest' in GitHub Actions.

Here is an example workflow for running unit tests using 'hottest':

name: SampleTest

on:
  push:

jobs:
  sample_test:
    name: sample test

    strategy:
      matrix:
        platform: [ubuntu-latest]

    runs-on: ${{ matrix.platform }}

    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-go@v4
        with:
          go-version: "1"
          check-latest: true

      - name: Download dependencies
        run: go mod download

      - uses: nao1215/actions-hottest@v1
        with:
          # This argument is same as `go test` command.
          args: '-cover -coverpkg=./... -coverprofile=coverage.out ./...'
Enter fullscreen mode Exit fullscreen mode

Here are the logs for when the unit tests succeed and when they fail:

  • when all test pass
    all-test-pass

  • when some test fails
    test-fail

Comments Test Results in Pull Request

I find it inconvenient to check the workflow logs when tests fail. Therefore, I have decided to have 'hottest' leave the test results as comments in the Pull Request.

Here are the comments for when the unit tests succeed and when they fail:

  • when all test pass
    all-test-pass

  • when some test fails
    test-fail

Conclusion

'hottest' is a command that extracts error messages from failed unit tests. You can easily adopt GitHub Actions. Its usage is similar to 'go test,' and there is no need to rewrite the test code.

lease do give 'hottest' a try!! Additionally, your support in the form of a GitHub star would be encouraging for further development.

💖 💪 🙅 🚩
nchika
nchika

Posted on December 2, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related