-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: bwplotka <[email protected]>
- Loading branch information
Showing
7 changed files
with
222 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Go | ||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
name: Unit tests on Go ${{ matrix.go }} ${{ matrix.platform }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.22.x' | ||
- uses: actions/cache@v3 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
- name: Run unit tests. | ||
env: | ||
GOBIN: /tmp/.bin | ||
run: make test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
# This action is synced from https://github.com/prometheus/prometheus | ||
name: golangci-lint | ||
on: | ||
push: | ||
paths: | ||
- "go.sum" | ||
- "go.mod" | ||
- "**.go" | ||
- "scripts/errcheck_excludes.txt" | ||
- ".github/workflows/golangci-lint.yml" | ||
- ".golangci.yml" | ||
pull_request: | ||
|
||
permissions: # added using https://github.com/step-security/secure-repo | ||
contents: read | ||
|
||
jobs: | ||
golangci: | ||
permissions: | ||
contents: read # for actions/checkout to fetch code | ||
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
- name: Install Go | ||
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 | ||
with: | ||
go-version: 1.23.x | ||
- name: Install snmp_exporter/generator dependencies | ||
run: sudo apt-get update && sudo apt-get -y install libsnmp-dev | ||
if: github.repository == 'prometheus/snmp_exporter' | ||
- name: Lint | ||
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0 | ||
with: | ||
args: --verbose ./tools/mtypes/... | ||
version: v1.60.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,135 @@ | ||
# Generally copied from prometheus/prometheus. | ||
run: | ||
deadline: 5m | ||
skip-files: | ||
# Skip autogenerated files. | ||
- ^.*\.(pb|y)\.go$ | ||
timeout: 15m | ||
|
||
output: | ||
sort-results: true | ||
|
||
linters: | ||
enable: | ||
- depguard | ||
- errorlint | ||
- gocritic | ||
- godot | ||
- gofumpt | ||
- goimports | ||
- misspell | ||
- nolintlint | ||
- perfsprint | ||
- predeclared | ||
- revive | ||
- testifylint | ||
- unconvert | ||
- unused | ||
- usestdlibvars | ||
- whitespace | ||
- loggercheck | ||
|
||
issues: | ||
max-issues-per-linter: 0 | ||
max-same-issues: 0 | ||
# The default exclusions are too aggressive. For one, they | ||
# essentially disable any linting on doc comments. We disable | ||
# default exclusions here and add exclusions fitting our codebase | ||
# further down. | ||
exclude-use-default: false | ||
exclude-files: | ||
# Skip autogenerated files. | ||
- ^.*\.(pb|y)\.go$ | ||
exclude-rules: | ||
- linters: | ||
- errcheck | ||
# Taken from the default exclusions (that are otherwise disabled above). | ||
text: Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked | ||
- linters: | ||
- govet | ||
# We use many Seek methods that do not follow the usual pattern. | ||
text: "stdmethods: method Seek.* should have signature Seek" | ||
- path: _test.go | ||
linters: | ||
- errcheck | ||
- linters: | ||
- godot | ||
source: "^// ===" | ||
- linters: | ||
- perfsprint | ||
text: "fmt.Sprintf can be replaced with string concatenation" | ||
linters-settings: | ||
depguard: | ||
rules: | ||
main: | ||
deny: | ||
- pkg: "sync/atomic" | ||
desc: "Use go.uber.org/atomic instead of sync/atomic" | ||
- pkg: "github.com/stretchr/testify/assert" | ||
desc: "Use github.com/stretchr/testify/require instead of github.com/stretchr/testify/assert" | ||
- pkg: "github.com/go-kit/kit/log" | ||
desc: "Use github.com/go-kit/log instead of github.com/go-kit/kit/log" | ||
- pkg: "io/ioutil" | ||
desc: "Use corresponding 'os' or 'io' functions instead." | ||
- pkg: "regexp" | ||
desc: "Use github.com/grafana/regexp instead of regexp" | ||
- pkg: "github.com/pkg/errors" | ||
desc: "Use 'errors' or 'fmt' instead of github.com/pkg/errors" | ||
- pkg: "gzip" | ||
desc: "Use github.com/klauspost/compress instead of gzip" | ||
- pkg: "zlib" | ||
desc: "Use github.com/klauspost/compress instead of zlib" | ||
- pkg: "golang.org/x/exp/slices" | ||
desc: "Use 'slices' instead." | ||
errcheck: | ||
exclude-functions: | ||
# Don't flag lines such as "io.Copy(io.Discard, resp.Body)". | ||
- io.Copy | ||
# The next two are used in HTTP handlers, any error is handled by the server itself. | ||
- io.WriteString | ||
- (net/http.ResponseWriter).Write | ||
# No need to check for errors on server's shutdown. | ||
- (*net/http.Server).Shutdown | ||
# Never check for logger errors. | ||
- (github.com/go-kit/log.Logger).Log | ||
goimports: | ||
local-prefixes: github.com/prometheus/prometheus | ||
gofumpt: | ||
extra-rules: true | ||
perfsprint: | ||
# Optimizes `fmt.Errorf`. | ||
errorf: false | ||
revive: | ||
# By default, revive will enable only the linting rules that are named in the configuration file. | ||
# So, it's needed to explicitly enable all required rules here. | ||
rules: | ||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md | ||
- name: blank-imports | ||
- name: comment-spacings | ||
- name: context-as-argument | ||
arguments: | ||
# Allow functions with test or bench signatures. | ||
- allowTypesBefore: "*testing.T,testing.TB" | ||
- name: context-keys-type | ||
- name: dot-imports | ||
- name: empty-block | ||
- name: error-naming | ||
- name: error-return | ||
- name: error-strings | ||
- name: errorf | ||
- name: exported | ||
- name: increment-decrement | ||
- name: indent-error-flow | ||
- name: package-comments | ||
- name: range | ||
- name: receiver-naming | ||
- name: redefines-builtin-id | ||
- name: superfluous-else | ||
- name: time-naming | ||
- name: unexported-return | ||
- name: unreachable-code | ||
- name: unused-parameter | ||
disabled: true | ||
- name: var-declaration | ||
- name: var-naming | ||
testifylint: | ||
disable: | ||
- float-compare | ||
- go-require | ||
enable-all: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters