Skip to content

Commit

Permalink
.circleci: Add config to test against go1.18 (#1006)
Browse files Browse the repository at this point in the history
* Add config to test against go1.18

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>

* Try to fix circleci

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
  • Loading branch information
kakkoyun committed Mar 17, 2022
1 parent 157170d commit 5d78aaa
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 5 deletions.
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.

0 comments on commit 5d78aaa

Please sign in to comment.