From 144d7bc199ff6bd3d884ecf535e1f700735e9ea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20K=C3=A4ufl?= Date: Tue, 28 Aug 2018 21:53:37 +0200 Subject: [PATCH 1/2] Update the Travis and CircleCI Go versions --- .circleci/config.yml | 4 ++-- .travis.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 066df2251..d749f3b5f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -26,11 +26,11 @@ version: 2 jobs: go-current: docker: - - image: circleci/golang:1.10.0 + - image: circleci/golang:1.11 <<: *base go-previous: docker: - - image: circleci/golang:1.9.4 + - image: circleci/golang:1.10 <<: *base go-latest: docker: diff --git a/.travis.yml b/.travis.yml index 5afcb2096..784fb017c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,8 @@ language: go matrix: include: - - go: 1.9.4 - - go: 1.10.0 + - go: 1.10.x + - go: 1.11.x - go: tip allow_failures: - go: tip From 6671edee266cb01f6aeab8ce9e59f5a43a4eb369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20K=C3=A4ufl?= Date: Tue, 28 Aug 2018 22:54:03 +0200 Subject: [PATCH 2/2] Adapt to new gofmt formatting The formatting of gofmt changed slightly in go 1.11. The release notes recommend to use a specific binary of gofmt. See https://golang.org/doc/go1.11#gofmt This commit adapts to the new formatting applied by gofmt and changes the configs for travis and circleci to run gofmt only with go 1.11. --- .circleci/config.yml | 69 ++++++++++++++++++++++++---------------- .travis.yml | 3 +- bash_completions_test.go | 2 +- 3 files changed, 45 insertions(+), 29 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d749f3b5f..6d248bcda 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,38 +1,53 @@ -workflows: - version: 2 - main: - jobs: - - go-current - - go-previous - - go-latest -base: &base - working_directory: /go/src/github.com/spf13/cobra - steps: - - checkout - - run: - name: "All Commands" - command: | - mkdir -p bin - curl -Lso bin/shellcheck https://github.com/caarlos0/shellcheck-docker/releases/download/v0.4.6/shellcheck - chmod +x bin/shellcheck - go get -t -v ./... - PATH=$PATH:$PWD/bin go test -v ./... - go build - diff -u <(echo -n) <(gofmt -d -s .) - if [ -z $NOVET ]; then - diff -u <(echo -n) <(go tool vet . 2>&1 | grep -vE 'ExampleCommand|bash_completions.*Fprint'); - fi version: 2 + +references: + workspace: &workspace + /go/src/github.com/spf13/cobra + + run_tests: &run_tests + run: + name: "All Commands" + command: | + mkdir -p bin + curl -Lso bin/shellcheck https://github.com/caarlos0/shellcheck-docker/releases/download/v0.4.6/shellcheck + chmod +x bin/shellcheck + go get -t -v ./... + PATH=$PATH:$PWD/bin go test -v ./... + go build + if [ -z $NOVET ]; then + diff -u <(echo -n) <(go tool vet . 2>&1 | grep -vE 'ExampleCommand|bash_completions.*Fprint'); + fi + jobs: go-current: docker: - image: circleci/golang:1.11 - <<: *base + working_directory: *workspace + steps: + - checkout + - *run_tests + - run: + name: "Check formatting" + command: diff -u <(echo -n) <(gofmt -d -s .) go-previous: docker: - image: circleci/golang:1.10 - <<: *base + working_directory: *workspace + steps: + - checkout + - *run_tests go-latest: docker: - image: circleci/golang:latest - <<: *base + working_directory: *workspace + steps: + - checkout + - *run_tests + +workflows: + version: 2 + main: + jobs: + - go-current + - go-previous + - go-latest diff --git a/.travis.yml b/.travis.yml index 784fb017c..5f157433a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,8 @@ matrix: - go: 1.10.x - go: 1.11.x - go: tip + - go: 1.11.x + script: diff -u <(echo -n) <(gofmt -d -s .) allow_failures: - go: tip @@ -15,7 +17,6 @@ before_install: script: - PATH=$PATH:$PWD/bin go test -v ./... - go build - - diff -u <(echo -n) <(gofmt -d -s .) - if [ -z $NOVET ]; then diff -u <(echo -n) <(go tool vet . 2>&1 | grep -vE 'ExampleCommand|bash_completions.*Fprint'); fi diff --git a/bash_completions_test.go b/bash_completions_test.go index 94b965dac..dd0fa52bc 100644 --- a/bash_completions_test.go +++ b/bash_completions_test.go @@ -71,7 +71,7 @@ func TestBashCompletions(t *testing.T) { ArgAliases: []string{"pods", "nodes", "services", "replicationcontrollers", "po", "no", "svc", "rc"}, ValidArgs: []string{"pod", "node", "service", "replicationcontroller"}, BashCompletionFunction: bashCompletionFunc, - Run: emptyRun, + Run: emptyRun, } rootCmd.Flags().IntP("introot", "i", -1, "help message for flag introot") rootCmd.MarkFlagRequired("introot")