| title | weight | toc |
|---|---|---|
CI/CD Pipeline |
3 |
true |
This document describes the automated CI/CD pipeline for Pass-CLI.
Trigger: Push to main branch or pull requests to main
Jobs:
-
Test (Matrix: Ubuntu, macOS, Windows)
- Runs unit tests with race detection
- Generates code coverage reports
- Uploads coverage to Codecov
-
Integration Test (Matrix: Ubuntu, macOS, Windows)
- Runs integration tests with build tags
- Tests E2E workflows across platforms
- 5-minute timeout for complete test suite
-
Lint
- Runs golangci-lint with comprehensive checks
- Enforces code quality standards
- Fails on any linting issues
-
Security Scan
- Runs Gosec security scanner
- Generates SARIF report for GitHub Security
- Identifies potential security vulnerabilities
-
Build
- Runs GoReleaser in snapshot mode
- Builds for all platforms without publishing
- Uploads build artifacts for verification
Trigger: Git tags matching v* pattern
Jobs:
-
Test Before Release
- Runs complete unit test suite
- Runs integration tests
- Must pass before release proceeds
-
Lint Before Release
- Runs full linting suite
- Ensures code quality standards met
-
Security Scan Before Release
- Final security check before release
- Must complete successfully
-
Release
- Runs GoReleaser for production release
- Builds all platform binaries
- Creates GitHub release with artifacts
- Generates checksums and SBOMs
-
Verify Release (Matrix: Ubuntu, macOS, Windows)
- Downloads released artifacts
- Verifies checksums
- Tests binary extraction
- Runs version command verification
- Tests and linting must pass before builds
- Security scans must complete before release
- Any failure stops the pipeline
- Platforms: Ubuntu, macOS, Windows
- Go Version: 1.25 (pinned for consistency)
- Ensures cross-platform compatibility
- Go module cache enabled
- Build cache enabled
- Speeds up CI runs significantly
- Build artifacts retained for 7 days
- Release artifacts retained for 30 days
- Coverage reports uploaded to Codecov
Configuration: .github/dependabot.yml
Updates:
- GitHub Actions (weekly)
- Go modules (weekly)
- Automatic PR creation for updates
Features:
- Groups patch updates together
- Labels PRs automatically
- Assigns reviewers
GITHUB_TOKEN is automatically provided by GitHub Actions for:
- Creating releases
- Uploading artifacts
- Commenting on PRs
For advanced features, you may configure:
- CODECOV_TOKEN: For private repository coverage uploads
- GPG_KEY: For signing releases (if configured)
- SLACK_WEBHOOK: For release notifications
# Run unit tests like CI
go test -v -race -coverprofile=coverage.txt ./...
# Run integration tests like CI
go test -v -tags=integration -timeout 5m ./test
# Run linter like CI
golangci-lint run --timeout=5m
# Run security scan like CI
gosec ./...
# Build like CI
goreleaser build --snapshot --clean# Full release dry run
goreleaser release --snapshot --clean --skip=publish
# Verify checksums
cd dist
sha256sum -c checksums.txt# Ensure on main branch and up-to-date
git checkout main
git pull origin main
# Run full test suite
go test ./...
go test -v -tags=integration -timeout 5m ./test
# Create and push tag
git tag -a v1.0.0 -m "Release v1.0.0"
git push origin v1.0.0- Tag is pushed to GitHub
- Release workflow is triggered
- Tests run across all platforms
- Linting and security scans execute
- GoReleaser builds all binaries
- GitHub release is created
- Artifacts are uploaded
- Verification runs on all platforms
- Watch GitHub Actions tab for progress
- Check release page for artifacts
- Review logs if any failures occur
- Download and test binaries
contents: read- Read repository code
contents: write- Create releases and upload artifactspackages: write- Publish packages (if configured)
Test Failures:
# Run tests locally to debug
go test -v -race ./...
go test -v -tags=integration ./testLint Failures:
# Fix linting issues
golangci-lint run --fixBuild Failures:
# Test cross-compilation
GOOS=linux GOARCH=amd64 go build .
GOOS=darwin GOARCH=arm64 go build .
GOOS=windows GOARCH=amd64 go build .Release Failures:
# Validate GoReleaser config
goreleaser check
# Dry run release
goreleaser release --snapshot --clean --skip=publish"Go language version mismatch" (golangci-lint):
- Issue: golangci-lint fails with "binary was built with go X but current version is Y"
- Root Cause: golangci-lint must be built with a Go version >= the project's Go version
- Solution: Pin golangci-lint to a version built with compatible Go
- Example: For Go 1.21+ projects, use golangci-lint v1.55+ with golangci-lint-action v6
- name: Run golangci-lint uses: golangci/golangci-lint-action@v6 with: version: v1.55 # Built with Go 1.21+
- Reference: golangci/golangci-lint#5873
"Resource not accessible by integration":
- Check workflow permissions
- Ensure GITHUB_TOKEN has proper scopes
- For cross-repo updates (Homebrew/Scoop), use Personal Access Tokens:
env: HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }} SCOOP_BUCKET_TOKEN: ${{ secrets.SCOOP_BUCKET_TOKEN }}
"No matching tag":
- Verify tag format matches
v* - Ensure tag is pushed to remote
"Build timeout":
- Increase timeout in workflow
- Optimize build process
"Artifact upload failed":
- Check artifact size limits
- Verify artifact paths exist
- Always test locally first: Run tests and builds before pushing
- Use semantic versioning: Follow semver for tags
- Write good commit messages: They become release notes
- Monitor workflow runs: Check Actions tab after pushing
- Review release artifacts: Verify before announcing
- Keep dependencies updated: Review Dependabot PRs
- Document breaking changes: Update CHANGELOG.md
Add to README.md:
[](https://github.com/arimxyer/pass-cli/actions/workflows/ci.yml)
[](https://github.com/arimxyer/pass-cli/actions/workflows/release.yml)
[](https://goreportcard.com/report/github.com/arimxyer/pass-cli)
[](https://codecov.io/gh/arimxyer/pass-cli)- Gosec runs on every push and PR
- SARIF results uploaded to GitHub Security
- Vulnerabilities appear in Security tab
- Dependabot scans for vulnerable dependencies
- Creates PRs for security updates
- Alerts appear in Security tab
- Review security scan results
- Update dependencies promptly
- Don't commit secrets to repository
- Use GitHub Secrets for sensitive data