diff --git a/.circleci/config.yml b/.circleci/config.yml index 6d19c1d30fdcc..75e57de4e4a48 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -37,66 +37,51 @@ commands: default: "gotestsum" cache_version: type: string - default: "v2" - goversion: - type: string - default: 1.21.5 + default: "v3" steps: + - checkout - check-changed-files-or-halt - - restore_cache: - name: "Restore binaries from cache" - key: << parameters.os >>-<< parameters.arch >>-go<< parameters.goversion >>-<< parameters.cache_version >>-{{ checksum "go.sum" }} - when: condition: equal: [ linux, << parameters.os >> ] steps: + - restore_cache: + key: linux-go-<< parameters.cache_version >>-{{ checksum "go.sum" }} - attach_workspace: at: '/go' - when: condition: equal: [ darwin, << parameters.os >> ] steps: + - restore_cache: + key: darwin-go-<< parameters.cache_version >>-{{ checksum "go.sum" }} - run: 'sh ./scripts/installgo_mac.sh' - when: condition: equal: [ windows, << parameters.os >> ] steps: - - run: rm -rf '/c/Program Files/Go' + - run: rm -rf /c/Go - run: choco feature enable -n allowGlobalConfirmation + - restore_cache: + key: windows-go-<< parameters.cache_version >>-{{ checksum "go.sum" }} - run: 'sh ./scripts/installgo_windows.sh' - - run: choco install mingw --version=12.2.0.03042023 - - run: go env - - run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.0 + - run: choco install mingw + - run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.2 - when: condition: equal: [ linux, << parameters.os >> ] steps: - - run: - name: golangci-lint cache status - command: GOGC=20 /go/bin/golangci-lint cache status - - run: - name: golangci-lint run - command: GOGC=20 /go/bin/golangci-lint run --verbose + - run: GOGC=20 /go/bin/golangci-lint run --verbose - when: condition: equal: [ darwin, << parameters.os >> ] steps: - - run: - name: golangci-lint cache status - command: $HOME/go/bin/golangci-lint cache status - - run: - name: golangci-lint run - command: $HOME/go/bin/golangci-lint run --verbose + - run: $HOME/go/bin/golangci-lint run --verbose - when: condition: equal: [ windows, << parameters.os >> ] steps: - - run: - name: golangci-lint cache status - command: $HOME/go/bin/golangci-lint.exe cache status - - run: - name: golangci-lint run - command: $HOME/go/bin/golangci-lint.exe run --verbose + - run: $HOME/go/bin/golangci-lint.exe run --verbose - run: ./scripts/install_gotestsum.sh << parameters.os >> << parameters.gotestsum >> - unless: condition: @@ -126,19 +111,19 @@ commands: equal: [ linux, << parameters.os >> ] steps: - save_cache: - name: 'Saving binaries to cache' - key: << parameters.os >>-<< parameters.arch >>-go<< parameters.goversion >>-<< parameters.cache_version >>-{{ checksum "go.sum" }} + name: 'Saving cache' + key: linux-go-<< parameters.cache_version >>-{{ checksum "go.sum" }} paths: - - '/go/src/github.com/influxdata/telegraf/gotestsum' + - '~/go/src/github.com/influxdata/telegraf/gotestsum' - when: condition: equal: [ darwin, << parameters.os >> ] steps: - save_cache: - name: 'Saving binaries to cache' - key: << parameters.os >>-<< parameters.arch >>-go<< parameters.goversion >>-<< parameters.cache_version >>-{{ checksum "go.sum" }} + name: 'Saving cache' + key: darwin-go-<< parameters.cache_version >>-{{ checksum "go.sum" }} paths: - - '~/go/src/github.com/influxdata/telegraf/gotestsum' + - '/go/src/github.com/influxdata/telegraf/gotestsum' - '/usr/local/Cellar/go' - '/usr/local/bin/go' - '/usr/local/bin/gofmt' @@ -147,11 +132,11 @@ commands: equal: [ windows, << parameters.os >> ] steps: - save_cache: - name: 'Saving binaries to cache' - key: << parameters.os >>-<< parameters.arch >>-go<< parameters.goversion >>-<< parameters.cache_version >>-{{ checksum "go.sum" }} + name: 'Saving cache' + key: windows-go-<< parameters.cache_version >>-{{ checksum "go.sum" }} paths: - - '~\project\gotestsum.exe' - - 'C:\Program Files\Go' + - 'C:\Go' + - 'C:\Users\circleci\project\gotestsum.exe' package-build: parameters: type: @@ -191,22 +176,17 @@ commands: root: './build' paths: - 'dist' - jobs: test-go-linux: executor: telegraf-ci parameters: - goversion: - type: string - default: 1.21.5 cache_version: type: string default: "v2" steps: - checkout - restore_cache: - name: "Restore Go caches" - key: linux-amd64-go<< parameters.goversion >>-cache-<< parameters.cache_version >>-{{ checksum "go.sum" }} + key: go-mod-v1-{{ checksum "go.sum" }} - check-changed-files-or-halt - run: ./scripts/make_docs.sh - run: 'make deps' @@ -215,12 +195,10 @@ jobs: - run: 'make check-deps' - test-go - save_cache: - name: "Save Go caches" - key: linux-amd64-go<< parameters.goversion >>-<< parameters.cache_version >>-{{ checksum "go.sum" }} + name: 'go module cache' + key: go-mod-v1-{{ checksum "go.sum" }} paths: - '/go/pkg/mod' - - '~/.cache/golangci-lint' - - '~/.cache/go-build' - persist_to_workspace: root: '/go' paths: @@ -228,30 +206,19 @@ jobs: test-go-linux-386: executor: telegraf-ci parameters: - goversion: - type: string - default: 1.21.5 cache_version: type: string default: "v2" steps: - checkout - restore_cache: - name: "Restore Go caches" - key: linux-386-go<< parameters.goversion >>-cache-<< parameters.cache_version >>-{{ checksum "go.sum" }} + key: go-mod-v1-{{ checksum "go.sum" }} - check-changed-files-or-halt - run: 'GOARCH=386 make deps' - run: 'GOARCH=386 make tidy' - run: 'GOARCH=386 make check' - test-go: arch: "386" - - save_cache: - name: "Save Go caches" - key: linux-386-go<< parameters.goversion >>-cache-<< parameters.cache_version >>-{{ checksum "go.sum" }} - paths: - - '/go/pkg/mod' - - '~/.cache/golangci-lint' - - '~/.cache/go-build' test-integration: machine: image: ubuntu-2204:current @@ -265,32 +232,14 @@ jobs: test-go-mac: executor: mac parameters: - goversion: - type: string - default: 1.21.5 cache_version: type: string default: "v2" steps: - - checkout - - restore_cache: - name: "Restore Go caches" - key: darwin-arm64-go<< parameters.goversion >>-cache-<< parameters.cache_version >>-{{ checksum "go.sum" }} - test-go: os: darwin - arch: arm64 - - save_cache: - name: "Save Go caches" - key: darwin-arm64-go<< parameters.goversion >>-cache-<< parameters.cache_version >>-{{ checksum "go.sum" }} - paths: - - '~/go/pkg/mod' - - '~/Library/Caches/golangci-lint' - - '~/Library/Caches/go-build' test-go-windows: parameters: - goversion: - type: string - default: 1.21.5 cache_version: type: string default: "v2" @@ -299,45 +248,28 @@ jobs: shell: bash.exe size: xlarge steps: - - checkout - - restore_cache: - name: "Restore Go caches" - key: windows-amd64-go<< parameters.goversion >>-cache-<< parameters.cache_version >>-{{ checksum "go.sum" }} - test-go: os: windows gotestsum: "gotestsum.exe" - - save_cache: - name: "Save Go caches" - key: windows-amd64-go<< parameters.goversion >>-cache-<< parameters.cache_version >>-{{ checksum "go.sum" }} - paths: - - '~\go\pkg\mod' - - '~\AppData\Local\golangci-lint' - - '~\AppData\Local\go-build' test-licenses: executor: telegraf-ci parameters: - goversion: - type: string - default: 1.21.5 cache_version: type: string default: "v2" steps: - checkout - restore_cache: - name: "Restore Go caches" - key: linux-amd64-go<< parameters.goversion >>-cache-<< parameters.cache_version >>-{{ checksum "go.sum" }} + key: go-mod-v1-{{ checksum "go.sum" }} - check-changed-files-or-halt - run: 'make build_tools' - run: './tools/license_checker/license_checker -whitelist ./tools/license_checker/data/whitelist' - save_cache: - name: "Save Go caches" - key: linux-amd64-go<< parameters.goversion >>-cache-<< parameters.cache_version >>-{{ checksum "go.sum" }} + name: 'go module cache' + key: go-mod-v1-{{ checksum "go.sum" }} paths: - '/go/pkg/mod' - - '~/.cache/golangci-lint' - - '~/.cache/go-build' windows-package: parameters: diff --git a/scripts/installgo_windows.sh b/scripts/installgo_windows.sh index 134b40ff71b66..c980d405baa9c 100644 --- a/scripts/installgo_windows.sh +++ b/scripts/installgo_windows.sh @@ -9,6 +9,8 @@ setup_go () { choco upgrade golang --allow-downgrade --version=${GO_VERSION} choco install make git config --system core.longpaths true + rm -rf /c/Go + cp -r /c/Program\ Files/Go /c/ } if command -v go >/dev/null 2>&1; then