Fail build if go mod tidy/download changes
This commit is contained in:
parent
29fcf83bb5
commit
94f9031dcb
2
.github/workflows/go.yml
vendored
2
.github/workflows/go.yml
vendored
@ -15,7 +15,7 @@ jobs:
|
|||||||
- name: Check out source
|
- name: Check out source
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Install Linters
|
- name: Install Linters
|
||||||
run: "curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0"
|
run: "curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.28.0"
|
||||||
- name: Build
|
- name: Build
|
||||||
env:
|
env:
|
||||||
GO111MODULE: "on"
|
GO111MODULE: "on"
|
||||||
|
|||||||
14
run_tests.sh
14
run_tests.sh
@ -7,14 +7,28 @@ set -ex
|
|||||||
|
|
||||||
go version
|
go version
|
||||||
|
|
||||||
|
# run `go mod download` and `go mod tidy` and fail if the git status of
|
||||||
|
# go.mod and/or go.sum changes
|
||||||
|
MOD_STATUS=$(git status --porcelain go.mod go.sum)
|
||||||
|
go mod download
|
||||||
|
go mod tidy
|
||||||
|
UPDATED_MOD_STATUS=$(git status --porcelain go.mod go.sum)
|
||||||
|
if [ "$UPDATED_MOD_STATUS" != "$MOD_STATUS" ]; then
|
||||||
|
echo "Running `go mod tidy` modified go.mod and/or go.sum"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# run tests
|
||||||
env GORACE="halt_on_error=1" go test -race ./...
|
env GORACE="halt_on_error=1" go test -race ./...
|
||||||
|
|
||||||
|
# set output format for linter
|
||||||
if [[ -v CI ]]; then
|
if [[ -v CI ]]; then
|
||||||
OUT_FORMAT="github-actions"
|
OUT_FORMAT="github-actions"
|
||||||
else
|
else
|
||||||
OUT_FORMAT="colored-line-number"
|
OUT_FORMAT="colored-line-number"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# run linter
|
||||||
golangci-lint run --disable-all --deadline=10m \
|
golangci-lint run --disable-all --deadline=10m \
|
||||||
--out-format=$OUT_FORMAT \
|
--out-format=$OUT_FORMAT \
|
||||||
--enable=gofmt \
|
--enable=gofmt \
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user