DEV Community

nchika
nchika

Posted on • Edited on

1 1

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.

Image of Datadog

Learn how to monitor AWS container environments at scale

In this eBook, Datadog and AWS share insights into the changing state of containers in the cloud and explore why orchestration technologies are an essential part of managing ever-changing containerized workloads.

Download the eBook

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs