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
119 changes: 119 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: CI/CD Pipeline

on:
push:
branches:
- master
pull_request:

permissions:
contents: read
pull-requests: read

env:
COVERAGE_THRESHOLD: 50

jobs:
# Setup job to expose variables
setup:
name: Setup
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false

# Build verification - ensure the tool compiles
build:
name: Build
runs-on: ubuntu-latest
needs: setup
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false

- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: stable
cache: true
cache-dependency-path: go.sum

- name: Download dependencies
run: go mod download

- name: Build library
run: go build -v ./...

- name: Build standalone binary
run: go build -v -o bin/errx-migrate ./cmd/errx-migrate

# Unit Tests
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
matrix:
go-version:
- oldstable
- stable
needs: setup
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false

- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: ${{ matrix.go-version }}
cache: true
cache-dependency-path: go.sum

- name: Download dependencies
run: go mod download

- name: Run unit tests with race detection
run: |
go test -race -v -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 | tail -1 | awk '{print $3}' | sed 's/%//' > coverage.txt

- name: Check coverage threshold
run: |
COVERAGE=$(cat coverage.txt)
echo "Coverage: ${COVERAGE}%"
if (( $(echo "$COVERAGE < $COVERAGE_THRESHOLD" | bc -l) )); then
echo "Coverage ${COVERAGE}% is below threshold ${COVERAGE_THRESHOLD}%"
exit 1
fi

- name: Upload coverage to Codecov
if: matrix.go-version == 'stable'
uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 # v6.0.1
with:
files: ./coverage.out
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false

- name: Upload coverage artifacts
if: matrix.go-version == 'stable'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: coverage-report
path: |
coverage.out
coverage.html
coverage.txt
49 changes: 49 additions & 0 deletions .github/workflows/go-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Go Lint

on:
push:
branches:
- master
pull_request:

permissions:
contents: read
pull-requests: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
permissions:
contents: read
steps:
# Checkout code
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false

- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: stable
cache: true
cache-dependency-path: go.sum

- name: Download dependencies
run: go mod download

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

- name: golangci-lint
uses: golangci/golangci-lint-action@82606bf257cbaff209d206a39f5134f0cfbfd2ee # v9.2.1
with:
args: --timeout=30m
version: v2.12.2

- name: Run govulncheck
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...
85 changes: 85 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Release

on:
push:
tags:
- 'v*'
pull_request:
branches:
- master

# Least privilege by default; the release job opts into write below.
permissions:
contents: read

Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
jobs:
# PR path: build a snapshot to validate the GoReleaser config. Read-only
# permissions and caching disabled so an untrusted PR cannot publish or
# poison caches used by the trusted (tag) release job.
snapshot:
name: GoReleaser Snapshot
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
persist-credentials: false

- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: 1.26.0
cache: false

- name: Run GoReleaser (snapshot)
uses: goreleaser/goreleaser-action@5daf1e915a5f0af01ddbcd89a43b8061ff4f1a89 # v7.2.2
with:
distribution: goreleaser
version: '~> v2'
args: release --snapshot --clean --skip=publish

- name: Upload PR artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: release-artifacts
path: |
dist/*.tar.gz
dist/*.zip
dist/checksums.txt
retention-days: 7

# Tag path: the real release. Runs only on tag pushes (a trusted ref) and is
# the only job granted write permissions.
release:
name: GoReleaser Release
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
persist-credentials: false

- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: 1.26.0
cache: true
cache-dependency-path: go.sum

- name: Run GoReleaser (production release)
uses: goreleaser/goreleaser-action@5daf1e915a5f0af01ddbcd89a43b8061ff4f1a89 # v7.2.2
with:
distribution: goreleaser
version: '~> v2'
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading