😌 Peace of mind with GitHub Actions for a project in Go
Tags: actionshackathon21, go, ci
Published: 2021-12-09 02:30:59

[Instructions]: # (To submit to the GitHub Actions x DEV Hackathon 2021, please fill out all sections.)


### My Workflow
[Note]: # (Please make sure the project links to the appropriate GitHub Actions repository, and includes [an open source license](https://choosealicense.com/) and README.)

Automating simple checks and providing helpful information can make a noticeable difference on a quality of life of a project maintainer. As an enthusiastic Go developer and open source contributor I assembled a [library](https://github.com/bool64/dev) of tools to ease my life.

This library contains `Makefile` includes and GitHub Actions. Go project can import `github.com/bool64/dev` to receive versioned helpers. GitHub Actions are copied into the project with `make github-actions` (or `make reset-ci`).

#### Changed lines of code

Sometimes pull requests are big, this is usually not great, but might be unavoidable in some cases. This action comments the distribution of changed lines by type, so that it is easy to understand the scope (for example if largest part of PR is in JSON mocks).

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lmoq5l80uhzkxje4uht2.png)

#### API Changes

It is important to avoid unnecessary breaking changes or at least be aware of them. This action leverages [`gorelease`](https://pkg.go.dev/golang.org/x/exp/cmd/gorelease) to comment severity of API changes.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9woeh49cmy1rdh7kafo2.png)

#### Test Coverage

Having meaningful test coverage increases confidence. This action will show the difference of coverage for every changed function, so that developer can see where some more effort is needed.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t3yu5s8yvb3535404b9c.png)
 
#### Benchmark Difference

When high performance is important, this action will help to see degradation or improvements to inform further decisions.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o8jjkiuf404tq1hu984s.png)
 
#### Automated Binary Builder

For command line tools it is convenient to delegate binary releases to GitHub Actions, maintainer only needs to create a new release, building and uploading happens automagically.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/326apouwnf99s93np726.png)

### Submission Category: 

Maintainer Must-Haves



### Yaml File or Link to Code

* [Changed lines of code](https://github.com/bool64/dev/blob/master/templates/github/workflows/cloc.yml)
* [API Changes](https://github.com/bool64/dev/blob/master/templates/github/workflows/gorelease.yml)
* [Test Coverage](https://github.com/bool64/dev/blob/master/templates/github/workflows/test-unit.yml)
* [Benchmark Difference](https://github.com/bool64/dev/blob/master/templates/github/workflows/bench.yml)
* [Automated Binary Builder](https://github.com/bool64/dev/blob/master/templates/github/workflows/release-assets.yml)

{% github https://github.com/bool64/dev %}

### Additional Resources / Info

* PR Comment: [`marocchino/sticky-pull-request-comment`](https://github.com/marocchino/sticky-pull-request-comment)
* API Changes: [`gorelease`](https://pkg.go.dev/golang.org/x/exp/cmd/gorelease)
* A tool to show a number of changed lines: [`sccdiff`](https://github.com/vearutop/sccdiff/)
* Benchmark comparer: [`benchstat`](https://pkg.go.dev/golang.org/x/perf/cmd/benchstat)