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:
|
|
|
|
|
2021-10-21 23:24:11 +02:00
|
|
|
- name: Set up Go 1.17
|
|
|
|
uses: actions/setup-go@v2
|
2019-12-12 04:31:35 +01:00
|
|
|
with:
|
2021-10-21 23:24:11 +02:00
|
|
|
go-version: 1.17
|
2019-12-12 04:31:35 +01:00
|
|
|
id: go
|
|
|
|
|
|
|
|
- name: Check out code into the Go module directory
|
2021-10-21 23:24:11 +02:00
|
|
|
uses: actions/checkout@v2
|
2019-12-12 04:31:35 +01:00
|
|
|
|
2021-10-21 23:24:11 +02:00
|
|
|
- uses: actions/cache@v2
|
2020-07-01 00:53:30 +02:00
|
|
|
with:
|
|
|
|
path: ~/go/pkg/mod
|
2021-10-21 23:24:11 +02:00
|
|
|
key: ${{ runner.os }}-gofmt1.17-${{ hashFiles('**/go.sum') }}
|
2020-07-01 00:53:30 +02:00
|
|
|
restore-keys: |
|
2021-10-21 23:24:11 +02:00
|
|
|
${{ runner.os }}-gofmt1.17-
|
2020-07-01 00:53:30 +02:00
|
|
|
|
|
|
|
- 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
|