Skip to content

Commit 61a6573

Browse files
authoredJul 4, 2020
Merge pull request aptible#59 from pikapika2020/go-1-14-migration
Migration to `go 1.14` with go modules and latest versions of external dependicies
2 parents 2275476 + 6a0e41f commit 61a6573

File tree

8 files changed

+155
-229
lines changed

8 files changed

+155
-229
lines changed
 

‎.travis.yml

+2-9
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,7 @@ dist: trusty
33

44
language: go
55

6-
go: "1.9"
7-
8-
before_install:
9-
- mkdir -p $HOME/gopath/src/github.com/aptible/supercronic
10-
- rsync -az ${TRAVIS_BUILD_DIR}/ $HOME/gopath/src/github.com/aptible/supercronic/
11-
- export TRAVIS_BUILD_DIR=$HOME/gopath/src/github.com/aptible/supercronic
12-
- cd $TRAVIS_BUILD_DIR
13-
- go get -u github.com/golang/dep/cmd/dep
6+
go: "1.14.4"
147

158
install:
169
- make deps
@@ -22,7 +15,7 @@ jobs:
2215
- stage: test
2316
script:
2417
- make fmt
25-
- git diff --exit-code
18+
- git diff --exit-code ':(exclude)go.sum'
2619
- make test
2720
- stage: build
2821
script:

‎Gopkg.lock

-175
This file was deleted.

‎Gopkg.toml

-39
This file was deleted.

‎Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ SHELL=/bin/bash
33

44
.PHONY: deps
55
deps:
6-
dep ensure -vendor-only
6+
go mod vendor
77

88
.PHONY: build
99
build: $(GOFILES)
1010
go build
1111

1212
.PHONY: unit
1313
unit:
14-
go test $$(go list ./... | grep -v /vendor/)
14+
go test -v -race $$(go list ./... | grep -v /vendor/)
1515
go vet $$(go list ./... | grep -v /vendor/)
1616

1717
.PHONY: integration

‎cron/cron.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,11 @@ func startFunc(wg *sync.WaitGroup, exitCtx context.Context, logger *logrus.Entry
166166

167167
jobWg.Add(1)
168168

169-
runThisJob := func(cronIteration uint64) {
169+
// `nextRun` will be mutated by the next iteration of
170+
// this loop, so we cannot simply capture it into the
171+
// closure here. Instead, we make it a parameter so
172+
// that it gets copied when `runThisJob` is called
173+
runThisJob := func(cronIteration uint64, nextRun time.Time) {
170174
defer jobWg.Done()
171175

172176
jobLogger := logger.WithFields(logrus.Fields{
@@ -177,9 +181,9 @@ func startFunc(wg *sync.WaitGroup, exitCtx context.Context, logger *logrus.Entry
177181
}
178182

179183
if overlapping {
180-
go runThisJob(cronIteration)
184+
go runThisJob(cronIteration, nextRun)
181185
} else {
182-
runThisJob(cronIteration)
186+
runThisJob(cronIteration, nextRun)
183187
}
184188

185189
cronIteration++

‎crontab/crontab.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"regexp"
88
"strings"
99

10-
"github.com/gorhill/cronexpr"
10+
"github.com/krallin/cronexpr"
1111
"github.com/sirupsen/logrus"
1212
)
1313

‎go.mod

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module github.com/aptible/supercronic
2+
3+
go 1.14
4+
5+
require (
6+
github.com/certifi/gocertifi v0.0.0-20200211180108-c7c1fbc02894 // indirect
7+
github.com/evalphobia/logrus_sentry v0.8.2
8+
github.com/getsentry/raven-go v0.2.0 // indirect
9+
github.com/golang/protobuf v1.4.0 // indirect
10+
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
11+
github.com/krallin/cronexpr v0.0.0-20180801141017-b648cc9a908c
12+
github.com/pkg/errors v0.9.1 // indirect
13+
github.com/prometheus/client_golang v1.5.1
14+
github.com/prometheus/procfs v0.0.11 // indirect
15+
github.com/sirupsen/logrus v1.5.0
16+
github.com/stretchr/testify v1.4.0
17+
golang.org/x/sys v0.0.0-20200413165638-669c56c373c4 // indirect
18+
)

0 commit comments

Comments
 (0)