Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to go1.21 and golangci 1.60.0, test with go1.23 #104

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.20.x, 1.21.x, 1.22.x]
go-version: [1.21.x, 1.22.x, 1.23.x]
steps:
- name: checkout
uses: actions/checkout@v4
Expand All @@ -32,5 +32,5 @@ jobs:
BUF_TOKEN: ${{ secrets.BUF_TOKEN }}
run: make test
- name: lint
if: matrix.go-version == '1.22.x'
if: matrix.go-version == '1.23.x'
run: make lint
16 changes: 4 additions & 12 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,43 +17,35 @@ linters-settings:
- T any
- i int
- wg sync.WaitGroup
- ok bool
linters:
enable-all: true
disable:
- cyclop # covered by gocyclo
- deadcode # abandoned
- depguard # requires custom config in newer versions to use non-stdlib deps
- exhaustivestruct # replaced by exhaustruct
- execinquery # deprecated in golangci v1.58.0
- exhaustruct # super-spammy and doesn't like idiomatic Go (especially w/ protos)
- funlen # rely on code review to limit function length
- gocognit # dubious "cognitive overhead" quantification
- gofumpt # prefer standard gofmt
- goimports # rely on gci instead
- golint # deprecated by Go team
- gomnd # some unnamed constants are okay
- ifshort # deprecated by author
- inamedparam # convention is not followed
- interfacer # deprecated by author
- ireturn # "accept interfaces, return structs" isn't ironclad
- lll # don't want hard limits for line length
- maintidx # covered by gocyclo
- maligned # readability trumps efficient struct packing
- mnd # some unnamed constants are okay
- nlreturn # generous whitespace violates house style
- nonamedreturns # no bare returns is really what we care about
- nosnakecase # deprecated in https://github.com/golangci/golangci-lint/pull/3065
- scopelint # deprecated by author
- structcheck # abandoned
- testpackage # internal tests are fine
- varcheck # abandoned
- wrapcheck # don't _always_ need to wrap errors
- wsl # generous whitespace violates house style
issues:
exclude-dirs-use-default: false
exclude:
# Don't ban use of fmt.Errorf to create new errors, but the remaining
# checks from err113 are useful.
- "err113: do not define dynamic errors.*"
- "variable name 'ok' is too short"
- "do not define dynamic errors.*"
exclude-rules:
- path: example_test\.go
linters:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LICENSE_IGNORE := -e internal/testdata/
# Set to use a different compiler. For example, `GO=go1.18rc1 make test`.
GO ?= go
BUF_VERSION ?= v1.29.0
GOLANGCI_LINT_VERSION ?= v1.57.1
GOLANGCI_LINT_VERSION ?= v1.60.0

.PHONY: help
help: ## Describe useful make targets
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/bufbuild/prototransform

go 1.20
go 1.21

require (
buf.build/gen/go/bufbuild/reflect/connectrpc/go v1.16.2-20240117202343-bf8f65e8876c.1
Expand Down
12 changes: 6 additions & 6 deletions jitter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,24 @@ func TestAddJitter(t *testing.T) {
testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
var min, max time.Duration
var minPeriod, maxPeriod time.Duration
for i := 0; i < 10_000; i++ {
period := addJitter(testCase.pollingPeriod, testCase.jitter)
require.GreaterOrEqual(t, period, testCase.min)
require.LessOrEqual(t, period, testCase.max)
if i == 0 || period < min {
min = period
if i == 0 || period < minPeriod {
minPeriod = period
}
if i == 0 || period > max {
max = period
if i == 0 || period > maxPeriod {
maxPeriod = period
}
}
// After 10k iterations, with uniform distribution RNG, we could
// probably put much tighter bound on this; but we're a bit lenient
// to make sure we don't see flaky failures in CI. We want to observe
// at least 90% of the effective jitter range.
minVariation := time.Duration(0.9 * float64(testCase.max-testCase.min))
require.GreaterOrEqual(t, max-min, minVariation)
require.GreaterOrEqual(t, maxPeriod-minPeriod, minVariation)
})
}
}
Loading