Merge pull request #723 from cli/go-ci-checks
Assert that running `go fmt` or `go mod tidy` produces no changes in CI
This commit is contained in:
commit
44a37cbba3
1 changed files with 24 additions and 5 deletions
29
.github/workflows/go.yml
vendored
29
.github/workflows/go.yml
vendored
|
|
@ -18,10 +18,29 @@ jobs:
|
|||
uses: actions/checkout@v2
|
||||
|
||||
- name: Verify dependencies
|
||||
run: go mod verify
|
||||
|
||||
- name: Build
|
||||
shell: bash
|
||||
run: |
|
||||
go test -race ./...
|
||||
go build -v ./cmd/gh
|
||||
go mod verify
|
||||
go mod download
|
||||
|
||||
- name: Run tests
|
||||
shell: bash
|
||||
run: |
|
||||
assert-nothing-changed() {
|
||||
local diff
|
||||
git checkout -- .
|
||||
"$@" >/dev/null || true
|
||||
if ! diff="$(git diff -U1 --color --exit-code)"; then
|
||||
printf '\n\e[31mError: running `\e[1m%s\e[22m` results in modifications that you must check into version control:\e[0m\n%s\n' "$*" "$diff" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
STATUS=0
|
||||
go test -race ./... || STATUS=$?
|
||||
assert-nothing-changed go fmt ./... || STATUS=$?
|
||||
assert-nothing-changed go mod tidy || STATUS=$?
|
||||
exit $STATUS
|
||||
|
||||
- name: Build
|
||||
run: go build -v ./cmd/gh
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue