DEV Community

Viacheslav Poturaev
Viacheslav Poturaev

Posted on

😌 Peace of mind with GitHub Actions for a project in Go

My Workflow

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 of tools to ease my life.

This library contains Makefile includes and GitHub Actions. Go project can import 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

API Changes

It is important to avoid unnecessary breaking changes or at least be aware of them. This action leverages gorelease to comment severity of API changes.

Image description

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

Benchmark Difference

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

Image description

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

Submission Category:

Maintainer Must-Haves

Yaml File or Link to Code

GitHub logo bool64 / dev

🛠️ Go development helpers

Go development helpers



Run this command in your repo root.

curl -sLo Makefile && printf "package $(go list -f '{{.Name}}' || echo 'mypackage')_test\n\nimport _ \"\" // Include CI/Dev scripts to project.\n" > dev_test.go && make reset-ci


Add a test file (e.g. dev_test.go) to your module with unused import.

package mymodule_test
import _ "" // Include development helpers to project. 
Enter fullscreen mode Exit fullscreen mode

Add Makefile to your module with includes standard targets.

#GOLANGCI_LINT_VERSION := "v1.43.0" # Optional configuration to pinpoint golangci-lint version.
# The head of Makefile determines location of dev-go to include standard targets.
GO ?= go
export GO111MODULE = on

ifneq "$(GOFLAGS)" ""
  $(info GOFLAGS: ${GOFLAGS})

ifneq "$(wildcard ./vendor )" ""
  $(info Using vendor)
  modVendor =  -mod=vendor
  ifeq (,$(findstring -mod,$(GOFLAGS)))
      export GOFLAGS := ${GOFLAGS} ${modVendor}
  ifneq "$(wildcard ./vendor/" ""
    DEVGO_PATH := ./vendor/

Enter fullscreen mode Exit fullscreen mode

Additional Resources / Info

Top comments (0)