This containerized Go CI/CD Toolchain provides a "golden path" for ensuring high code quality and consistency across Go projects. Designed for modern development workflows, it integrates essential code quality tools and policy-driven gates into a reproducible Docker environment, making it ideal for robust CI/CD pipelines.
Solves "Works on My Machine": Crucially, this toolchain eliminates environmental inconsistencies. By encapsulating all Go versions, linters, and configurations within a Docker image, it guarantees that the exact same checks and tool versions run everywhere – from a developer's laptop to production CI/CD pipelines.
Comprehensive Code Quality Assurance: Implements a stringent suite of checks, including:
Test Coverage Analysis: Configurable policy enforcement for minimum coverage thresholds.
Static Analysis (Linting): Leverages golangci-lint for fast, thorough, and opinionated code analysis.
Cyclomatic Complexity Monitoring: Utilizes gocyclo with custom policies to enforce maintainability and reduce technical debt.
Go Example Verification: Ensures code examples are correct and runnable, promoting clear documentation and testability.
Policy-Driven Quality Gates: Features custom awk scripts (coverage-policy.awk, gocyclo-policy.awk) for highly flexible and enforceable quality standards, allowing teams to define and automatically apply project-specific metrics.
CI-Optimized & Developer-Friendly Logging: Dynamically switches between structured JSON output (for seamless integration with log aggregation and analysis systems in CI) and human-readable logs (for immediate developer feedback).
Performance & Maintainability Focus: Includes mechanisms for persistent Docker volume caching to drastically cut pipeline execution times and ensures clean file permissions for generated artifacts.
Modular & Extensible: Built with Makefile orchestration, enabling easy integration into various CI platforms and straightforward customization or expansion of quality checks.
Detailed "conditional" logs: Only in the case of an issue detected by any of the make targets, will a log file be created and persisted on the host.
Run comprehensive quality checks on your Go project, locally or in CI:
# For local development with human-readable output
docker run --rm -v "$(pwd)":/gosource dotwilbert/go-toolchain:latest
# With caching through a docker volume 'go-build-cache' and host user id
docker run --rm --user $(id -u):$(id -g) -v "$(pwd)":/gosource -v go-build-cache:/home/maker dotwilbert/go-toolchain:latest
# For CI pipelines with structured JSON output
docker run --rm -e CI=true -v "$(pwd)":/gosource dotwilbert/go-toolchain:latest
This toolchain empowers teams to maintain exceptional code standards, proactively catch issues, and accelerate delivery with confidence, embodying best practices in modern software engineering.