From 90e914f87c24b0910d242d3c1942e2a6671035de Mon Sep 17 00:00:00 2001 From: John Roesler Date: Tue, 28 Jan 2025 15:28:32 -0600 Subject: [PATCH 1/2] go to 1.21, upgrade deps --- .github/workflows/go_test.yml | 2 +- .golangci.yaml | 4 +--- example_test.go | 2 +- go.mod | 6 +++--- go.sum | 8 ++++---- scheduler_test.go | 32 ++++++++++++++++---------------- 6 files changed, 26 insertions(+), 28 deletions(-) diff --git a/.github/workflows/go_test.yml b/.github/workflows/go_test.yml index 7bd9bd29..60f8024c 100644 --- a/.github/workflows/go_test.yml +++ b/.github/workflows/go_test.yml @@ -12,9 +12,9 @@ strategy: matrix: go-version: - - "1.20" - "1.21" - "1.22" + - "1.23" name: lint and test runs-on: ubuntu-latest steps: diff --git a/.golangci.yaml b/.golangci.yaml index 9d6ae5d7..e4f0cc10 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -20,10 +20,9 @@ issues: linters: enable: - bodyclose - - exportloopref + - copyloopvar - gofumpt - goimports - - gosec - gosimple - govet - ineffassign @@ -39,6 +38,5 @@ output: - format: colored-line-number print-issued-lines: true print-linter-name: true - uniq-by-line: true path-prefix: "" sort-results: true diff --git a/example_test.go b/example_test.go index 477a9930..7b9fc067 100644 --- a/example_test.go +++ b/example_test.go @@ -606,7 +606,7 @@ func ExampleWithClock() { ), ) s.Start() - fakeClock.BlockUntil(1) + _ = fakeClock.BlockUntilContext(context.Background(), 1) fakeClock.Advance(time.Second * 5) wg.Wait() _ = s.StopJobs() diff --git a/go.mod b/go.mod index 5b0a680f..cc4d9a82 100644 --- a/go.mod +++ b/go.mod @@ -1,14 +1,14 @@ module github.com/go-co-op/gocron/v2 -go 1.20 +go 1.21.0 require ( github.com/google/uuid v1.6.0 - github.com/jonboulle/clockwork v0.4.0 + github.com/jonboulle/clockwork v0.5.0 github.com/robfig/cron/v3 v3.0.1 github.com/stretchr/testify v1.10.0 go.uber.org/goleak v1.3.0 - golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 + golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa ) require ( diff --git a/go.sum b/go.sum index 34ae466e..ba9734f1 100644 --- a/go.sum +++ b/go.sum @@ -3,8 +3,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/jonboulle/clockwork v0.4.0 h1:p4Cf1aMWXnXAUh8lVfewRBx1zaTSYKrKMF2g3ST4RZ4= -github.com/jonboulle/clockwork v0.4.0/go.mod h1:xgRqUGwRcjKCO1vbZUEtSLrqKoPSsUpK7fnezOII0kc= +github.com/jonboulle/clockwork v0.5.0 h1:Hyh9A8u51kptdkR+cqRpT1EebBwTn1oK9YfGYbdFz6I= +github.com/jonboulle/clockwork v0.5.0/go.mod h1:3mZlmanh0g2NDKO5TWZVJAfofYk64M7XN3SzBPjZF60= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -19,8 +19,8 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= -golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY= -golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= +golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa h1:ELnwvuAXPNtPk1TJRuGkI9fDTwym6AYBu0qzT8AcHdI= +golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/scheduler_test.go b/scheduler_test.go index 047401b7..b9c591ba 100644 --- a/scheduler_test.go +++ b/scheduler_test.go @@ -1426,13 +1426,13 @@ func TestScheduler_OneTimeJob_DoesNotCleanupNext(t *testing.T) { tests := []struct { name string runAt time.Time - fakeClock clockwork.FakeClock + fakeClock *clockwork.FakeClock assertErr require.ErrorAssertionFunc // asserts things about schedules, advance time and perform new assertions advanceAndAsserts []func( t *testing.T, j Job, - clock clockwork.FakeClock, + clock *clockwork.FakeClock, runs *atomic.Uint32, ) }{ @@ -1440,8 +1440,8 @@ func TestScheduler_OneTimeJob_DoesNotCleanupNext(t *testing.T) { name: "exhausted run do does not cleanup next item", runAt: time.Date(2024, time.April, 22, 4, 5, 0, 0, time.UTC), fakeClock: clockwork.NewFakeClockAt(schedulerStartTime), - advanceAndAsserts: []func(t *testing.T, j Job, clock clockwork.FakeClock, runs *atomic.Uint32){ - func(t *testing.T, j Job, clock clockwork.FakeClock, runs *atomic.Uint32) { + advanceAndAsserts: []func(t *testing.T, j Job, clock *clockwork.FakeClock, runs *atomic.Uint32){ + func(t *testing.T, j Job, clock *clockwork.FakeClock, runs *atomic.Uint32) { require.Equal(t, uint32(0), runs.Load()) // last not initialized @@ -2377,13 +2377,13 @@ func TestScheduler_AtTimesJob(t *testing.T) { tests := []struct { name string atTimes []time.Time - fakeClock clockwork.FakeClock + fakeClock *clockwork.FakeClock assertErr require.ErrorAssertionFunc // asserts things about schedules, advance time and perform new assertions advanceAndAsserts []func( t *testing.T, j Job, - clock clockwork.FakeClock, + clock *clockwork.FakeClock, runs *atomic.Uint32, ) }{ @@ -2407,8 +2407,8 @@ func TestScheduler_AtTimesJob(t *testing.T) { name: "one run 1 millisecond in the future", atTimes: []time.Time{n.Add(1 * time.Millisecond)}, fakeClock: clockwork.NewFakeClockAt(n), - advanceAndAsserts: []func(t *testing.T, j Job, clock clockwork.FakeClock, runs *atomic.Uint32){ - func(t *testing.T, j Job, clock clockwork.FakeClock, runs *atomic.Uint32) { + advanceAndAsserts: []func(t *testing.T, j Job, clock *clockwork.FakeClock, runs *atomic.Uint32){ + func(t *testing.T, j Job, clock *clockwork.FakeClock, runs *atomic.Uint32) { require.Equal(t, uint32(0), runs.Load()) // last not initialized @@ -2442,8 +2442,8 @@ func TestScheduler_AtTimesJob(t *testing.T) { name: "one run in the past and one in the future", atTimes: []time.Time{n.Add(-1 * time.Millisecond), n.Add(1 * time.Millisecond)}, fakeClock: clockwork.NewFakeClockAt(n), - advanceAndAsserts: []func(t *testing.T, j Job, clock clockwork.FakeClock, runs *atomic.Uint32){ - func(t *testing.T, j Job, clock clockwork.FakeClock, runs *atomic.Uint32) { + advanceAndAsserts: []func(t *testing.T, j Job, clock *clockwork.FakeClock, runs *atomic.Uint32){ + func(t *testing.T, j Job, clock *clockwork.FakeClock, runs *atomic.Uint32) { require.Equal(t, uint32(0), runs.Load()) // last not initialized @@ -2473,8 +2473,8 @@ func TestScheduler_AtTimesJob(t *testing.T) { name: "two runs in the future - order is maintained even if times are provided out of order", atTimes: []time.Time{n.Add(3 * time.Millisecond), n.Add(1 * time.Millisecond)}, fakeClock: clockwork.NewFakeClockAt(n), - advanceAndAsserts: []func(t *testing.T, j Job, clock clockwork.FakeClock, runs *atomic.Uint32){ - func(t *testing.T, j Job, clock clockwork.FakeClock, runs *atomic.Uint32) { + advanceAndAsserts: []func(t *testing.T, j Job, clock *clockwork.FakeClock, runs *atomic.Uint32){ + func(t *testing.T, j Job, clock *clockwork.FakeClock, runs *atomic.Uint32) { require.Equal(t, uint32(0), runs.Load()) // last not initialized @@ -2503,7 +2503,7 @@ func TestScheduler_AtTimesJob(t *testing.T) { require.Equal(t, n.Add(3*time.Millisecond), nextRunAt) }, - func(t *testing.T, j Job, clock clockwork.FakeClock, runs *atomic.Uint32) { + func(t *testing.T, j Job, clock *clockwork.FakeClock, runs *atomic.Uint32) { // advance and eventually run clock.Advance(2 * time.Millisecond) require.Eventually(t, func() bool { @@ -2526,8 +2526,8 @@ func TestScheduler_AtTimesJob(t *testing.T) { name: "two runs in the future - order is maintained even if times are provided out of order - deduplication", atTimes: []time.Time{n.Add(3 * time.Millisecond), n.Add(1 * time.Millisecond), n.Add(1 * time.Millisecond), n.Add(3 * time.Millisecond)}, fakeClock: clockwork.NewFakeClockAt(n), - advanceAndAsserts: []func(t *testing.T, j Job, clock clockwork.FakeClock, runs *atomic.Uint32){ - func(t *testing.T, j Job, clock clockwork.FakeClock, runs *atomic.Uint32) { + advanceAndAsserts: []func(t *testing.T, j Job, clock *clockwork.FakeClock, runs *atomic.Uint32){ + func(t *testing.T, j Job, clock *clockwork.FakeClock, runs *atomic.Uint32) { require.Equal(t, uint32(0), runs.Load()) // last not initialized @@ -2556,7 +2556,7 @@ func TestScheduler_AtTimesJob(t *testing.T) { require.Equal(t, n.Add(3*time.Millisecond), nextRunAt) }, - func(t *testing.T, j Job, clock clockwork.FakeClock, runs *atomic.Uint32) { + func(t *testing.T, j Job, clock *clockwork.FakeClock, runs *atomic.Uint32) { // advance and eventually run clock.Advance(2 * time.Millisecond) require.Eventually(t, func() bool { From 0cd70c6096f0b2838bee6850159e07bdcc66b5b0 Mon Sep 17 00:00:00 2001 From: John Roesler Date: Tue, 28 Jan 2025 21:22:25 -0600 Subject: [PATCH 2/2] test without 1.23 --- .github/workflows/go_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go_test.yml b/.github/workflows/go_test.yml index 60f8024c..b951abae 100644 --- a/.github/workflows/go_test.yml +++ b/.github/workflows/go_test.yml @@ -14,7 +14,7 @@ go-version: - "1.21" - "1.22" - - "1.23" +# - "1.23" name: lint and test runs-on: ubuntu-latest steps: