Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
213 changes: 213 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
name: CI

on:
push:
branches: [main]
tags: ['**']
pull_request:
branches: [main]
workflow_dispatch:
schedule:
- cron: '0 0 * * 0'

permissions:
contents: read

jobs:
unit:
name: unit tests
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
go-version: [1.25.x]
platform: [ubuntu-latest]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Verify go.mod is tidy
run: |
go mod tidy
git diff --exit-code -- go.mod go.sum

- name: Unit tests
run: go test -race -covermode=atomic -coverprofile=coverage.out ./...

- name: Coverage summary
run: go tool cover -func=coverage.out | tail -n 1 || true

- name: Enforce coverage threshold
run: |
THRESHOLD=70.0
TOTAL=$(go tool cover -func=coverage.out | awk '/^total:/ {gsub("%","",$3); print $3}')
echo "Total coverage: ${TOTAL}% (threshold ${THRESHOLD}%)"
awk -v t="$THRESHOLD" -v a="$TOTAL" 'BEGIN { if (a+0 < t+0) { exit 1 } }'

- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage
path: coverage.out

lint:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Download modules
run: go mod download

- name: Warm build cache
run: go build ./...

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
install-mode: goinstall
args: --timeout=5m --out-format=github-actions --allow-parallel-runners
only-new-issues: false

vulncheck:
name: govulncheck
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Run govulncheck
run: |
set +e
TMP_OUT=$(mktemp)
go run golang.org/x/vuln/cmd/govulncheck@latest ./... | tee "$TMP_OUT"
status=$?
set -e
if grep -E "^\s*Fixed in:\s+" "$TMP_OUT" | grep -v "Fixed in: N/A" >/dev/null; then
echo "govulncheck: vulnerabilities with available fixes detected"
exit 1
fi
echo "govulncheck: no vulnerabilities with available fixes"
exit 0

codeql:
if: (github.event_name != 'push') || (!startsWith(github.ref, 'refs/heads/gh-readonly-queue/'))
name: CodeQL Analysis
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: go

- name: Download dependencies
run: go mod download

- name: Build
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3

gosec:
name: gosec
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Install gosec
run: go install github.com/securego/gosec/v2/cmd/gosec@latest

- name: Run gosec
run: |
$(go env GOPATH)/bin/gosec ./...

gitleaks:
name: gitleaks
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Download gitleaks
run: |
set -e
VERSION="8.18.4"
URL="https://github.com/gitleaks/gitleaks/releases/download/v${VERSION}/gitleaks_${VERSION}_linux_x64.tar.gz"
curl -sSL "$URL" | tar -xz gitleaks
chmod +x gitleaks

- name: Run gitleaks
run: ./gitleaks detect --source . --no-banner --redact

trivy:
name: trivy scan (fs)
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- uses: actions/checkout@v4
- name: Run Trivy filesystem scan
uses: aquasecurity/trivy-action@0.24.0
with:
scan-type: fs
ignore-unfixed: true
format: sarif
output: trivy-results.sarif
vuln-type: 'os,library'
severity: CRITICAL,HIGH
exit-code: 1
- name: Upload Trivy SARIF
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: trivy-results.sarif

workflow-lint:
name: actionlint
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
steps:
- uses: actions/checkout@v4
- uses: reviewdog/action-actionlint@v1
55 changes: 55 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
version: "2"
run:
tests: true
linters:
default: none
enable:
- gocyclo
- govet
- ineffassign
- misspell
- staticcheck
- unused
settings:
gocyclo:
min-complexity: 25
misspell:
locale: US
staticcheck:
checks:
- all
- -S1000 # Allow single-case select for readability
- -S1037 # Allow select with timeout channel for test patterns
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- gocyclo
path: _test\.go
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gci
- gofmt
- gofumpt
- goimports
settings:
gci:
sections:
- standard
- default
- prefix(github.com/netresearch/go-cron)
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
Loading