Skip to content

Commit 5d78aaa

Browse files
authored
.circleci: Add config to test against go1.18 (#1006)
* Add config to test against go1.18 Signed-off-by: Kemal Akkoyun <[email protected]> * Try to fix circleci Signed-off-by: Kemal Akkoyun <[email protected]>
1 parent 157170d commit 5d78aaa

File tree

4 files changed

+58
-5
lines changed

4 files changed

+58
-5
lines changed

.circleci/config.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version: 2.1
22
orbs:
3-
go: circleci/go@0.2.0
3+
go: circleci/go@1.7.1
44
prometheus: prometheus/[email protected]
55
jobs:
66
test:
@@ -17,8 +17,7 @@ jobs:
1717
type: boolean
1818
default: true
1919
docker:
20-
- image: circleci/golang:<< parameters.go_version >>
21-
working_directory: /go/src/github.com/prometheus/client_golang
20+
- image: cimg/go:<< parameters.go_version >>
2221
steps:
2322
- checkout
2423
- when:
@@ -59,4 +58,10 @@ workflows:
5958
name: go-1-17
6059
go_version: "1.17"
6160
run_lint: true
61+
- test:
62+
name: go-1-18
63+
go_version: "1.18"
64+
run_lint: true
65+
# Style and unused/missing packages are only checked against
66+
# the latest supported Go version.
6267
run_style_and_unused: true

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
- name: install Go
2121
uses: actions/setup-go@v2
2222
with:
23+
# golangci-lint is not read for Go 1.18 (https://github.com/golangci/golangci-lint/issues/2649)
2324
go-version: 1.17.x
2425
- name: Lint
2526
uses: golangci/[email protected]

prometheus/gen_go_collector_metrics_set.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ func main() {
3838
log.Fatal("requires Go version (e.g. go1.17) as an argument")
3939
}
4040
toolVersion := runtime.Version()
41-
if majorVersion := toolVersion[:strings.LastIndexByte(toolVersion, '.')]; majorVersion != os.Args[1] {
42-
log.Fatalf("using Go version %q but expected Go version %q", majorVersion, os.Args[1])
41+
mtv := majorVersion(toolVersion)
42+
mv != majorVersion(os.Args[1])
43+
if mtv != mv {
44+
log.Fatalf("using Go version %q but expected Go version %q", mtv, mv)
4345
}
4446
version, err := parseVersion(os.Args[1])
4547
if err != nil {
@@ -93,6 +95,10 @@ func parseVersion(s string) (goVersion, error) {
9395
return goVersion(i), err
9496
}
9597

98+
func majorVersion(v string) string {
99+
return v[:strings.LastIndexByte(v, '.')]
100+
}
101+
96102
func rmCardinality() int {
97103
cardinality := 0
98104

prometheus/go_collector_metrics_go118_test.go

Lines changed: 41 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)