Skip to content

Commit aa9255c

Browse files
authored
Merge branch 'main' into feature/test-validation-with-dots
Signed-off-by: Miroslav Šedivý <[email protected]>
2 parents f220878 + 5ef1ac5 commit aa9255c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1505
-512
lines changed

.circleci/config.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,14 @@ workflows:
9393
matrix:
9494
parameters:
9595
go_version:
96-
- "1.21"
97-
- "1.22"
9896
- "1.23"
97+
- "1.24"
9998
- test-assets:
10099
name: assets-go-<< matrix.go_version >>
101100
matrix:
102101
parameters:
103102
go_version:
104-
- "1.23"
103+
- "1.24"
105104
- style:
106105
name: style
107-
go_version: "1.23"
106+
go_version: "1.24"

.github/workflows/golangci-lint.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,17 @@ jobs:
2525
steps:
2626
- name: Checkout repository
2727
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
28+
with:
29+
persist-credentials: false
2830
- name: Install Go
29-
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
31+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
3032
with:
31-
go-version: 1.23.x
33+
go-version: 1.24.x
3234
- name: Install snmp_exporter/generator dependencies
3335
run: sudo apt-get update && sudo apt-get -y install libsnmp-dev
3436
if: github.repository == 'prometheus/snmp_exporter'
3537
- name: Lint
36-
uses: golangci/golangci-lint-action@ec5d18412c0aeab7936cb16880d708ba2a64e1ae # v6.2.0
38+
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
3739
with:
3840
args: --verbose
39-
version: v1.63.4
41+
version: v2.2.1

.github/workflows/scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
4444
# format to the repository Actions tab.
4545
- name: "Upload artifact"
46-
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
46+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
4747
with:
4848
name: SARIF file
4949
path: results.sarif

.golangci.yml

Lines changed: 177 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,188 @@
1-
issues:
2-
max-issues-per-linter: 0
3-
max-same-issues: 0
1+
version: "2"
42
linters:
3+
# Keep this list sorted alphabetically
54
enable:
6-
- errcheck
5+
- depguard
76
- errorlint
8-
- gofumpt
9-
- goimports
10-
- gosimple
7+
- exptostd
8+
- fatcontext
9+
- gocritic
10+
- godot
1111
- govet
12-
- ineffassign
12+
- loggercheck
1313
- misspell
14+
- nilnesserr
15+
# TODO(bwplotka): Enable once https://github.com/golangci/golangci-lint/issues/3228 is fixed.
16+
# - nolintlint
1417
- perfsprint
18+
- predeclared
1519
- revive
16-
- staticcheck
20+
- sloglint
1721
- testifylint
22+
- unconvert
1823
- unused
19-
linters-settings:
20-
goimports:
21-
local-prefixes: github.com/prometheus/common
22-
perfsprint:
23-
# Optimizes even if it requires an int or uint type cast.
24-
int-conversion: true
25-
# Optimizes into `err.Error()` even if it is only equivalent for non-nil errors.
26-
err-error: true
27-
# Optimizes `fmt.Errorf`.
28-
errorf: true
29-
# Optimizes `fmt.Sprintf` with only one argument.
30-
sprintf1: true
31-
# Optimizes into strings concatenation.
32-
strconcat: false
33-
revive:
24+
- usestdlibvars
25+
- whitespace
26+
exclusions:
27+
generated: lax
28+
presets:
29+
- comments
30+
- common-false-positives
31+
- legacy
32+
- std-error-handling
33+
paths:
34+
- third_party$
35+
- builtin$
36+
- examples$
3437
rules:
35-
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter
36-
- name: unused-parameter
37-
severity: warning
38-
disabled: true
39-
testifylint:
40-
disable:
41-
- go-require
42-
enable-all: true
43-
formatter:
44-
require-f-funcs: true
38+
- linters:
39+
- errcheck
40+
# Taken from the default exclusions in v1.
41+
text: Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
42+
- linters:
43+
- govet
44+
# We use many Seek methods that do not follow the usual pattern.
45+
text: "stdmethods: method Seek.* should have signature Seek"
46+
- linters:
47+
- revive
48+
# We have stopped at some point to write doc comments on exported symbols.
49+
# TODO(beorn7): Maybe we should enforce this again?
50+
text: exported (.+) should have comment( \(or a comment on this block\))? or be unexported
51+
- linters:
52+
- gocritic
53+
text: "appendAssign"
54+
- linters:
55+
- errcheck
56+
path: _test.go
57+
- linters:
58+
- errorlint
59+
path: "tsdb/head_wal.go"
60+
- linters:
61+
- godot
62+
source: "^// ==="
63+
warn-unused: true
64+
settings:
65+
depguard:
66+
rules:
67+
main:
68+
deny:
69+
- pkg: "github.com/go-kit/kit/log"
70+
desc: "Use github.com/go-kit/log instead of github.com/go-kit/kit/log"
71+
- pkg: "io/ioutil"
72+
desc: "Use corresponding 'os' or 'io' functions instead."
73+
- pkg: "github.com/pkg/errors"
74+
desc: "Use 'errors' or 'fmt' instead of github.com/pkg/errors"
75+
- pkg: "gzip"
76+
desc: "Use github.com/klauspost/compress instead of gzip"
77+
- pkg: "zlib"
78+
desc: "Use github.com/klauspost/compress instead of zlib"
79+
- pkg: "golang.org/x/exp/slices"
80+
desc: "Use 'slices' instead."
81+
errcheck:
82+
exclude-functions:
83+
# Don't flag lines such as "io.Copy(io.Discard, resp.Body)".
84+
- io.Copy
85+
# The next two are used in HTTP handlers, any error is handled by the server itself.
86+
- io.WriteString
87+
- (net/http.ResponseWriter).Write
88+
# No need to check for errors on server's shutdown.
89+
- (*net/http.Server).Shutdown
90+
# Never check for rollback errors as Rollback() is called when a previous error was detected.
91+
- (github.com/prometheus/prometheus/storage.Appender).Rollback
92+
govet:
93+
disable:
94+
- shadow
95+
- fieldalignment
96+
enable-all: true
97+
perfsprint:
98+
# Optimizes even if it requires an int or uint type cast.
99+
int-conversion: true
100+
# Optimizes into `err.Error()` even if it is only equivalent for non-nil errors.
101+
err-error: true
102+
# Optimizes `fmt.Errorf`.
103+
errorf: true
104+
# Optimizes `fmt.Sprintf` with only one argument.
105+
sprintf1: true
106+
# Optimizes into strings concatenation.
107+
strconcat: false
108+
revive:
109+
# By default, revive will enable only the linting rules that are named in the configuration file.
110+
# So, it's needed to explicitly enable all required rules here.
111+
rules:
112+
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md
113+
- name: blank-imports
114+
- name: comment-spacings
115+
- name: context-as-argument
116+
arguments:
117+
# Allow functions with test or bench signatures.
118+
- allowTypesBefore: '*testing.T,testing.TB'
119+
- name: context-keys-type
120+
- name: dot-imports
121+
- name: early-return
122+
arguments:
123+
- "preserveScope"
124+
# A lot of false positives: incorrectly identifies channel draining as "empty code block".
125+
# See https://github.com/mgechev/revive/issues/386
126+
- name: empty-block
127+
disabled: true
128+
- name: error-naming
129+
- name: error-return
130+
- name: error-strings
131+
- name: errorf
132+
- name: exported
133+
- name: increment-decrement
134+
- name: indent-error-flow
135+
arguments:
136+
- "preserveScope"
137+
- name: package-comments
138+
# TODO(beorn7): Currently, we have a lot of missing package doc comments. Maybe we should have them.
139+
disabled: true
140+
- name: range
141+
- name: receiver-naming
142+
- name: redefines-builtin-id
143+
- name: superfluous-else
144+
arguments:
145+
- "preserveScope"
146+
- name: time-naming
147+
- name: unexported-return
148+
- name: unreachable-code
149+
- name: unused-parameter
150+
- name: unused-receiver
151+
- name: var-declaration
152+
- name: var-naming
153+
testifylint:
154+
enable-all: true
155+
disable:
156+
- float-compare
157+
- go-require
158+
formatter:
159+
require-f-funcs: true
160+
issues:
161+
max-issues-per-linter: 0
162+
max-same-issues: 0
163+
output:
164+
show-stats: false
45165
run:
46-
timeout: 5m
166+
timeout: 15m
167+
formatters:
168+
enable:
169+
- gci
170+
- gofumpt
171+
- goimports
172+
settings:
173+
gci:
174+
sections:
175+
- standard
176+
- default
177+
- prefix(github.com/prometheus/common)
178+
gofumpt:
179+
extra-rules: true
180+
goimports:
181+
local-prefixes:
182+
- github.com/prometheus/common
183+
exclusions:
184+
generated: lax
185+
paths:
186+
- third_party$
187+
- builtin$
188+
- examples$

CHANGELOG.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Changelog
2+
3+
## main / unreleased
4+
5+
### What's Changed
6+
7+
* [ENHANCEMENT] Create CHANGELOG.md for easier communication of library changes, especially possible breaking changes. https://github.com/prometheus/common/pull/833
8+
9+
## v0.66.1 / 2025-09-05
10+
11+
This release has no functional changes, it just drops the dependencies `github.com/grafana/regexp` and `go.uber.org/atomic` and replaces `gopkg.in/yaml.v2` with `go.yaml.in/yaml/v2` (a drop-in replacement).
12+
13+
### What's Changed
14+
* Revert "Use github.com/grafana/regexp instead of regexp" by @aknuds1 in https://github.com/prometheus/common/pull/835
15+
* Move to supported version of yaml parser by @dims in https://github.com/prometheus/common/pull/834
16+
* Revert "Use go.uber.org/atomic instead of sync/atomic (#825)" by @aknuds1 in https://github.com/prometheus/common/pull/838
17+
18+
**Full Changelog**: https://github.com/prometheus/common/compare/v1.20.99...v0.66.1
19+
20+
## v0.66.0 / 2025-09-02
21+
22+
### ⚠️ Breaking Changes ⚠️
23+
24+
* A default-constructed TextParser will be invalid. It must have a valid `scheme` set, so users should use the NewTextParser function to create a valid TextParser. Otherwise parsing will panic with "Invalid name validation scheme requested: unset".
25+
26+
### What's Changed
27+
* model: add constants for type and unit labels. by @bwplotka in https://github.com/prometheus/common/pull/801
28+
* model.ValidationScheme: Support encoding as YAML by @aknuds1 in https://github.com/prometheus/common/pull/799
29+
* fix(promslog): always print time.Duration values as go duration strings by @tjhop in https://github.com/prometheus/common/pull/798
30+
* Add `ValidationScheme` methods `IsValidMetricName` and `IsValidLabelName` by @aknuds1 in https://github.com/prometheus/common/pull/806
31+
* Fix delimited proto not escaped correctly by @thampiotr in https://github.com/prometheus/common/pull/809
32+
* Decoder: Remove use of global name validation and add validation by @ywwg in https://github.com/prometheus/common/pull/808
33+
* ValidationScheme implements pflag.Value and json.Marshaler/Unmarshaler interfaces by @juliusmh in https://github.com/prometheus/common/pull/807
34+
* expfmt: Add NewTextParser function by @aknuds1 in https://github.com/prometheus/common/pull/816
35+
36+
* Enable the godot linter by @aknuds1 in https://github.com/prometheus/common/pull/821
37+
* Enable usestdlibvars linter by @aknuds1 in https://github.com/prometheus/common/pull/820
38+
* Enable unconvert linter by @aknuds1 in https://github.com/prometheus/common/pull/819
39+
* Enable the fatcontext linter by @aknuds1 in https://github.com/prometheus/common/pull/822
40+
* Enable gocritic linter by @aknuds1 in https://github.com/prometheus/common/pull/818
41+
* Use go.uber.org/atomic instead of sync/atomic by @aknuds1 in https://github.com/prometheus/common/pull/825
42+
* Enable revive rule unused-parameter by @aknuds1 in https://github.com/prometheus/common/pull/824
43+
* Enable revive rules by @aknuds1 in https://github.com/prometheus/common/pull/823
44+
* Synchronize common files from prometheus/prometheus by @prombot in https://github.com/prometheus/common/pull/802
45+
* Synchronize common files from prometheus/prometheus by @prombot in https://github.com/prometheus/common/pull/803
46+
* Sync .golangci.yml with prometheus/prometheus by @aknuds1 in https://github.com/prometheus/common/pull/817
47+
* ci: update upload-actions by @ywwg in https://github.com/prometheus/common/pull/814
48+
* docs: fix typo in expfmt.Negotiate by @wmcram in https://github.com/prometheus/common/pull/813
49+
* build(deps): bump golang.org/x/net from 0.40.0 to 0.41.0 by @dependabot[bot] in https://github.com/prometheus/common/pull/800
50+
* build(deps): bump golang.org/x/net from 0.41.0 to 0.42.0 by @dependabot[bot] in https://github.com/prometheus/common/pull/810
51+
* build(deps): bump github.com/stretchr/testify from 1.10.0 to 1.11.1 in /assets by @dependabot[bot] in https://github.com/prometheus/common/pull/826
52+
* build(deps): bump google.golang.org/protobuf from 1.36.6 to 1.36.8 by @dependabot[bot] in https://github.com/prometheus/common/pull/830
53+
* build(deps): bump golang.org/x/net from 0.42.0 to 0.43.0 by @dependabot[bot] in https://github.com/prometheus/common/pull/829
54+
* build(deps): bump github.com/stretchr/testify from 1.10.0 to 1.11.1 by @dependabot[bot] in https://github.com/prometheus/common/pull/827
55+
56+
### New Contributors
57+
* @aknuds1 made their first contribution in https://github.com/prometheus/common/pull/799
58+
* @thampiotr made their first contribution in https://github.com/prometheus/common/pull/809
59+
* @wmcram made their first contribution in https://github.com/prometheus/common/pull/813
60+
* @juliusmh made their first contribution in https://github.com/prometheus/common/pull/807
61+

Makefile.common

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_
6161
SKIP_GOLANGCI_LINT :=
6262
GOLANGCI_LINT :=
6363
GOLANGCI_LINT_OPTS ?=
64-
GOLANGCI_LINT_VERSION ?= v1.63.4
64+
GOLANGCI_LINT_VERSION ?= v2.2.1
65+
GOLANGCI_FMT_OPTS ?=
6566
# golangci-lint only supports linux, darwin and windows platforms on i386/amd64/arm64.
6667
# windows isn't included here because of the path separator being different.
6768
ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin))
@@ -138,7 +139,7 @@ common-deps:
138139
update-go-deps:
139140
@echo ">> updating Go dependencies"
140141
@for m in $$($(GO) list -mod=readonly -m -f '{{ if and (not .Indirect) (not .Main)}}{{.Path}}{{end}}' all); do \
141-
$(GO) get -d $$m; \
142+
$(GO) get $$m; \
142143
done
143144
$(GO) mod tidy
144145

@@ -156,9 +157,13 @@ $(GOTEST_DIR):
156157
@mkdir -p $@
157158

158159
.PHONY: common-format
159-
common-format:
160+
common-format: $(GOLANGCI_LINT)
160161
@echo ">> formatting code"
161162
$(GO) fmt $(pkgs)
163+
ifdef GOLANGCI_LINT
164+
@echo ">> formatting code with golangci-lint"
165+
$(GOLANGCI_LINT) fmt $(GOLANGCI_FMT_OPTS)
166+
endif
162167

163168
.PHONY: common-vet
164169
common-vet:
@@ -248,8 +253,8 @@ $(PROMU):
248253
cp $(PROMU_TMP)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM)/promu $(FIRST_GOPATH)/bin/promu
249254
rm -r $(PROMU_TMP)
250255

251-
.PHONY: proto
252-
proto:
256+
.PHONY: common-proto
257+
common-proto:
253258
@echo ">> generating code from proto files"
254259
@./scripts/genproto.sh
255260

0 commit comments

Comments
 (0)