Skip to content

Commit a902616

Browse files
authored
Update for Go 1.26 (#883)
* Update minimum Go version to 1.26.0. * Update tests for Go 1.26.x. * Migrate to GitHub Actions. * Ignore package naming issues. Signed-off-by: SuperQ <superq@gmail.com>
1 parent afbd47d commit a902616

7 files changed

Lines changed: 200 additions & 107 deletions

File tree

.circleci/config.yml

Lines changed: 23 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,33 @@
11
---
2+
# Prometheus has switched to GitHub action.
3+
# Circle CI is not disabled repository-wise so that previous pull requests
4+
# continue working.
5+
# This file does not generate any CircleCI workflow.
6+
27
version: 2.1
38

4-
orbs:
5-
go: circleci/go@1.7.1
9+
executors:
10+
golang:
11+
docker:
12+
- image: busybox
613

714
jobs:
8-
test:
9-
parameters:
10-
go_version:
11-
type: string
12-
use_gomod_cache:
13-
type: boolean
14-
default: true
15-
docker:
16-
- image: cimg/go:<< parameters.go_version >>
17-
environment:
18-
# Override Go 1.18 security deprecations.
19-
GODEBUG: "x509sha1=1,tls10default=1"
20-
steps:
21-
- checkout
22-
- when:
23-
condition: << parameters.use_gomod_cache >>
24-
steps:
25-
- go/load-cache:
26-
key: v1-go<< parameters.go_version >>
27-
- run: make test
28-
- when:
29-
condition: << parameters.use_gomod_cache >>
30-
steps:
31-
- go/save-cache:
32-
key: v1-go<< parameters.go_version >>
33-
- store_test_results:
34-
path: test-results
35-
test-assets:
36-
parameters:
37-
go_version:
38-
type: string
39-
use_gomod_cache:
40-
type: boolean
41-
default: true
42-
docker:
43-
- image: cimg/go:<< parameters.go_version >>
44-
steps:
45-
- checkout
46-
- when:
47-
condition: << parameters.use_gomod_cache >>
48-
steps:
49-
- go/load-cache:
50-
key: v1-go<< parameters.go_version >>
51-
- run: make -C assets test
52-
- when:
53-
condition: << parameters.use_gomod_cache >>
54-
steps:
55-
- go/save-cache:
56-
key: v1-go<< parameters.go_version >>
57-
- store_test_results:
58-
path: test-results
59-
style:
60-
parameters:
61-
go_version:
62-
type: string
63-
use_gomod_cache:
64-
type: boolean
65-
default: true
66-
docker:
67-
- image: cimg/go:<< parameters.go_version >>
15+
noopjob:
16+
executor: golang
17+
6818
steps:
69-
- checkout
70-
- when:
71-
condition: << parameters.use_gomod_cache >>
72-
steps:
73-
- go/load-cache:
74-
key: v1-go<< parameters.go_version >>
75-
- run: make style
76-
- run: make -C assets style
77-
- run: make check-go-mod-version
78-
- when:
79-
condition: << parameters.use_gomod_cache >>
80-
steps:
81-
- go/save-cache:
82-
key: v1-go<< parameters.go_version >>
83-
- store_test_results:
84-
path: test-results
19+
- run:
20+
command: "true"
8521

8622
workflows:
8723
version: 2
88-
tests:
24+
common:
8925
jobs:
90-
# Supported Go versions are synced with github.com/prometheus/client_golang.
91-
- test:
92-
name: go-<< matrix.go_version >>
93-
matrix:
94-
parameters:
95-
go_version:
96-
- "1.24"
97-
- "1.25"
98-
- test-assets:
99-
name: assets-go-<< matrix.go_version >>
100-
matrix:
101-
parameters:
102-
go_version:
103-
- "1.25"
104-
- style:
105-
name: style
106-
go_version: "1.25"
26+
- noopjob
27+
triggers:
28+
- schedule:
29+
cron: "0 0 30 2 *"
30+
filters:
31+
branches:
32+
only:
33+
- master

.github/workflows/ci.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: CI
2+
on:
3+
pull_request:
4+
push:
5+
branches: [main, 'release-*']
6+
tags: ['v*']
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
lint:
13+
name: Lint
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
18+
- name: Install Go
19+
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
20+
with:
21+
go-version: 1.26.x
22+
- run: make check_license
23+
- run: make style
24+
- run: make -C assets style
25+
- run: make check-go-mod-version
26+
27+
test-assets:
28+
name: Test Assets
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
33+
- name: Install Go
34+
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
35+
with:
36+
go-version: 1.26.x
37+
- run: make -C assets test
38+
39+
test:
40+
name: Test
41+
runs-on: ubuntu-latest
42+
env:
43+
# Override Go 1.18 security deprecations.
44+
GODEBUG: "x509sha1=1,tls10default=1"
45+
strategy:
46+
matrix:
47+
go:
48+
- 1.25.x
49+
- 1.26.x
50+
steps:
51+
- name: Checkout repository
52+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
53+
- name: Install Go
54+
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
55+
with:
56+
go-version: ${{ matrix.go }}
57+
- run: make test

.github/workflows/golangci-lint.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
name: golangci-lint
44
on:
55
push:
6+
branches: [main, master, 'release-*']
67
paths:
78
- "go.sum"
89
- "go.mod"
910
- "**.go"
1011
- "scripts/errcheck_excludes.txt"
1112
- ".github/workflows/golangci-lint.yml"
1213
- ".golangci.yml"
14+
tags: ['v*']
1315
pull_request:
1416

1517
permissions: # added using https://github.com/step-security/secure-repo
@@ -24,13 +26,13 @@ jobs:
2426
runs-on: ubuntu-latest
2527
steps:
2628
- name: Checkout repository
27-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
29+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2830
with:
2931
persist-credentials: false
3032
- name: Install Go
3133
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
3234
with:
33-
go-version: 1.25.x
35+
go-version: 1.26.x
3436
- name: Install snmp_exporter/generator dependencies
3537
run: sudo apt-get update && sudo apt-get -y install libsnmp-dev
3638
if: github.repository == 'prometheus/snmp_exporter'

.golangci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ linters:
133133
- name: unused-receiver
134134
- name: var-declaration
135135
- name: var-naming
136+
# TODO(SuperQ): See: https://github.com/prometheus/prometheus/issues/17766
137+
arguments:
138+
- []
139+
- []
140+
- - skip-package-name-checks: true
136141
testifylint:
137142
enable-all: true
138143
disable:
@@ -162,4 +167,4 @@ formatters:
162167
extra-rules: true
163168
goimports:
164169
local-prefixes:
165-
- github.com/prometheus/common
170+
- github.com/prometheus/common

0 commit comments

Comments
 (0)