mirror of https://github.com/go-co-op/gocron.git
re-enable goleak detection in ci (#832)
* re-enable goleak detection in ci * fix version string * re-add go 1.23
This commit is contained in:
parent
129f89c569
commit
08b53d788a
|
|
@ -14,7 +14,7 @@
|
|||
go-version:
|
||||
- "1.21"
|
||||
- "1.22"
|
||||
# - "1.23"
|
||||
- "1.23"
|
||||
name: lint and test
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
|
@ -25,8 +25,8 @@
|
|||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v6.5.0
|
||||
uses: golangci/golangci-lint-action@v6.3.2
|
||||
with:
|
||||
version: v1.59.1
|
||||
version: v1.61.0
|
||||
- name: test
|
||||
run: make test_ci
|
||||
|
|
|
|||
2
Makefile
2
Makefile
|
|
@ -16,7 +16,7 @@ test_coverage:
|
|||
@go test -race -v $(GO_FLAGS) -count=1 -coverprofile=coverage.out -covermode=atomic $(GO_PKGS)
|
||||
|
||||
test_ci:
|
||||
@TEST_ENV=ci go test -race -v $(GO_FLAGS) -count=1 $(GO_PKGS)
|
||||
@go test -race -v $(GO_FLAGS) -count=1 $(GO_PKGS)
|
||||
|
||||
mocks:
|
||||
@go generate ./...
|
||||
|
|
|
|||
|
|
@ -362,6 +362,7 @@ func TestScheduler_StopTimeout(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestScheduler_StopLongRunningJobs(t *testing.T) {
|
||||
defer verifyNoGoroutineLeaks(t)
|
||||
t.Run("start, run job, stop jobs before job is completed", func(t *testing.T) {
|
||||
s := newTestScheduler(t,
|
||||
WithStopTimeout(50*time.Millisecond),
|
||||
|
|
@ -393,6 +394,8 @@ func TestScheduler_StopLongRunningJobs(t *testing.T) {
|
|||
// the running job is canceled, no unexpected timeout error
|
||||
require.NoError(t, s.StopJobs())
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
||||
require.NoError(t, s.Shutdown())
|
||||
})
|
||||
t.Run("start, run job, stop jobs before job is completed - manual context cancel", func(t *testing.T) {
|
||||
s := newTestScheduler(t,
|
||||
|
|
@ -428,6 +431,8 @@ func TestScheduler_StopLongRunningJobs(t *testing.T) {
|
|||
cancel()
|
||||
require.NoError(t, s.StopJobs())
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
||||
require.NoError(t, s.Shutdown())
|
||||
})
|
||||
t.Run("start, run job, stop jobs before job is completed - manual context cancel WithContext", func(t *testing.T) {
|
||||
s := newTestScheduler(t,
|
||||
|
|
@ -464,18 +469,18 @@ func TestScheduler_StopLongRunningJobs(t *testing.T) {
|
|||
cancel()
|
||||
require.NoError(t, s.StopJobs())
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
||||
require.NoError(t, s.Shutdown())
|
||||
})
|
||||
}
|
||||
|
||||
func TestScheduler_StopAndStartLongRunningJobs(t *testing.T) {
|
||||
defer verifyNoGoroutineLeaks(t)
|
||||
t.Run("start, run job, stop jobs before job is completed", func(t *testing.T) {
|
||||
s := newTestScheduler(t,
|
||||
WithStopTimeout(50*time.Millisecond),
|
||||
)
|
||||
|
||||
restart := false
|
||||
restartP := &restart
|
||||
|
||||
_, err := s.NewJob(
|
||||
DurationJob(
|
||||
50*time.Millisecond,
|
||||
|
|
@ -484,14 +489,7 @@ func TestScheduler_StopAndStartLongRunningJobs(t *testing.T) {
|
|||
func(ctx context.Context) {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
if *restartP {
|
||||
t.Fatal("job should not been canceled after restart")
|
||||
}
|
||||
case <-time.After(100 * time.Millisecond):
|
||||
if !*restartP {
|
||||
t.Fatal("job can not been canceled")
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
),
|
||||
|
|
@ -508,11 +506,10 @@ func TestScheduler_StopAndStartLongRunningJobs(t *testing.T) {
|
|||
// the running job is canceled, no unexpected timeout error
|
||||
require.NoError(t, s.StopJobs())
|
||||
|
||||
*restartP = true
|
||||
|
||||
s.Start()
|
||||
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
require.NoError(t, s.Shutdown())
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue