From 01a98ff53ae896e7025ca80bb7b6d51aae1826e5 Mon Sep 17 00:00:00 2001 From: Nick Miyake Date: Sun, 24 Nov 2019 21:28:09 -0800 Subject: [PATCH 01/12] 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. --- azure-pipelines.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a86a6205..fa425e04 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -81,6 +81,9 @@ steps: - script: | go get -v -t -d ./... golangci-lint run -E gofmt -E goimports -E misspell + go mod tidy + diff -u <(echo -n) <(git diff go.mod) + diff -u <(echo -n) <(git diff go.sum) go test -race ./... workingDirectory: '$(modulePath)' displayName: Run tests From cc280440306c9980c186f8cfbbb1feaa44df809b Mon Sep 17 00:00:00 2001 From: Nick Miyake Date: Sun, 24 Nov 2019 21:40:20 -0800 Subject: [PATCH 02/12] Improve pipeline --- azure-pipelines.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index fa425e04..27997be2 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -78,12 +78,15 @@ steps: env displayName: Print Go version and environment -- script: | - go get -v -t -d ./... - golangci-lint run -E gofmt -E goimports -E misspell +- bash: | go mod tidy diff -u <(echo -n) <(git diff go.mod) diff -u <(echo -n) <(git diff go.sum) + displayName: Ensure that module definition and checksums are correct + +- script: | + go get -v -t -d ./... + golangci-lint run -E gofmt -E goimports -E misspell go test -race ./... workingDirectory: '$(modulePath)' displayName: Run tests From ef7b5b3821abce104b18c1037591ad040e4e84f6 Mon Sep 17 00:00:00 2001 From: Nick Miyake Date: Sun, 24 Nov 2019 21:44:45 -0800 Subject: [PATCH 03/12] Use script --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 27997be2..564e55f2 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -78,7 +78,7 @@ steps: env displayName: Print Go version and environment -- bash: | +- script: | go mod tidy diff -u <(echo -n) <(git diff go.mod) diff -u <(echo -n) <(git diff go.sum) From 62261c66604d51789faf334247d24fa49658c8c8 Mon Sep 17 00:00:00 2001 From: Nick Miyake Date: Sun, 24 Nov 2019 21:49:32 -0800 Subject: [PATCH 04/12] Add working directory --- azure-pipelines.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 564e55f2..e0b46b0c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -78,10 +78,11 @@ steps: env displayName: Print Go version and environment -- script: | +- bash: | go mod tidy diff -u <(echo -n) <(git diff go.mod) diff -u <(echo -n) <(git diff go.sum) + workingDirectory: '$(modulePath)' displayName: Ensure that module definition and checksums are correct - script: | From cff302c383c60fdc9917e9ac2af30828e9c0be6c Mon Sep 17 00:00:00 2001 From: Nick Miyake Date: Mon, 25 Nov 2019 10:34:20 -0800 Subject: [PATCH 05/12] Fix module definition script for Windows --- azure-pipelines.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e0b46b0c..6e638e8f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -80,8 +80,16 @@ steps: - bash: | go mod tidy - diff -u <(echo -n) <(git diff go.mod) - diff -u <(echo -n) <(git diff go.sum) + 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 From e7b37b4f1a80c1ec043427d42ad1257543a05c5b Mon Sep 17 00:00:00 2001 From: Nick Miyake Date: Mon, 25 Nov 2019 10:40:44 -0800 Subject: [PATCH 06/12] Add git configuration for autocrlf --- azure-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6e638e8f..896cf15b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -79,6 +79,7 @@ steps: displayName: Print Go version and environment - bash: | + git config --global core.autocrlf false go mod tidy if [ ! -z "$(git status --porcelain go.mod)" ]; then printf "go.mod has modifications\n" From b7d8b0f904488375733cde5fc8b3e20b87f80573 Mon Sep 17 00:00:00 2001 From: Nick Miyake Date: Mon, 25 Nov 2019 10:43:20 -0800 Subject: [PATCH 07/12] Simplify --- azure-pipelines.yml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 896cf15b..86a2ca5d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -81,16 +81,8 @@ steps: - bash: | git config --global core.autocrlf false 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 + diff -u <(echo -n) <(git diff go.mod) + diff -u <(echo -n) <(git diff go.sum) workingDirectory: '$(modulePath)' displayName: Ensure that module definition and checksums are correct From e0357e1cc3c581d5bb97e2a0f88299fb8deb0f59 Mon Sep 17 00:00:00 2001 From: Nick Miyake Date: Mon, 25 Nov 2019 10:49:19 -0800 Subject: [PATCH 08/12] Revert "Simplify" This reverts commit b7d8b0f904488375733cde5fc8b3e20b87f80573. --- azure-pipelines.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 86a2ca5d..896cf15b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -81,8 +81,16 @@ steps: - bash: | git config --global core.autocrlf false go mod tidy - diff -u <(echo -n) <(git diff go.mod) - diff -u <(echo -n) <(git diff go.sum) + 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 From 08b5531a1ba6ebef5cb4abb4c641ffd99d09bc3c Mon Sep 17 00:00:00 2001 From: Nick Miyake Date: Mon, 25 Nov 2019 11:02:19 -0800 Subject: [PATCH 09/12] Flip core.autocrlf --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 896cf15b..cfab2953 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -79,7 +79,7 @@ steps: displayName: Print Go version and environment - bash: | - git config --global core.autocrlf false + git config --global core.autocrlf true go mod tidy if [ ! -z "$(git status --porcelain go.mod)" ]; then printf "go.mod has modifications\n" From 93e4e7c468fa2103171e1f173a9693dea6e09926 Mon Sep 17 00:00:00 2001 From: Nick Miyake Date: Mon, 25 Nov 2019 11:07:07 -0800 Subject: [PATCH 10/12] Add .gitattributes to prevent line ending conversion --- .gitattributes | 1 + azure-pipelines.yml | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..fa1385d9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* -text diff --git a/azure-pipelines.yml b/azure-pipelines.yml index cfab2953..6e638e8f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -79,7 +79,6 @@ steps: displayName: Print Go version and environment - bash: | - git config --global core.autocrlf true go mod tidy if [ ! -z "$(git status --porcelain go.mod)" ]; then printf "go.mod has modifications\n" From 12a088aa29be453044fe96db61717164405ec706 Mon Sep 17 00:00:00 2001 From: Nick Miyake Date: Mon, 25 Nov 2019 11:19:53 -0800 Subject: [PATCH 11/12] Try approach without .gitattributes --- .gitattributes | 1 - azure-pipelines.yml | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) delete mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index fa1385d9..00000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* -text diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6e638e8f..7d78c06f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -26,6 +26,10 @@ variables: #GO111MODULE: on steps: + +- bash: git config --global core.autocrlf false + displayName: "Disable line ending conversion for git to" + - bash: | latestGo=$(curl "https://golang.org/VERSION?m=text") echo "##vso[task.setvariable variable=LATEST_GO]$latestGo" From f9382a2ea72ebfb1b4d3e3be9a250b75f1e305ec Mon Sep 17 00:00:00 2001 From: Nick Miyake Date: Mon, 25 Nov 2019 11:22:19 -0800 Subject: [PATCH 12/12] Add checkout step --- azure-pipelines.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7d78c06f..0dcfdcf3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -30,6 +30,8 @@ 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"