Skip to content

Commit 013873b

Browse files
committed
Run tests in CI
Signed-off-by: Karsten Jeschkies <[email protected]>
1 parent 5d9a043 commit 013873b

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

Diff for: .github/workflows/ci.yml

+11
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ on:
1010
workflow_call:
1111

1212
jobs:
13+
test_go:
14+
name: Go tests
15+
runs-on: ubuntu-latest
16+
container:
17+
image: quay.io/prometheus/golang-builder:1.23-base
18+
steps:
19+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
20+
- uses: prometheus/promci@c3c93a50d581b928af720f0134b2b2dad32a6c41 # v0.4.6
21+
- uses: ./.github/promci/actions/setup_environment
22+
- run: go test ./pkg/...
23+
1324
build:
1425
name: Build for common architectures
1526
runs-on: ubuntu-latest

Diff for: cmd/yace/scraper.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type cachingFactory interface {
3838
Clear()
3939
}
4040

41-
func NewScraper(featureFlags []string) *scraper { //nolint:revive
41+
func NewScraper(featureFlags []string) *scraper {
4242
s := &scraper{
4343
registry: atomic.Pointer[prometheus.Registry]{},
4444
featureFlags: featureFlags,

Diff for: pkg/promutil/prometheus_test.go

+13
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818

1919
"github.com/prometheus/client_golang/prometheus"
2020
dto "github.com/prometheus/client_model/go"
21+
"github.com/prometheus/common/model"
2122
"github.com/stretchr/testify/assert"
2223
"github.com/stretchr/testify/require"
2324
)
@@ -71,6 +72,12 @@ func TestSanitize(t *testing.T) {
7172
}
7273

7374
func TestPromStringTag(t *testing.T) {
75+
originalValidationScheme := model.NameValidationScheme
76+
model.NameValidationScheme = model.LegacyValidation
77+
defer func() {
78+
model.NameValidationScheme = originalValidationScheme
79+
}()
80+
7481
testCases := []struct {
7582
name string
7683
label string
@@ -134,6 +141,12 @@ func TestPromStringTag(t *testing.T) {
134141
}
135142

136143
func TestNewPrometheusCollector_CanReportMetricsAndErrors(t *testing.T) {
144+
originalValidationScheme := model.NameValidationScheme
145+
model.NameValidationScheme = model.LegacyValidation
146+
defer func() {
147+
model.NameValidationScheme = originalValidationScheme
148+
}()
149+
137150
metrics := []*PrometheusMetric{
138151
{
139152
Name: "this*is*not*valid",

0 commit comments

Comments
 (0)