Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e634c48
Add license and Go workflow checks
victoralfred Jan 18, 2026
dd6c7ee
Update badges
victoralfred Jan 18, 2026
8cdcaee
Fix staticcheck SA1012 warnings in test files
victoralfred Jan 18, 2026
3f65a74
Fix lint failure
victoralfred Jan 18, 2026
d346e44
Fix nil Context
victoralfred Jan 18, 2026
1f4688a
Fix ctx errors
victoralfred Jan 18, 2026
250eadc
Remove unused staticcheck linter directives
victoralfred Jan 18, 2026
d8afe5b
Improve performance with slice preallocation
victoralfred Jan 18, 2026
ebffd03
Fix lint
victoralfred Jan 18, 2026
61c0128
Remove additional unused linter directives
victoralfred Jan 18, 2026
6ba6d9d
Fix nil context test handling across all test files
victoralfred Jan 18, 2026
72dbfdd
Use correct staticcheck directive format
victoralfred Jan 18, 2026
02b0798
Use nolint directive for golangci-lint compatibility
victoralfred Jan 18, 2026
94b863a
Use lint:ignore format for both staticcheck and golangci-lint
victoralfred Jan 18, 2026
be47ee1
Revert to statictest ignore
victoralfred Jan 18, 2026
211d291
Fix staticcheck SA1012 by using context variable assignment
victoralfred Jan 18, 2026
4c6ffae
Fix fmt error
victoralfred Jan 18, 2026
2f8a554
Use explicit nil to fix nil error
victoralfred Jan 18, 2026
7f765dd
Update gowritter to v1.0.1 for cross-platform path fixes
victoralfred Jan 18, 2026
6c2dc3b
Fix Windows compatibility in tests
victoralfred Jan 18, 2026
1bb9110
Fix remaining Windows test failures with hardcoded paths
victoralfred Jan 19, 2026
25eac96
Fix semgrep and trivy scanner Windows test failures
victoralfred Jan 19, 2026
6aa5ed8
Fix flaky TestTimeoutHandling test on Windows
victoralfred Jan 19, 2026
3a3fe83
Fix flaky TestRunPolicyCheckContextTimeout on Windows
victoralfred Jan 19, 2026
908bf09
Fix gocritic linter warnings for invalid path tests
victoralfred Jan 19, 2026
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
260 changes: 260 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
name: Go

on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
schedule:
# Run weekly on Monday at 9 AM UTC
- cron: '0 9 * * 1'

jobs:
# Test against multiple Go versions
test-matrix:
name: Test (Go ${{ matrix.go-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go-version: ['1.22', '1.23', 'stable']
steps:
- uses: actions/checkout@v4

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

- name: Display Go version
run: go version

- name: Download dependencies
run: go mod download

- name: Verify dependencies
run: go mod verify

- name: Run tests
run: go test -v -race -timeout 10m ./...

- name: Build
run: go build -v ./cmd/devsec

# Vulnerability scanning
vulnerability-scan:
name: Vulnerability Scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 'stable'

- name: Install govulncheck
run: go install golang.org/x/vuln/cmd/govulncheck@latest

- name: Run govulncheck
run: govulncheck ./...

# Go module checks
go-mod:
name: Go Module Checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 'stable'

- name: Check go.mod tidiness
run: |
go mod tidy
git diff --exit-code go.mod go.sum || {
echo "ERROR: go.mod or go.sum is not tidy"
echo "Please run 'go mod tidy' and commit the changes"
exit 1
}

- name: Check for outdated dependencies
run: |
echo "Checking for outdated dependencies..."
go list -u -m all | grep '\[' || echo "All dependencies up to date"

# Static analysis
static-analysis:
name: Static Analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 'stable'

- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@latest

- name: Run staticcheck
run: staticcheck ./...

- name: Install revive
run: go install github.com/mgechev/revive@latest

- name: Run revive
run: revive -config .golangci.yml ./... || true

# Code formatting
formatting:
name: Code Formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 'stable'

- name: Check gofmt
run: |
if [ -n "$(gofmt -l .)" ]; then
echo "ERROR: The following files are not formatted:"
gofmt -l .
echo "Please run 'gofmt -w .' to format the code"
exit 1
fi
echo "✓ All files are properly formatted"

- name: Install goimports
run: go install golang.org/x/tools/cmd/goimports@latest

- name: Check goimports
run: |
if [ -n "$(goimports -l .)" ]; then
echo "Warning: The following files have import issues:"
goimports -l .
fi

# Benchmark tests
benchmark:
name: Benchmark
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 'stable'

- name: Run benchmarks
run: |
go test -bench=. -benchmem -run=^$ ./... | tee benchmark.txt

- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: benchmark-results
path: benchmark.txt
retention-days: 30

# Code coverage
coverage:
name: Code Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 'stable'

- name: Run tests with coverage
run: |
go test -v -race -coverprofile=coverage.out -covermode=atomic ./...

- name: Generate coverage report
run: |
go tool cover -html=coverage.out -o coverage.html
go tool cover -func=coverage.out > coverage.txt

- name: Display coverage summary
run: |
echo "Coverage Summary:"
cat coverage.txt | tail -1

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: ./coverage.out
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false

- name: Upload coverage artifacts
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: |
coverage.out
coverage.html
coverage.txt
retention-days: 30

notify:
name: Slack Notification
runs-on: ubuntu-latest
needs: [test-matrix, vulnerability-scan, go-mod, static-analysis, formatting, coverage]
if: always() && github.event_name == 'push'
environment: production
steps:
- name: Send Slack notification
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
run: |
if [ "${{ needs.test-matrix.result }}" == "success" ] && \
[ "${{ needs.vulnerability-scan.result }}" == "success" ] && \
[ "${{ needs.go-mod.result }}" == "success" ] && \
[ "${{ needs.static-analysis.result }}" == "success" ] && \
[ "${{ needs.formatting.result }}" == "success" ] && \
[ "${{ needs.coverage.result }}" == "success" ]; then
STATUS="success"
COLOR="good"
TEXT="All Go checks passed for devsec"
else
STATUS="failure"
COLOR="danger"
TEXT="Go checks failed for devsec"
fi

if [ -z "$SLACK_WEBHOOK_URL" ]; then
echo "Warning: SLACK_WEBHOOK_URL not configured, skipping notification"
exit 0
fi

curl -X POST -H 'Content-type: application/json' \
--data "{
\"attachments\": [{
\"color\": \"$COLOR\",
\"title\": \"Go Pipeline $STATUS\",
\"text\": \"$TEXT\",
\"fields\": [
{\"title\": \"Repository\", \"value\": \"${{ github.repository }}\", \"short\": true},
{\"title\": \"Branch\", \"value\": \"${{ github.ref_name }}\", \"short\": true},
{\"title\": \"Commit\", \"value\": \"${{ github.sha }}\", \"short\": true},
{\"title\": \"Actor\", \"value\": \"${{ github.actor }}\", \"short\": true}
],
\"footer\": \"GitHub Actions\",
\"ts\": $(date +%s)
}]
}" \
"$SLACK_WEBHOOK_URL"
Loading
Loading