Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
Add CI check to ensure module definition is correct (#198)
Browse files Browse the repository at this point in the history
* Add CI check to ensure module definition is correct

Fail verification if "go mod tidy" results in any modifications
to go.mod or go.sum.

* Improve pipeline

* Use script

* Add working directory

* Fix module definition script for Windows

* Add git configuration for autocrlf

* Simplify

* Revert "Simplify"

This reverts commit b7d8b0f.

* Flip core.autocrlf

* Add .gitattributes to prevent line ending conversion

* Try approach without .gitattributes

* Add checkout step
  • Loading branch information
nmiyake authored and mholt committed Nov 29, 2019
1 parent 0c5dd86 commit 44285f7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ variables:
#GO111MODULE: on

steps:

- bash: git config --global core.autocrlf false
displayName: "Disable line ending conversion for git to"

- checkout: self

- bash: |
latestGo=$(curl "https://golang.org/VERSION?m=text")
echo "##vso[task.setvariable variable=LATEST_GO]$latestGo"
Expand Down Expand Up @@ -78,6 +84,21 @@ steps:
env
displayName: Print Go version and environment

- bash: |
go mod tidy
if [ ! -z "$(git status --porcelain go.mod)" ]; then
printf "go.mod has modifications\n"
git diff go.mod
exit 1
fi
if [ ! -z "$(git status --porcelain go.sum)" ]; then
printf "go.sum has modifications\n"
git diff go.sum
exit 1
fi
workingDirectory: '$(modulePath)'
displayName: Ensure that module definition and checksums are correct

- script: |
go get -v -t -d ./...
golangci-lint run -E gofmt -E goimports -E misspell
Expand Down

0 comments on commit 44285f7

Please sign in to comment.