Skip to content

chore(ci): modernize GitHub Actions + migrate golangci-lint to v2 (fixes the go1.25 lint) #111

chore(ci): modernize GitHub Actions + migrate golangci-lint to v2 (fixes the go1.25 lint)

chore(ci): modernize GitHub Actions + migrate golangci-lint to v2 (fixes the go1.25 lint) #111

name: CI
on:
push:
branches: [main]
tags: ['v*']
pull_request:
branches: [main]
permissions:
contents: read
jobs:
build:
name: Build & Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.25'
- name: Download dependencies
run: go mod download
- name: Vet
run: go vet ./...
- name: Lint
uses: golangci/golangci-lint-action@v9
with:
version: latest
- name: Build
run: CGO_ENABLED=0 go build -o kshark ./cmd/kshark
- name: Test
run: go test ./... -v -race -timeout 120s -coverprofile=coverage.out
- name: Coverage report
run: go tool cover -func=coverage.out
- name: Coverage gate
run: |
TOTAL=$(go tool cover -func=coverage.out | grep '^total:' | awk '{print substr($3, 1, length($3)-1)}')
echo "Total coverage: ${TOTAL}%"
THRESHOLD=40
if [ "$(echo "$TOTAL < $THRESHOLD" | bc)" -eq 1 ]; then
echo "::error::Coverage ${TOTAL}% is below ${THRESHOLD}% minimum"
exit 1
fi
- name: Vulnerability check
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...
release:
name: Release
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
id-token: write # Required for keyless cosign signing via GitHub OIDC
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.25'
- name: Install cosign
uses: sigstore/cosign-installer@v3
- name: Install syft (SBOM generator)
uses: anchore/sbom-action/download-syft@v0
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v7
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}