Add gofmt CI step (#115)
parent
c0eeb00f17
commit
7c4418392f
|
@ -9,6 +9,27 @@ on:
|
|||
- '*'
|
||||
|
||||
jobs:
|
||||
gofmt:
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2.1.4
|
||||
with:
|
||||
go-version: 1.16
|
||||
id: go
|
||||
# Check the codebase has been formatted by `gofmt`.
|
||||
# We run two `gofmt` commands for different purposes:
|
||||
# 1. `gofmt -d .`: to print diffs in the CI log if any.
|
||||
# 2. `gofmt -l`: to test there is a diff in the codebase. This is because
|
||||
# `gofmt` exits with exit status 0 even if there is a diff.
|
||||
# This is recommended in https://github.com/golang/go/issues/24230)
|
||||
- name: Run gofmt
|
||||
run: |
|
||||
gofmt -d .
|
||||
test -z $(gofmt -l .)
|
||||
|
||||
linux-tests:
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
|
|
Loading…
Reference in New Issue