chore: Cache rework for `.circleci` jobs (#13753)
Co-authored-by: Pawel Zak <Pawel Zak>
This commit is contained in:
parent
6f5e5be7b2
commit
904db01e6b
|
|
@ -37,51 +37,62 @@ commands:
|
||||||
default: "gotestsum"
|
default: "gotestsum"
|
||||||
cache_version:
|
cache_version:
|
||||||
type: string
|
type: string
|
||||||
default: "v3"
|
default: "v1"
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
|
||||||
- check-changed-files-or-halt
|
- check-changed-files-or-halt
|
||||||
|
- restore_cache:
|
||||||
|
name: "Restore binaries from cache"
|
||||||
|
key: << parameters.os >>-<< parameters.arch >>-go-bin-<< parameters.cache_version >>-{{ checksum "go.sum" }}
|
||||||
- when:
|
- when:
|
||||||
condition:
|
condition:
|
||||||
equal: [ linux, << parameters.os >> ]
|
equal: [ linux, << parameters.os >> ]
|
||||||
steps:
|
steps:
|
||||||
- restore_cache:
|
|
||||||
key: linux-go-<< parameters.cache_version >>-{{ checksum "go.sum" }}
|
|
||||||
- attach_workspace:
|
- attach_workspace:
|
||||||
at: '/go'
|
at: '/go'
|
||||||
- when:
|
- when:
|
||||||
condition:
|
condition:
|
||||||
equal: [ darwin, << parameters.os >> ]
|
equal: [ darwin, << parameters.os >> ]
|
||||||
steps:
|
steps:
|
||||||
- restore_cache:
|
|
||||||
key: darwin-go-<< parameters.cache_version >>-{{ checksum "go.sum" }}
|
|
||||||
- run: 'sh ./scripts/installgo_mac.sh'
|
- run: 'sh ./scripts/installgo_mac.sh'
|
||||||
- when:
|
- when:
|
||||||
condition:
|
condition:
|
||||||
equal: [ windows, << parameters.os >> ]
|
equal: [ windows, << parameters.os >> ]
|
||||||
steps:
|
steps:
|
||||||
- run: rm -rf /c/Go
|
|
||||||
- run: choco feature enable -n allowGlobalConfirmation
|
- run: choco feature enable -n allowGlobalConfirmation
|
||||||
- restore_cache:
|
|
||||||
key: windows-go-<< parameters.cache_version >>-{{ checksum "go.sum" }}
|
|
||||||
- run: 'sh ./scripts/installgo_windows.sh'
|
- run: 'sh ./scripts/installgo_windows.sh'
|
||||||
- run: choco install mingw
|
- run: choco install mingw
|
||||||
|
- run: go env
|
||||||
- run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.2
|
- run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.2
|
||||||
- when:
|
- when:
|
||||||
condition:
|
condition:
|
||||||
equal: [ linux, << parameters.os >> ]
|
equal: [ linux, << parameters.os >> ]
|
||||||
steps:
|
steps:
|
||||||
- run: GOGC=20 /go/bin/golangci-lint run --verbose
|
- 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
|
||||||
- when:
|
- when:
|
||||||
condition:
|
condition:
|
||||||
equal: [ darwin, << parameters.os >> ]
|
equal: [ darwin, << parameters.os >> ]
|
||||||
steps:
|
steps:
|
||||||
- run: $HOME/go/bin/golangci-lint run --verbose
|
- 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
|
||||||
- when:
|
- when:
|
||||||
condition:
|
condition:
|
||||||
equal: [ windows, << parameters.os >> ]
|
equal: [ windows, << parameters.os >> ]
|
||||||
steps:
|
steps:
|
||||||
- run: $HOME/go/bin/golangci-lint.exe run --verbose
|
- 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: ./scripts/install_gotestsum.sh << parameters.os >> << parameters.gotestsum >>
|
- run: ./scripts/install_gotestsum.sh << parameters.os >> << parameters.gotestsum >>
|
||||||
- unless:
|
- unless:
|
||||||
condition:
|
condition:
|
||||||
|
|
@ -111,19 +122,19 @@ commands:
|
||||||
equal: [ linux, << parameters.os >> ]
|
equal: [ linux, << parameters.os >> ]
|
||||||
steps:
|
steps:
|
||||||
- save_cache:
|
- save_cache:
|
||||||
name: 'Saving cache'
|
name: 'Saving binaries to cache'
|
||||||
key: linux-go-<< parameters.cache_version >>-{{ checksum "go.sum" }}
|
key: << parameters.os >>-<< parameters.arch >>-go-bin-<< parameters.cache_version >>-{{ checksum "go.sum" }}
|
||||||
paths:
|
paths:
|
||||||
- '~/go/src/github.com/influxdata/telegraf/gotestsum'
|
- '/go/src/github.com/influxdata/telegraf/gotestsum'
|
||||||
- when:
|
- when:
|
||||||
condition:
|
condition:
|
||||||
equal: [ darwin, << parameters.os >> ]
|
equal: [ darwin, << parameters.os >> ]
|
||||||
steps:
|
steps:
|
||||||
- save_cache:
|
- save_cache:
|
||||||
name: 'Saving cache'
|
name: 'Saving binaries to cache'
|
||||||
key: darwin-go-<< parameters.cache_version >>-{{ checksum "go.sum" }}
|
key: << parameters.os >>-<< parameters.arch >>-go-bin-<< parameters.cache_version >>-{{ checksum "go.sum" }}
|
||||||
paths:
|
paths:
|
||||||
- '/go/src/github.com/influxdata/telegraf/gotestsum'
|
- '~/go/src/github.com/influxdata/telegraf/gotestsum'
|
||||||
- '/usr/local/Cellar/go'
|
- '/usr/local/Cellar/go'
|
||||||
- '/usr/local/bin/go'
|
- '/usr/local/bin/go'
|
||||||
- '/usr/local/bin/gofmt'
|
- '/usr/local/bin/gofmt'
|
||||||
|
|
@ -132,11 +143,11 @@ commands:
|
||||||
equal: [ windows, << parameters.os >> ]
|
equal: [ windows, << parameters.os >> ]
|
||||||
steps:
|
steps:
|
||||||
- save_cache:
|
- save_cache:
|
||||||
name: 'Saving cache'
|
name: 'Saving binaries to cache'
|
||||||
key: windows-go-<< parameters.cache_version >>-{{ checksum "go.sum" }}
|
key: << parameters.os >>-<< parameters.arch >>-go-bin-<< parameters.cache_version >>-{{ checksum "go.sum" }}
|
||||||
paths:
|
paths:
|
||||||
- 'C:\Go'
|
- '~\project\gotestsum.exe'
|
||||||
- 'C:\Users\circleci\project\gotestsum.exe'
|
- 'C:\Program Files\Go'
|
||||||
package-build:
|
package-build:
|
||||||
parameters:
|
parameters:
|
||||||
type:
|
type:
|
||||||
|
|
@ -176,13 +187,15 @@ commands:
|
||||||
root: './build'
|
root: './build'
|
||||||
paths:
|
paths:
|
||||||
- 'dist'
|
- 'dist'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test-go-linux:
|
test-go-linux:
|
||||||
executor: telegraf-ci
|
executor: telegraf-ci
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
key: go-mod-v1-{{ checksum "go.sum" }}
|
name: "Restore Go caches"
|
||||||
|
key: linux-amd64-go-cache-v1-{{ checksum "go.sum" }}
|
||||||
- check-changed-files-or-halt
|
- check-changed-files-or-halt
|
||||||
- run: ./scripts/make_docs.sh
|
- run: ./scripts/make_docs.sh
|
||||||
- run: 'make deps'
|
- run: 'make deps'
|
||||||
|
|
@ -191,10 +204,12 @@ jobs:
|
||||||
- run: 'make check-deps'
|
- run: 'make check-deps'
|
||||||
- test-go
|
- test-go
|
||||||
- save_cache:
|
- save_cache:
|
||||||
name: 'go module cache'
|
name: "Save Go caches"
|
||||||
key: go-mod-v1-{{ checksum "go.sum" }}
|
key: linux-amd64-go-cache-v1-{{ checksum "go.sum" }}
|
||||||
paths:
|
paths:
|
||||||
- '/go/pkg/mod'
|
- '/go/pkg/mod'
|
||||||
|
- '~/.cache/golangci-lint'
|
||||||
|
- '~/.cache/go-build'
|
||||||
- persist_to_workspace:
|
- persist_to_workspace:
|
||||||
root: '/go'
|
root: '/go'
|
||||||
paths:
|
paths:
|
||||||
|
|
@ -204,13 +219,21 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
key: go-mod-v1-{{ checksum "go.sum" }}
|
name: "Restore Go caches"
|
||||||
|
key: linux-386-go-cache-v1-{{ checksum "go.sum" }}
|
||||||
- check-changed-files-or-halt
|
- check-changed-files-or-halt
|
||||||
- run: 'GOARCH=386 make deps'
|
- run: 'GOARCH=386 make deps'
|
||||||
- run: 'GOARCH=386 make tidy'
|
- run: 'GOARCH=386 make tidy'
|
||||||
- run: 'GOARCH=386 make check'
|
- run: 'GOARCH=386 make check'
|
||||||
- test-go:
|
- test-go:
|
||||||
arch: "386"
|
arch: "386"
|
||||||
|
- save_cache:
|
||||||
|
name: "Save Go caches"
|
||||||
|
key: linux-386-go-cache-v1-{{ checksum "go.sum" }}
|
||||||
|
paths:
|
||||||
|
- '/go/pkg/mod'
|
||||||
|
- '~/.cache/golangci-lint'
|
||||||
|
- '~/.cache/go-build'
|
||||||
test-integration:
|
test-integration:
|
||||||
machine:
|
machine:
|
||||||
image: ubuntu-2204:current
|
image: ubuntu-2204:current
|
||||||
|
|
@ -224,32 +247,57 @@ jobs:
|
||||||
test-go-mac:
|
test-go-mac:
|
||||||
executor: mac
|
executor: mac
|
||||||
steps:
|
steps:
|
||||||
|
- checkout
|
||||||
|
- restore_cache:
|
||||||
|
name: "Restore Go caches"
|
||||||
|
key: darwin-amd64-go-cache-v1-{{ checksum "go.sum" }}
|
||||||
- test-go:
|
- test-go:
|
||||||
os: darwin
|
os: darwin
|
||||||
|
- save_cache:
|
||||||
|
name: "Save Go caches"
|
||||||
|
key: darwin-amd64-go-cache-v1-{{ checksum "go.sum" }}
|
||||||
|
paths:
|
||||||
|
- '~/go/pkg/mod'
|
||||||
|
- '~/Library/Caches/golangci-lint'
|
||||||
|
- '~/Library/Caches/go-build'
|
||||||
test-go-windows:
|
test-go-windows:
|
||||||
executor:
|
executor:
|
||||||
name: win/default
|
name: win/default
|
||||||
shell: bash.exe
|
shell: bash.exe
|
||||||
size: xlarge
|
size: xlarge
|
||||||
steps:
|
steps:
|
||||||
|
- checkout
|
||||||
|
- restore_cache:
|
||||||
|
name: "Restore Go caches"
|
||||||
|
key: windows-amd64-go-cache-v1-{{ checksum "go.sum" }}
|
||||||
- test-go:
|
- test-go:
|
||||||
os: windows
|
os: windows
|
||||||
gotestsum: "gotestsum.exe"
|
gotestsum: "gotestsum.exe"
|
||||||
|
- save_cache:
|
||||||
|
name: "Save Go caches"
|
||||||
|
key: windows-amd64-go-cache-v1-{{ checksum "go.sum" }}
|
||||||
|
paths:
|
||||||
|
- '~\go\pkg\mod'
|
||||||
|
- '~\AppData\Local\golangci-lint'
|
||||||
|
- '~\AppData\Local\go-build'
|
||||||
|
|
||||||
test-licenses:
|
test-licenses:
|
||||||
executor: telegraf-ci
|
executor: telegraf-ci
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
key: go-mod-v1-{{ checksum "go.sum" }}
|
name: "Restore Go caches"
|
||||||
|
key: linux-amd64-go-cache-v1-{{ checksum "go.sum" }}
|
||||||
- check-changed-files-or-halt
|
- check-changed-files-or-halt
|
||||||
- run: 'make build_tools'
|
- run: 'make build_tools'
|
||||||
- run: './tools/license_checker/license_checker -whitelist ./tools/license_checker/data/whitelist'
|
- run: './tools/license_checker/license_checker -whitelist ./tools/license_checker/data/whitelist'
|
||||||
- save_cache:
|
- save_cache:
|
||||||
name: 'go module cache'
|
name: "Save Go caches"
|
||||||
key: go-mod-v1-{{ checksum "go.sum" }}
|
key: linux-amd64-go-cache-v1-{{ checksum "go.sum" }}
|
||||||
paths:
|
paths:
|
||||||
- '/go/pkg/mod'
|
- '/go/pkg/mod'
|
||||||
|
- '~/.cache/golangci-lint'
|
||||||
|
- '~/.cache/go-build'
|
||||||
|
|
||||||
windows-package:
|
windows-package:
|
||||||
parameters:
|
parameters:
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,6 @@ setup_go () {
|
||||||
choco upgrade golang --allow-downgrade --version=${GO_VERSION}
|
choco upgrade golang --allow-downgrade --version=${GO_VERSION}
|
||||||
choco install make
|
choco install make
|
||||||
git config --system core.longpaths true
|
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
|
if command -v go >/dev/null 2>&1; then
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue