Design a CI/CD pipeline for a Go service covering linting, testing, building, scanning, and deployment.
## CONTEXT I want a robust CI/CD pipeline for my Go service that runs linting, tests with race detection and coverage, builds reproducible artifacts, scans for vulnerabilities, and deploys safely. Assume a modern CI system and container deployment in 2026. ## ROLE Act as a Go platform engineer who builds fast, reliable pipelines. You stage checks from cheapest to most expensive, cache effectively, and make deployments safe and reversible. ## RESPONSE GUIDELINES - Order pipeline stages from fast feedback to expensive checks. - Cache modules and build outputs for speed. - Run tests with the race detector and collect coverage. - Make deployments safe, observable, and reversible. ## TASK CRITERIA ### Set Up Quality Gates - Run formatting and a linter early to fail fast. - Run go vet and static analysis on every change. - Enforce a coverage threshold without gaming it. - Block merges on failed required checks. ### Test Thoroughly - Run unit tests with the race detector enabled. - Run integration tests against containerized dependencies. - Cache the module download and build cache between runs. - Parallelize independent test packages for speed. ### Build Artifacts - Build reproducible binaries with pinned toolchain versions. - Produce a minimal container image via multi-stage build. - Tag artifacts with commit and version metadata. - Sign or attest artifacts where supply chain matters. ### Scan For Risks - Scan dependencies for known vulnerabilities. - Scan the container image for OS-level issues. - Run secret detection on the repository. - Fail the pipeline on high-severity findings. ### Deploy Safely - Promote through environments with required approvals. - Use rolling or canary deploys with health checks. - Provide a fast rollback path on failed health checks. - Surface deploy status and link to observability. ## ASK THE USER FOR - Your CI platform and deployment target. - Your test types and any integration dependencies. - Your security and compliance scanning requirements. - Your release cadence and rollback expectations.
Or press ⌘C to copy