Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.circleci: Add config to test against go1.18 #1006

Merged
merged 2 commits into from Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions .circleci/config.yml
@@ -1,6 +1,6 @@
version: 2.1
orbs:
go: circleci/go@0.2.0
go: circleci/go@1.7.1
prometheus: prometheus/prometheus@0.16.0
jobs:
test:
Expand All @@ -17,8 +17,7 @@ jobs:
type: boolean
default: true
docker:
- image: circleci/golang:<< parameters.go_version >>
working_directory: /go/src/github.com/prometheus/client_golang
- image: cimg/go:<< parameters.go_version >>
steps:
- checkout
- when:
Expand Down Expand Up @@ -59,4 +58,10 @@ workflows:
name: go-1-17
go_version: "1.17"
run_lint: true
- test:
name: go-1-18
go_version: "1.18"
run_lint: true
# Style and unused/missing packages are only checked against
# the latest supported Go version.
run_style_and_unused: true
1 change: 1 addition & 0 deletions .github/workflows/golangci-lint.yml
Expand Up @@ -20,6 +20,7 @@ jobs:
- name: install Go
uses: actions/setup-go@v2
with:
# golangci-lint is not read for Go 1.18 (https://github.com/golangci/golangci-lint/issues/2649)
go-version: 1.17.x
- name: Lint
uses: golangci/golangci-lint-action@v3.1.0
Expand Down
10 changes: 8 additions & 2 deletions prometheus/gen_go_collector_metrics_set.go
Expand Up @@ -38,8 +38,10 @@ func main() {
log.Fatal("requires Go version (e.g. go1.17) as an argument")
}
toolVersion := runtime.Version()
if majorVersion := toolVersion[:strings.LastIndexByte(toolVersion, '.')]; majorVersion != os.Args[1] {
log.Fatalf("using Go version %q but expected Go version %q", majorVersion, os.Args[1])
mtv := majorVersion(toolVersion)
mv != majorVersion(os.Args[1])
if mtv != mv {
log.Fatalf("using Go version %q but expected Go version %q", mtv, mv)
}
version, err := parseVersion(os.Args[1])
if err != nil {
Expand Down Expand Up @@ -93,6 +95,10 @@ func parseVersion(s string) (goVersion, error) {
return goVersion(i), err
}

func majorVersion(v string) string {
return v[:strings.LastIndexByte(v, '.')]
}

func rmCardinality() int {
cardinality := 0

Expand Down
41 changes: 41 additions & 0 deletions prometheus/go_collector_metrics_go118_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.