File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ if [ -z " $1 " ]; then
4+ rm -f ./gofmterr
5+ find . -iname ' *.go' ! -name ' *.pb.go' -exec " $0 " {} \;
6+ [ -f ./gofmterr ] && exit 1
7+ exit 0
8+ fi
9+
10+ OUT=" $( ./goimports -d " $1 " | awk ' {printf "%s%%0A",$0}' ) "
11+ if [ -n " $OUT " ]; then
12+ echo " ::error file=$1 ::$OUT "
13+ touch ./gofmterr
14+ fi
Original file line number Diff line number Diff line change 1+ name : gofmt
2+ on :
3+ push :
4+ branches :
5+ - main
6+ pull_request :
7+ paths :
8+ - " .github/workflows/gofmt.yml"
9+ - " .github/workflows/gofmt.sh"
10+ - " **.go"
11+
12+ jobs :
13+ gofmt :
14+ name : Run gofmt
15+ runs-on : ubuntu-latest
16+ steps :
17+ - name : Set up Go 1.19
18+ uses : actions/setup-go@v2
19+ with :
20+ go-version : 1.19
21+ id : go
22+
23+ - name : Check out code into the Go module directory
24+ uses : actions/checkout@v2
25+
26+ - uses : actions/cache@v2
27+ with :
28+ path : ~/go/pkg/mod
29+ key : ${{ runner.os }}-gofmt1.19-${{ hashFiles('**/go.sum') }}
30+ restore-keys : |
31+ ${{ runner.os }}-gofmt1.19-
32+
33+ - name : Install goimports
34+ run : |
35+ go get golang.org/x/tools/cmd/goimports
36+ go build golang.org/x/tools/cmd/goimports
37+
38+ - name : gofmt
39+ run : $GITHUB_WORKSPACE/.github/workflows/gofmt.sh
Original file line number Diff line number Diff line change 1+ name : Build and test
2+ on :
3+ push :
4+ branches :
5+ - main
6+ pull_request :
7+ paths :
8+ - " .github/workflows/test.yml"
9+ - " **Makefile"
10+ - " **.go"
11+ - " **.proto"
12+ - " go.mod"
13+ - " go.sum"
14+
15+ jobs :
16+ test-linux :
17+ name : Build and test on Ubuntu
18+ runs-on : ubuntu-latest
19+ steps :
20+ - name : Set up Go 1.19
21+ uses : actions/setup-go@v2
22+ with :
23+ go-version : 1.19
24+ id : go
25+
26+ - name : Check out code
27+ uses : actions/checkout@v3
28+
29+ - uses : actions/cache@v2
30+ with :
31+ path : ~/go/pkg/mod
32+ key : ${{ runner.os }}-go1.19-${{ hashFiles('**/go.sum') }}
33+ restore-keys : |
34+ ${{ runner.os }}-go1.19-
35+
36+ - name : Run unit tests
37+ run : make testvv
38+ env :
39+ TEST_FLAGS : -race
You can’t perform that action at this time.
0 commit comments