From a1401c26b1c5fa9ba759de38705db7001c07fd04 Mon Sep 17 00:00:00 2001 From: SuperQ Date: Wed, 25 Aug 2021 16:24:42 +0200 Subject: [PATCH 1/2] Build with Go 1.17 Update build to use Go 1.17. * Use golang-builder images for testing. * Update CircleCI go orb. * Use tools from golang-builder image. Signed-off-by: SuperQ --- .circleci/config.yml | 14 ++++---------- .promu.yml | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index db7bbc257..97152bea7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ version: 2.1 orbs: prometheus: prometheus/prometheus@0.11.0 - go: circleci/go@0.2.0 + go: circleci/go@1.7.0 win: circleci/windows@2.3.0 executors: @@ -11,10 +11,10 @@ executors: # should also be updated. golang: docker: - - image: circleci/golang:1.16-node + - image: quay.io/prometheus/golang-builder:1.17-base golang_115: docker: - - image: circleci/golang:1.15-node + - image: quay.io/prometheus/golang-builder:1.15-base jobs: test_go: @@ -24,8 +24,6 @@ jobs: - prometheus/setup_environment - go/load-cache: key: v1 - - run: - command: sudo apt-get install -y yamllint - run: command: make GO_ONLY=1 environment: @@ -110,14 +108,12 @@ jobs: - run: command: go install -mod=readonly github.com/google/go-jsonnet/cmd/jsonnet github.com/google/go-jsonnet/cmd/jsonnetfmt github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb working_directory: ~/project/documentation/prometheus-mixin - - run: + -8716766cb49ab9dd7df5622d80bb217b94a21d0f3d3dc3d074c3ec7a0c7f67ea run: command: make clean working_directory: ~/project/documentation/prometheus-mixin - run: command: jb install working_directory: ~/project/documentation/prometheus-mixin - - run: - command: sudo apt-get install -y yamllint - run: command: make working_directory: ~/project/documentation/prometheus-mixin @@ -129,8 +125,6 @@ jobs: executor: golang steps: - checkout - - run: mkdir -v -p "${PATH%%:*}" && curl -sL --fail https://github.com/mikefarah/yq/releases/download/v4.6.3/yq_linux_amd64 -o "${PATH%%:*}/yq" && chmod -v +x "${PATH%%:*}/yq" - - run: sha256sum -c <(echo "c4343783c3361495c0d6d1eb742bba7432aa65e13e9fb8d7e201d544bcf14246 ${PATH%%:*}/yq") - run: ./scripts/sync_repo_files.sh workflows: diff --git a/.promu.yml b/.promu.yml index f52a646de..9601efeee 100644 --- a/.promu.yml +++ b/.promu.yml @@ -1,7 +1,7 @@ go: # Whenever the Go version is updated here, # .circle/config.yml should also be updated. - version: 1.16 + version: 1.17 repository: path: github.com/prometheus/prometheus build: From e167a45c6550736bb1ed5d1baca4e8f93c0aa9fb Mon Sep 17 00:00:00 2001 From: SuperQ Date: Wed, 25 Aug 2021 16:35:30 +0200 Subject: [PATCH 2/2] Add new Go build tags. Add new go:build comments based on 1.17 formatting[0]. [0]: https://golang.org/doc/go1.17#gofmt Signed-off-by: SuperQ --- .circleci/config.yml | 2 +- cmd/prometheus/main_unix_test.go | 1 + config/config_default_test.go | 1 + documentation/prometheus-mixin/tools.go | 3 ++- pkg/runtime/limits_default.go | 1 + pkg/runtime/limits_windows.go | 1 + pkg/runtime/statfs.go | 1 + pkg/runtime/statfs_default.go | 4 ++-- pkg/runtime/statfs_linux_386.go | 1 + pkg/runtime/statfs_uint32.go | 1 + pkg/runtime/uname_default.go | 1 + pkg/runtime/vmlimits_default.go | 4 ++-- pkg/runtime/vmlimits_openbsd.go | 1 + promql/fuzz.go | 1 + scripts/tools.go | 1 + tsdb/chunks/head_chunks_other.go | 1 + tsdb/fileutil/dir_unix.go | 1 + tsdb/fileutil/dir_windows.go | 1 + tsdb/fileutil/flock_solaris.go | 1 + tsdb/fileutil/flock_unix.go | 1 + tsdb/fileutil/mmap_386.go | 1 + tsdb/fileutil/mmap_amd64.go | 1 + tsdb/fileutil/mmap_unix.go | 1 + tsdb/fileutil/preallocate_other.go | 1 + tsdb/fileutil/sync.go | 1 + tsdb/fileutil/sync_darwin.go | 1 + tsdb/fileutil/sync_linux.go | 1 + tsdb/goversion/goversion.go | 1 + tsdb/wal_test.go | 1 + web/ui/assets_generate.go | 1 + web/ui/ui.go | 1 + 31 files changed, 34 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 97152bea7..4ef588110 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -108,7 +108,7 @@ jobs: - run: command: go install -mod=readonly github.com/google/go-jsonnet/cmd/jsonnet github.com/google/go-jsonnet/cmd/jsonnetfmt github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb working_directory: ~/project/documentation/prometheus-mixin - -8716766cb49ab9dd7df5622d80bb217b94a21d0f3d3dc3d074c3ec7a0c7f67ea run: + - run: command: make clean working_directory: ~/project/documentation/prometheus-mixin - run: diff --git a/cmd/prometheus/main_unix_test.go b/cmd/prometheus/main_unix_test.go index 393c6f952..7724f0dd1 100644 --- a/cmd/prometheus/main_unix_test.go +++ b/cmd/prometheus/main_unix_test.go @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. // +//go:build !windows // +build !windows package main diff --git a/config/config_default_test.go b/config/config_default_test.go index e0f09aa11..f5333f4c8 100644 --- a/config/config_default_test.go +++ b/config/config_default_test.go @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !windows // +build !windows package config diff --git a/documentation/prometheus-mixin/tools.go b/documentation/prometheus-mixin/tools.go index e3551e821..1115bb953 100644 --- a/documentation/prometheus-mixin/tools.go +++ b/documentation/prometheus-mixin/tools.go @@ -12,7 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//+build tools +//go:build tools +// +build tools // Package tools tracks dependencies for tools that used in the build process. // See https://github.com/golang/go/issues/25922 diff --git a/pkg/runtime/limits_default.go b/pkg/runtime/limits_default.go index 4f59b1c55..c3e0b4701 100644 --- a/pkg/runtime/limits_default.go +++ b/pkg/runtime/limits_default.go @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !windows // +build !windows package runtime diff --git a/pkg/runtime/limits_windows.go b/pkg/runtime/limits_windows.go index d947e132e..ce514949e 100644 --- a/pkg/runtime/limits_windows.go +++ b/pkg/runtime/limits_windows.go @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build windows // +build windows package runtime diff --git a/pkg/runtime/statfs.go b/pkg/runtime/statfs.go index 06522094e..2e5a624b6 100644 --- a/pkg/runtime/statfs.go +++ b/pkg/runtime/statfs.go @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build openbsd || windows || netbsd || solaris // +build openbsd windows netbsd solaris package runtime diff --git a/pkg/runtime/statfs_default.go b/pkg/runtime/statfs_default.go index 8ce7d8339..a493a5cbb 100644 --- a/pkg/runtime/statfs_default.go +++ b/pkg/runtime/statfs_default.go @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build !windows,!openbsd,!netbsd,!solaris -// +build !386 +//go:build !windows && !openbsd && !netbsd && !solaris && !386 +// +build !windows,!openbsd,!netbsd,!solaris,!386 package runtime diff --git a/pkg/runtime/statfs_linux_386.go b/pkg/runtime/statfs_linux_386.go index ba90ca8a6..b45eecdd3 100644 --- a/pkg/runtime/statfs_linux_386.go +++ b/pkg/runtime/statfs_linux_386.go @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build linux && 386 // +build linux,386 package runtime diff --git a/pkg/runtime/statfs_uint32.go b/pkg/runtime/statfs_uint32.go index 1a5557a8c..fa10ebc96 100644 --- a/pkg/runtime/statfs_uint32.go +++ b/pkg/runtime/statfs_uint32.go @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build (386 && darwin) || (386 && freebsd) // +build 386,darwin 386,freebsd package runtime diff --git a/pkg/runtime/uname_default.go b/pkg/runtime/uname_default.go index 595a4a28c..161337121 100644 --- a/pkg/runtime/uname_default.go +++ b/pkg/runtime/uname_default.go @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !linux // +build !linux package runtime diff --git a/pkg/runtime/vmlimits_default.go b/pkg/runtime/vmlimits_default.go index 47c4dd7c9..bf35b48fe 100644 --- a/pkg/runtime/vmlimits_default.go +++ b/pkg/runtime/vmlimits_default.go @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build !windows -// +build !openbsd +//go:build !windows && !openbsd +// +build !windows,!openbsd package runtime diff --git a/pkg/runtime/vmlimits_openbsd.go b/pkg/runtime/vmlimits_openbsd.go index f2117fe06..e33ab4802 100644 --- a/pkg/runtime/vmlimits_openbsd.go +++ b/pkg/runtime/vmlimits_openbsd.go @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build openbsd // +build openbsd package runtime diff --git a/promql/fuzz.go b/promql/fuzz.go index eeb1fede8..b34fbbc66 100644 --- a/promql/fuzz.go +++ b/promql/fuzz.go @@ -12,6 +12,7 @@ // limitations under the License. // Only build when go-fuzz is in use +//go:build gofuzz // +build gofuzz package promql diff --git a/scripts/tools.go b/scripts/tools.go index fda90e16a..52b464911 100644 --- a/scripts/tools.go +++ b/scripts/tools.go @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build tools // +build tools // Package tools tracks dependencies for tools that are required to generate the protobuf code. diff --git a/tsdb/chunks/head_chunks_other.go b/tsdb/chunks/head_chunks_other.go index a1de87370..8b37dd8c2 100644 --- a/tsdb/chunks/head_chunks_other.go +++ b/tsdb/chunks/head_chunks_other.go @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !windows // +build !windows package chunks diff --git a/tsdb/fileutil/dir_unix.go b/tsdb/fileutil/dir_unix.go index 58a77dfc1..db310014e 100644 --- a/tsdb/fileutil/dir_unix.go +++ b/tsdb/fileutil/dir_unix.go @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !windows // +build !windows package fileutil diff --git a/tsdb/fileutil/dir_windows.go b/tsdb/fileutil/dir_windows.go index c123395c0..f67cc74b3 100644 --- a/tsdb/fileutil/dir_windows.go +++ b/tsdb/fileutil/dir_windows.go @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build windows // +build windows package fileutil diff --git a/tsdb/fileutil/flock_solaris.go b/tsdb/fileutil/flock_solaris.go index cfff8e42f..f19c184a4 100644 --- a/tsdb/fileutil/flock_solaris.go +++ b/tsdb/fileutil/flock_solaris.go @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build solaris // +build solaris package fileutil diff --git a/tsdb/fileutil/flock_unix.go b/tsdb/fileutil/flock_unix.go index f6f78d367..c0aeb6948 100644 --- a/tsdb/fileutil/flock_unix.go +++ b/tsdb/fileutil/flock_unix.go @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd // +build darwin dragonfly freebsd linux netbsd openbsd package fileutil diff --git a/tsdb/fileutil/mmap_386.go b/tsdb/fileutil/mmap_386.go index 66b9d3680..591d722d5 100644 --- a/tsdb/fileutil/mmap_386.go +++ b/tsdb/fileutil/mmap_386.go @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build windows // +build windows package fileutil diff --git a/tsdb/fileutil/mmap_amd64.go b/tsdb/fileutil/mmap_amd64.go index 4b523bc67..4c9534e93 100644 --- a/tsdb/fileutil/mmap_amd64.go +++ b/tsdb/fileutil/mmap_amd64.go @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build windows // +build windows package fileutil diff --git a/tsdb/fileutil/mmap_unix.go b/tsdb/fileutil/mmap_unix.go index 043f4d408..9365c62f7 100644 --- a/tsdb/fileutil/mmap_unix.go +++ b/tsdb/fileutil/mmap_unix.go @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !windows && !plan9 // +build !windows,!plan9 package fileutil diff --git a/tsdb/fileutil/preallocate_other.go b/tsdb/fileutil/preallocate_other.go index 162fbc5f7..2c46dd490 100644 --- a/tsdb/fileutil/preallocate_other.go +++ b/tsdb/fileutil/preallocate_other.go @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !linux && !darwin // +build !linux,!darwin package fileutil diff --git a/tsdb/fileutil/sync.go b/tsdb/fileutil/sync.go index 2e64a4088..5bd18b458 100644 --- a/tsdb/fileutil/sync.go +++ b/tsdb/fileutil/sync.go @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !linux && !darwin // +build !linux,!darwin package fileutil diff --git a/tsdb/fileutil/sync_darwin.go b/tsdb/fileutil/sync_darwin.go index 2af1b0f41..155b94459 100644 --- a/tsdb/fileutil/sync_darwin.go +++ b/tsdb/fileutil/sync_darwin.go @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build darwin // +build darwin package fileutil diff --git a/tsdb/fileutil/sync_linux.go b/tsdb/fileutil/sync_linux.go index 8b4fc8268..1c2091ea3 100644 --- a/tsdb/fileutil/sync_linux.go +++ b/tsdb/fileutil/sync_linux.go @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build linux // +build linux package fileutil diff --git a/tsdb/goversion/goversion.go b/tsdb/goversion/goversion.go index 93ff6ef8b..02da2639d 100644 --- a/tsdb/goversion/goversion.go +++ b/tsdb/goversion/goversion.go @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build go1.12 // +build go1.12 // Package goversion enforces the go version supported by the tsdb module. diff --git a/tsdb/wal_test.go b/tsdb/wal_test.go index 9667105e1..fdcd6ce52 100644 --- a/tsdb/wal_test.go +++ b/tsdb/wal_test.go @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !windows // +build !windows package tsdb diff --git a/web/ui/assets_generate.go b/web/ui/assets_generate.go index 1f7870c2f..884329bd0 100644 --- a/web/ui/assets_generate.go +++ b/web/ui/assets_generate.go @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build ignore // +build ignore package main diff --git a/web/ui/ui.go b/web/ui/ui.go index 9ee457801..6b569ca32 100644 --- a/web/ui/ui.go +++ b/web/ui/ui.go @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !builtinassets // +build !builtinassets package ui