Repository: go-co-op/gocron
Pull request #764 (2024-08-05 18:24:17)

Bump golangci/golangci-lint-action from 6.0.1 to 6.1.0
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 6.0.1 to 6.1.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/golangci/golangci-lint-action/releases">golangci/golangci-lint-action's releases</a>.</em></p>
<blockquote>
<h2>v6.1.0</h2>
<!-- raw HTML omitted -->
<h2>What's Changed</h2>
<h3>Changes</h3>
<ul>
<li>feat: allow to skip golangci-lint installation by <a href="https://github.com/ldez"><code>@​ldez</code></a> in <a href="https://redirect.github.com/golangci/golangci-lint-action/pull/1079">golangci/golangci-lint-action#1079</a></li>
</ul>
<h3>Documentation</h3>
<ul>
<li>docs: add Go workspace examples by <a href="https://github.com/ldez"><code>@​ldez</code></a> in <a href="https://redirect.github.com/golangci/golangci-lint-action/pull/1064">golangci/golangci-lint-action#1064</a></li>
</ul>
<h3>Dependencies</h3>
<ul>
<li>build(deps): bump <code>@​types/node</code> from 20.12.8 to 20.12.11 by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/golangci/golangci-lint-action/pull/1041">golangci/golangci-lint-action#1041</a></li>
<li>build(deps-dev): bump <code>@​typescript-eslint/eslint-plugin</code> from 7.8.0 to 7.9.0 by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/golangci/golangci-lint-action/pull/1042">golangci/golangci-lint-action#1042</a></li>
<li>build(deps): bump <code>@​types/node</code> from 20.12.11 to 20.12.12 by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/golangci/golangci-lint-action/pull/1043">golangci/golangci-lint-action#1043</a></li>
<li>build(deps-dev): bump <code>@​typescript-eslint/parser</code> from 7.8.0 to 7.9.0 by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/golangci/golangci-lint-action/pull/1044">golangci/golangci-lint-action#1044</a></li>
<li>build(deps-dev): bump the dev-dependencies group with 2 updates by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/golangci/golangci-lint-action/pull/1047">golangci/golangci-lint-action#1047</a></li>
<li>build(deps): bump <code>@​types/node</code> from 20.12.12 to 20.14.0 in the dependencies group by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/golangci/golangci-lint-action/pull/1051">golangci/golangci-lint-action#1051</a></li>
<li>build(deps-dev): bump the dev-dependencies group across 1 directory with 3 updates by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/golangci/golangci-lint-action/pull/1053">golangci/golangci-lint-action#1053</a></li>
<li>build(deps-dev): bump the dev-dependencies group with 3 updates by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/golangci/golangci-lint-action/pull/1061">golangci/golangci-lint-action#1061</a></li>
<li>build(deps): bump <code>@​types/node</code> from 20.14.0 to 20.14.2 in the dependencies group by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/golangci/golangci-lint-action/pull/1062">golangci/golangci-lint-action#1062</a></li>
<li>build(deps-dev): bump the dev-dependencies group with 3 updates by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/golangci/golangci-lint-action/pull/1063">golangci/golangci-lint-action#1063</a></li>
<li>build(deps): bump <code>@​types/node</code> from 20.14.2 to 20.14.8 in the dependencies group by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/golangci/golangci-lint-action/pull/1066">golangci/golangci-lint-action#1066</a></li>
<li>build(deps-dev): bump the dev-dependencies group with 3 updates by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/golangci/golangci-lint-action/pull/1065">golangci/golangci-lint-action#1065</a></li>
<li>build(deps-dev): bump the dev-dependencies group with 2 updates by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/golangci/golangci-lint-action/pull/1067">golangci/golangci-lint-action#1067</a></li>
<li>build(deps): bump <code>@​types/node</code> from 20.14.8 to 20.14.9 in the dependencies group by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/golangci/golangci-lint-action/pull/1068">golangci/golangci-lint-action#1068</a></li>
<li>build(deps-dev): bump the dev-dependencies group with 4 updates by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/golangci/golangci-lint-action/pull/1071">golangci/golangci-lint-action#1071</a></li>
<li>build(deps): bump <code>@​types/node</code> from 20.14.9 to 20.14.10 in the dependencies group by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/golangci/golangci-lint-action/pull/1072">golangci/golangci-lint-action#1072</a></li>
<li>build(deps-dev): bump the dev-dependencies group with 3 updates by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/golangci/golangci-lint-action/pull/1073">golangci/golangci-lint-action#1073</a></li>
<li>build(deps-dev): bump the dev-dependencies group with 3 updates by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/golangci/golangci-lint-action/pull/1074">golangci/golangci-lint-action#1074</a></li>
<li>build(deps): bump <code>@​types/node</code> from 20.14.10 to 20.14.11 in the dependencies group by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/golangci/golangci-lint-action/pull/1075">golangci/golangci-lint-action#1075</a></li>
<li>build(deps-dev): bump the dev-dependencies group with 3 updates by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/golangci/golangci-lint-action/pull/1077">golangci/golangci-lint-action#1077</a></li>
<li>build(deps): bump <code>@​types/node</code> from 20.14.11 to 22.0.0 in the dependencies group by <a href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a href="https://redirect.github.com/golangci/golangci-lint-action/pull/1078">golangci/golangci-lint-action#1078</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a href="https://github.com/golangci/golangci-lint-action/compare/v6.0.1...v6.1.0">https://github.com/golangci/golangci-lint-action/compare/v6.0.1...v6.1.0</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/golangci/golangci-lint-action/commit/aaa42aa0628b4ae2578232a66b541047968fac86"><code>aaa42aa</code></a> feat: allow to skip golangci-lint installation (<a href="https://redirect.github.com/golangci/golangci-lint-action/issues/1079">#1079</a>)</li>
<li><a href="https://github.com/golangci/golangci-lint-action/commit/9ec89731c3231147ae014c73448ce9a7240d661b"><code>9ec8973</code></a> build(deps): bump <code>@​types/node</code> from 20.14.11 to 22.0.0 in the dependencies gro...</li>
<li><a href="https://github.com/golangci/golangci-lint-action/commit/58838cffc6bda5bd2ec1d112b85e698357d129ab"><code>58838cf</code></a> build(deps-dev): bump the dev-dependencies group with 3 updates (<a href="https://redirect.github.com/golangci/golangci-lint-action/issues/1077">#1077</a>)</li>
<li><a href="https://github.com/golangci/golangci-lint-action/commit/9f3ba2c3a8aadb9f3c42d252c4c227a6b0d98539"><code>9f3ba2c</code></a> build(deps): bump <code>@​types/node</code> from 20.14.10 to 20.14.11 in the dependencies g...</li>
<li><a href="https://github.com/golangci/golangci-lint-action/commit/2bd7a04e9163c07aaa1d5eabf703d7380133d655"><code>2bd7a04</code></a> build(deps-dev): bump the dev-dependencies group with 3 updates (<a href="https://redirect.github.com/golangci/golangci-lint-action/issues/1074">#1074</a>)</li>
<li><a href="https://github.com/golangci/golangci-lint-action/commit/db819a10bda59ee2a8f342af52c07e329576a0f5"><code>db819a1</code></a> build(deps-dev): bump the dev-dependencies group with 3 updates (<a href="https://redirect.github.com/golangci/golangci-lint-action/issues/1073">#1073</a>)</li>
<li><a href="https://github.com/golangci/golangci-lint-action/commit/d09fb0808ae08b4310fe3140992ba2475deac1c0"><code>d09fb08</code></a> build(deps): bump <code>@​types/node</code> from 20.14.9 to 20.14.10 in the dependencies gr...</li>
<li><a href="https://github.com/golangci/golangci-lint-action/commit/605617a3e2eaed801714e186af8a440496363f8d"><code>605617a</code></a> build(deps-dev): bump the dev-dependencies group with 4 updates (<a href="https://redirect.github.com/golangci/golangci-lint-action/issues/1071">#1071</a>)</li>
<li><a href="https://github.com/golangci/golangci-lint-action/commit/66f63c74bb4cdd7d445cb7c8c18dee38449cb1c5"><code>66f63c7</code></a> chore: generate</li>
<li><a href="https://github.com/golangci/golangci-lint-action/commit/2c01d264abe04570211ba8d3c6d3aa17eced3c80"><code>2c01d26</code></a> fix: home dir on Windows</li>
<li>Additional commits viewable in <a href="https://github.com/golangci/golangci-lint-action/compare/v6.0.1...v6.1.0">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=golangci/golangci-lint-action&package-manager=github_actions&previous-version=6.0.1&new-version=6.1.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>


Patch:
diff --git a/errors.go b/errors.go
index 5378125..04c3ffa 100644
--- a/errors.go
+++ b/errors.go
@@ -4,6 +4,7 @@ import "fmt"
 
 // Public error definitions
 var (
+	ErrCronJobInvalid                = fmt.Errorf("gocron: CronJob: invalid crontab")
 	ErrCronJobParse                  = fmt.Errorf("gocron: CronJob: crontab parse failure")
 	ErrDailyJobAtTimeNil             = fmt.Errorf("gocron: DailyJob: atTime within atTimes must not be nil")
 	ErrDailyJobAtTimesNil            = fmt.Errorf("gocron: DailyJob: atTimes must not be nil")
diff --git a/job.go b/job.go
index 6f09f3d..b3fbb8e 100644
--- a/job.go
+++ b/job.go
@@ -116,7 +116,7 @@ type cronJobDefinition struct {
 	withSeconds bool
 }
 
-func (c cronJobDefinition) setup(j *internalJob, location *time.Location, _ time.Time) error {
+func (c cronJobDefinition) setup(j *internalJob, location *time.Location, now time.Time) error {
 	var withLocation string
 	if strings.HasPrefix(c.crontab, "TZ=") || strings.HasPrefix(c.crontab, "CRON_TZ=") {
 		withLocation = c.crontab
@@ -140,6 +140,9 @@ func (c cronJobDefinition) setup(j *internalJob, location *time.Location, _ time
 	if err != nil {
 		return errors.Join(ErrCronJobParse, err)
 	}
+	if cronSchedule.Next(now).IsZero() {
+		return ErrCronJobInvalid
+	}
 
 	j.jobSchedule = &cronJob{cronSchedule: cronSchedule}
 	return nil


Test patch:
diff --git a/.github/workflows/go_test.yml b/.github/workflows/go_test.yml
index 7384e6e..af72f0a 100644
--- a/.github/workflows/go_test.yml
+++ b/.github/workflows/go_test.yml
@@ -25,7 +25,7 @@
          with:
            go-version: ${{ matrix.go-version }}
        - name: golangci-lint
-         uses: golangci/golangci-lint-action@v6.0.1
+         uses: golangci/golangci-lint-action@v6.1.0
          with:
            version: v1.59.1
        - name: test
diff --git a/scheduler_test.go b/scheduler_test.go
index 212eb70..70aed72 100644
--- a/scheduler_test.go
+++ b/scheduler_test.go
@@ -532,6 +532,15 @@ func TestScheduler_NewJobErrors(t *testing.T) {
 			nil,
 			ErrCronJobParse,
 		},
+		{
+			"cron invalid date",
+			CronJob(
+				"* * * 31 FEB *",
+				true,
+			),
+			nil,
+			ErrCronJobInvalid,
+		},
 		{
 			"duration job time interval is zero",
 			DurationJob(0 * time.Second),