Skip to content

Commit 14f3a34

Browse files
authored
feat: modernize fork with panic fixes, DST handling, and CI (#1)
Modernize the robfig/cron fork with critical bug fixes and improvements. ## Bug Fixes - Fix TZ timezone parsing panic when spec has no fields after TZ prefix (robfig#554, robfig#555) - Fix nil pointer panic in Entry.Run() when WrappedJob is nil (robfig#551) ## Enhancements - Implement ISC cron DST behavior for spring forward (robfig#541) - Upgrade to Go 1.25 - Finalize module path as github.com/netresearch/go-cron ## CI/Quality - Add comprehensive GitHub Actions CI workflow - Add golangci-lint v2 configuration - Add Dependabot for dependency updates - Fix deprecated io/ioutil usage ## Documentation - Update README for fork with migration instructions - Document all fixes and improvements All tests pass. Successfully integrated into Ofelia with full test coverage.
2 parents bc59245 + 041c736 commit 14f3a34

File tree

16 files changed

+589
-131
lines changed

16 files changed

+589
-131
lines changed

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "gomod"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
- package-ecosystem: "github-actions"
8+
directory: "/"
9+
schedule:
10+
interval: "weekly"

.github/workflows/ci.yml

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags: ['**']
7+
pull_request:
8+
branches: [main]
9+
workflow_dispatch:
10+
schedule:
11+
- cron: '0 0 * * 0'
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
unit:
18+
name: unit tests
19+
runs-on: ${{ matrix.platform }}
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
go-version: [1.25.x]
24+
platform: [ubuntu-latest]
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
31+
- name: Install Go
32+
uses: actions/setup-go@v5
33+
with:
34+
go-version: ${{ matrix.go-version }}
35+
36+
- name: Verify go.mod is tidy
37+
run: |
38+
go mod tidy
39+
git diff --exit-code -- go.mod go.sum
40+
41+
- name: Unit tests
42+
run: go test -race -covermode=atomic -coverprofile=coverage.out ./...
43+
44+
- name: Coverage summary
45+
run: go tool cover -func=coverage.out | tail -n 1 || true
46+
47+
- name: Enforce coverage threshold
48+
run: |
49+
THRESHOLD=70.0
50+
TOTAL=$(go tool cover -func=coverage.out | awk '/^total:/ {gsub("%","",$3); print $3}')
51+
echo "Total coverage: ${TOTAL}% (threshold ${THRESHOLD}%)"
52+
awk -v t="$THRESHOLD" -v a="$TOTAL" 'BEGIN { if (a+0 < t+0) { exit 1 } }'
53+
54+
- name: Upload coverage
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: coverage
58+
path: coverage.out
59+
60+
lint:
61+
name: golangci-lint
62+
runs-on: ubuntu-latest
63+
steps:
64+
- name: Checkout code
65+
uses: actions/checkout@v4
66+
with:
67+
fetch-depth: 0
68+
69+
- name: Install Go
70+
uses: actions/setup-go@v5
71+
with:
72+
go-version-file: go.mod
73+
74+
- name: Download modules
75+
run: go mod download
76+
77+
- name: Warm build cache
78+
run: go build ./...
79+
80+
- name: Run golangci-lint
81+
uses: golangci/golangci-lint-action@v6
82+
with:
83+
version: latest
84+
install-mode: goinstall
85+
args: --timeout=5m --out-format=github-actions --allow-parallel-runners
86+
only-new-issues: false
87+
88+
vulncheck:
89+
name: govulncheck
90+
runs-on: ubuntu-latest
91+
steps:
92+
- name: Checkout code
93+
uses: actions/checkout@v4
94+
- name: Install Go
95+
uses: actions/setup-go@v5
96+
with:
97+
go-version-file: go.mod
98+
- name: Run govulncheck
99+
run: |
100+
set +e
101+
TMP_OUT=$(mktemp)
102+
go run golang.org/x/vuln/cmd/govulncheck@latest ./... | tee "$TMP_OUT"
103+
status=$?
104+
set -e
105+
if grep -E "^\s*Fixed in:\s+" "$TMP_OUT" | grep -v "Fixed in: N/A" >/dev/null; then
106+
echo "govulncheck: vulnerabilities with available fixes detected"
107+
exit 1
108+
fi
109+
echo "govulncheck: no vulnerabilities with available fixes"
110+
exit 0
111+
112+
codeql:
113+
if: (github.event_name != 'push') || (!startsWith(github.ref, 'refs/heads/gh-readonly-queue/'))
114+
name: CodeQL Analysis
115+
runs-on: ubuntu-latest
116+
permissions:
117+
actions: read
118+
contents: read
119+
security-events: write
120+
steps:
121+
- name: Checkout repository
122+
uses: actions/checkout@v4
123+
124+
- name: Install Go
125+
uses: actions/setup-go@v5
126+
with:
127+
go-version-file: go.mod
128+
129+
- name: Initialize CodeQL
130+
uses: github/codeql-action/init@v3
131+
with:
132+
languages: go
133+
134+
- name: Download dependencies
135+
run: go mod download
136+
137+
- name: Build
138+
uses: github/codeql-action/autobuild@v3
139+
140+
- name: Perform CodeQL Analysis
141+
uses: github/codeql-action/analyze@v3
142+
143+
gosec:
144+
name: gosec
145+
runs-on: ubuntu-latest
146+
steps:
147+
- name: Checkout code
148+
uses: actions/checkout@v4
149+
150+
- name: Install Go
151+
uses: actions/setup-go@v5
152+
with:
153+
go-version-file: go.mod
154+
155+
- name: Install gosec
156+
run: go install github.com/securego/gosec/v2/cmd/gosec@latest
157+
158+
- name: Run gosec
159+
run: |
160+
$(go env GOPATH)/bin/gosec ./...
161+
162+
gitleaks:
163+
name: gitleaks
164+
runs-on: ubuntu-latest
165+
permissions:
166+
contents: read
167+
steps:
168+
- name: Checkout code
169+
uses: actions/checkout@v4
170+
171+
- name: Download gitleaks
172+
run: |
173+
set -e
174+
VERSION="8.18.4"
175+
URL="https://github.com/gitleaks/gitleaks/releases/download/v${VERSION}/gitleaks_${VERSION}_linux_x64.tar.gz"
176+
curl -sSL "$URL" | tar -xz gitleaks
177+
chmod +x gitleaks
178+
179+
- name: Run gitleaks
180+
run: ./gitleaks detect --source . --no-banner --redact
181+
182+
trivy:
183+
name: trivy scan (fs)
184+
runs-on: ubuntu-latest
185+
permissions:
186+
contents: read
187+
security-events: write
188+
steps:
189+
- uses: actions/checkout@v4
190+
- name: Run Trivy filesystem scan
191+
uses: aquasecurity/[email protected]
192+
with:
193+
scan-type: fs
194+
ignore-unfixed: true
195+
format: sarif
196+
output: trivy-results.sarif
197+
vuln-type: 'os,library'
198+
severity: CRITICAL,HIGH
199+
exit-code: 1
200+
- name: Upload Trivy SARIF
201+
uses: github/codeql-action/upload-sarif@v3
202+
with:
203+
sarif_file: trivy-results.sarif
204+
205+
workflow-lint:
206+
name: actionlint
207+
runs-on: ubuntu-latest
208+
permissions:
209+
contents: read
210+
pull-requests: read
211+
steps:
212+
- uses: actions/checkout@v4
213+
- uses: reviewdog/action-actionlint@v1

.golangci.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
version: "2"
2+
run:
3+
tests: true
4+
linters:
5+
default: none
6+
enable:
7+
- gocyclo
8+
- govet
9+
- ineffassign
10+
- misspell
11+
- staticcheck
12+
- unused
13+
settings:
14+
gocyclo:
15+
min-complexity: 25
16+
misspell:
17+
locale: US
18+
staticcheck:
19+
checks:
20+
- all
21+
- -S1000 # Allow single-case select for readability
22+
- -S1037 # Allow select with timeout channel for test patterns
23+
exclusions:
24+
generated: lax
25+
presets:
26+
- comments
27+
- common-false-positives
28+
- legacy
29+
- std-error-handling
30+
rules:
31+
- linters:
32+
- gocyclo
33+
path: _test\.go
34+
paths:
35+
- third_party$
36+
- builtin$
37+
- examples$
38+
formatters:
39+
enable:
40+
- gci
41+
- gofmt
42+
- gofumpt
43+
- goimports
44+
settings:
45+
gci:
46+
sections:
47+
- standard
48+
- default
49+
- prefix(github.com/netresearch/go-cron)
50+
exclusions:
51+
generated: lax
52+
paths:
53+
- third_party$
54+
- builtin$
55+
- examples$

0 commit comments

Comments
 (0)