2019-12-11 20:31:35 -07:00
|
|
|
name: gofmt
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
pull_request:
|
2020-03-02 14:21:19 -07:00
|
|
|
paths:
|
|
|
|
- '.github/workflows/gofmt.yml'
|
|
|
|
- '**.go'
|
2019-12-11 20:31:35 -07:00
|
|
|
jobs:
|
|
|
|
|
|
|
|
gofmt:
|
|
|
|
name: Run gofmt
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
|
2021-02-17 11:11:57 -07:00
|
|
|
- name: Set up Go 1.16
|
2019-12-11 20:31:35 -07:00
|
|
|
uses: actions/setup-go@v1
|
|
|
|
with:
|
2021-02-17 11:11:57 -07:00
|
|
|
go-version: 1.16
|
2019-12-11 20:31:35 -07:00
|
|
|
id: go
|
|
|
|
|
|
|
|
- name: Check out code into the Go module directory
|
|
|
|
uses: actions/checkout@v1
|
|
|
|
|
2020-06-30 16:53:30 -06:00
|
|
|
- uses: actions/cache@v1
|
|
|
|
with:
|
|
|
|
path: ~/go/pkg/mod
|
2021-02-17 11:11:57 -07:00
|
|
|
key: ${{ runner.os }}-gofmt1.16-${{ hashFiles('**/go.sum') }}
|
2020-06-30 16:53:30 -06:00
|
|
|
restore-keys: |
|
2021-02-17 11:11:57 -07:00
|
|
|
${{ runner.os }}-gofmt1.16-
|
2020-06-30 16:53:30 -06:00
|
|
|
|
|
|
|
- name: Install goimports
|
|
|
|
run: |
|
|
|
|
go get golang.org/x/tools/cmd/goimports
|
|
|
|
go build golang.org/x/tools/cmd/goimports
|
|
|
|
|
2019-12-11 20:31:35 -07:00
|
|
|
- name: gofmt
|
|
|
|
run: |
|
2020-06-30 16:53:30 -06:00
|
|
|
if [ "$(find . -iname '*.go' | grep -v '\.pb\.go$' | xargs ./goimports -l)" ]
|
2019-12-11 20:31:35 -07:00
|
|
|
then
|
2020-06-30 16:53:30 -06:00
|
|
|
find . -iname '*.go' | grep -v '\.pb\.go$' | xargs ./goimports -d
|
2019-12-11 20:31:35 -07:00
|
|
|
exit 1
|
|
|
|
fi
|