Skip to content

Commit 76c3ae1

Browse files
authored
Update CI (#183)
* Split golangci-lint to separate action file so it's auto-updated. * Update Go version in CI. * Update minimum Go version. * Remove deprecated rand.Seed(). Signed-off-by: SuperQ <[email protected]>
1 parent 342e23e commit 76c3ae1

File tree

5 files changed

+49
-27
lines changed

5 files changed

+49
-27
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,21 @@
1-
---
21
name: CI
3-
on: # yamllint disable-line rule:truthy
4-
pull_request:
2+
on:
53
push:
64
jobs:
75
test:
86
name: Test
97
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
go_version: ["1.20", "1.21"]
1011
container:
11-
image: quay.io/prometheus/golang-builder:1.20-base
12+
image: quay.io/prometheus/golang-builder:${{ matrix.go_version }}-base
13+
env:
14+
# Override Go 1.18 security deprecations.
15+
GODEBUG: "x509sha1=1,tls10default=1"
1216
steps:
13-
- uses: actions/checkout@v3
17+
- name: Checkout repository
18+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
1419
- uses: prometheus/[email protected]
1520
- uses: ./.github/promci/actions/setup_environment
1621
- run: make test
17-
18-
golangci:
19-
name: golangci-lint
20-
runs-on: ubuntu-latest
21-
steps:
22-
- name: Checkout repository
23-
uses: actions/checkout@v3
24-
- name: Install Go
25-
uses: actions/setup-go@v3
26-
with:
27-
go-version: '1.20'
28-
- name: Lint
29-
uses: golangci/[email protected]
30-
with:
31-
version: v1.51.2

.github/workflows/golangci-lint.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
# This action is synced from https://github.com/prometheus/prometheus
3+
name: golangci-lint
4+
on:
5+
push:
6+
paths:
7+
- "go.sum"
8+
- "go.mod"
9+
- "**.go"
10+
- "scripts/errcheck_excludes.txt"
11+
- ".github/workflows/golangci-lint.yml"
12+
- ".golangci.yml"
13+
pull_request:
14+
15+
jobs:
16+
golangci:
17+
name: lint
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
22+
- name: install Go
23+
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
24+
with:
25+
go-version: 1.21.x
26+
- name: Install snmp_exporter/generator dependencies
27+
run: sudo apt-get update && sudo apt-get -y install libsnmp-dev
28+
if: github.repository == 'prometheus/snmp_exporter'
29+
- name: Lint
30+
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0
31+
with:
32+
version: v1.54.2

.golangci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,9 @@ linters-settings:
1717
- (net/http.ResponseWriter).Write
1818
# Never check for logger errors.
1919
- (github.com/go-kit/log.Logger).Log
20-
20+
revive:
21+
rules:
22+
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter
23+
- name: unused-parameter
24+
severity: warning
25+
disabled: true

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/prometheus/exporter-toolkit
22

3-
go 1.18
3+
go 1.20
44

55
require (
66
github.com/alecthomas/kingpin/v2 v2.4.0

web/cache.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,10 @@ package web
1818
import (
1919
weakrand "math/rand"
2020
"sync"
21-
"time"
2221
)
2322

2423
var cacheSize = 100
2524

26-
func init() {
27-
weakrand.Seed(time.Now().UnixNano())
28-
}
29-
3025
type cache struct {
3126
cache map[string]bool
3227
mtx sync.Mutex

0 commit comments

Comments
 (0)