Reusable workflow for Go continuous integration that runs tests across multiple Go versions and operating systems, performs linting, verifies code formatting, and optionally builds cross-platform binaries.
- Multi-version Go testing (configurable versions)
- Cross-platform testing (Linux, macOS, Windows)
- golangci-lint with configurable arguments
- Code formatting verification (gofmt + go vet)
- Go module tidiness check
- Go coverage comment integration for PR feedback
- Optional cross-platform binary builds
- Documentation completeness checks
- Aggregate status check for all jobs
name: CI
on:
push:
branches: [develop, release-candidate, main]
pull_request:
branches: [develop, release-candidate, main]
jobs:
ci:
uses: LerianStudio/github-actions-shared-workflows/.github/workflows/go-ci.yml@v1.0.0name: CI
on: [push, pull_request]
jobs:
ci:
uses: LerianStudio/github-actions-shared-workflows/.github/workflows/go-ci.yml@v1.0.0
with:
go_versions: '["1.22", "1.23"]'
operating_systems: '["ubuntu-latest", "macos-latest"]'
go_version_lint: '1.23'
golangci_lint_version: 'latest'
golangci_lint_args: '--timeout=10m --enable-all'
enable_coverage_comment: true
check_docs: true
check_module_tidy: truename: CI
on: [push, pull_request]
jobs:
ci:
uses: LerianStudio/github-actions-shared-workflows/.github/workflows/go-ci.yml@v1.0.0
with:
enable_cross_platform_build: true
build_path: './cmd/myapp'
build_targets: |
[
{"os": "linux", "arch": "amd64"},
{"os": "linux", "arch": "arm64"},
{"os": "darwin", "arch": "amd64"},
{"os": "darwin", "arch": "arm64"},
{"os": "windows", "arch": "amd64"}
]| Input | Description | Required | Default |
|---|---|---|---|
go_versions |
JSON array of Go versions to test | No | ["1.21", "1.22", "1.23"] |
operating_systems |
JSON array of OSes to test on | No | ["ubuntu-latest", "macos-latest", "windows-latest"] |
runner_type |
GitHub runner type for non-matrix jobs | No | ubuntu-latest |
go_version_lint |
Go version for linting | No | 1.23 |
build_cmd |
Build command to execute | No | go build -v ./... |
test_cmd |
Test command to execute | No | go test -v -race -coverprofile=coverage.txt -covermode=atomic ./... |
enable_coverage_comment |
Enable Go coverage comment in PR | No | true |
golangci_lint_version |
golangci-lint version | No | latest |
golangci_lint_args |
Additional golangci-lint arguments | No | --timeout=5m |
check_docs |
Enable documentation checks | No | true |
check_module_tidy |
Enable go.mod/go.sum tidiness check | No | true |
enable_cross_platform_build |
Enable cross-platform builds | No | false |
build_targets |
JSON array of build targets | No | [] (uses defaults) |
build_path |
Path to main package | No | ./cmd |
Runs tests in a matrix across multiple Go versions and operating systems.
Posts coverage report as PR comment (only runs on pull requests).
Runs golangci-lint to check code quality.
Builds cross-platform binaries if enable_cross_platform_build is true.
Verifies go.mod and go.sum are tidy.
Checks code formatting and runs go vet.
Checks for required documentation files.
Aggregate status check that fails if any required job fails.
jobs:
ci:
uses: LerianStudio/github-actions-shared-workflows/.github/workflows/go-ci.yml@v1.0.0jobs:
ci:
uses: LerianStudio/github-actions-shared-workflows/.github/workflows/go-ci.yml@v1.0.0
with:
go_versions: '["1.23"]'
operating_systems: '["ubuntu-latest"]'jobs:
ci:
uses: LerianStudio/github-actions-shared-workflows/.github/workflows/go-ci.yml@v1.0.0
with:
check_docs: false- Pin to a version tag: Use
@v1.0.0instead of@v1.0.0for production stability - golangci-lint config: Place
.golangci.ymlin your repo root for custom linting rules - Custom build targets: Specify exact platforms you need to reduce build time
- Markdown link check: Add
.github/markdown-link-check-config.jsonto configure link validation - Coverage comments: Automatically posted to PRs when
enable_coverage_commentis true
- Go Security - Comprehensive security scanning
- Go Release - Automated release creation
Last Updated: 2025-11-22 Version: 1.0.0