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