Skip to content

CI/CD Integration

Status: Placeholder - Content coming soon

Prerequisites: Making Your First Release, GitHub Actions basics

Planned Content

This tutorial teaches you how to set up automated CI/CD pipelines with quality gates, using GitHub Actions and r2r commands for continuous delivery.

What You'll Learn

  • Set up GitHub Actions workflows for r2r projects
  • Implement quality gates at commit, merge, and release stages
  • Use pipeline commands for orchestration
  • Run changed modules only in CI
  • Configure test suites for different pipeline stages
  • Monitor pipeline status and wait for completion
  • Troubleshoot CI failures efficiently

Tutorial Structure

  1. Understanding the CD model

  2. 12-stage continuous delivery framework

  3. Quality gates: pre-commit, merge request, release
  4. Test levels at each stage (L0-L1 commit → L2 integration → L3 acceptance → L4 production)
  5. Artifact progression through stages

  6. GitHub Actions setup

  7. Workflow file structure (.github/workflows/)

  8. Trigger events: push, pull_request, workflow_dispatch
  9. Job dependencies and parallelization
  10. Secrets and environment variables

  11. Pre-commit quality gate

  12. Local: pre-commit hooks

  13. What to validate: format, lint, L0-L2 tests, specs
  14. Fast feedback (< 5 minutes)

  15. Commit/Push quality gate

name: Commit Pipeline
on: push
jobs:
  validate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Get changed modules
        run: r2r get changed-modules-ci
      - name: Build changed modules
        run: r2r build $(r2r get changed-modules-ci)
      - name: Test changed modules (unit suite)
        run: r2r test $(r2r get changed-modules-ci)
      - name: Validate all
        run: r2r validate
  1. Pull request quality gate

  2. Run integration suite (L2 Docker-based tests)

  3. Security scanning (SAST, vulnerabilities)
  4. Dependency validation
  5. Specification validation
  6. Thorough validation (10-20 minutes)

  7. Release quality gate

  8. Production verification suite (L4, PIV)

  9. Generate SBOM
  10. Compliance scanning
  11. Release approval checks

  12. Using pipeline commands

  13. Run pipeline: r2r pipeline run

  14. Check status: r2r pipeline status
  15. Dispatch and wait: r2r pipeline ci dispatch-and-wait
  16. Wait for completion: r2r pipeline wait

  17. Optimizing CI performance

  18. Build only changed modules

  19. Cache dependencies (Go modules, npm packages)
  20. Parallel test execution
  21. Incremental builds
  22. Matrix builds for multi-platform

  23. Monitoring and debugging

  24. View CI status: r2r pipeline status
  25. Generate CI summary: r2r pipeline ci-summary-link
  26. Debug failures: analyze logs, reproduce locally
  27. Flaky test detection

Complete Workflow Example

The tutorial will set up a complete CI/CD pipeline:

Pre-commit (local):

# .git/hooks/pre-commit
r2r validate

Commit pipeline (on push):

  • Build changed modules
  • Test changed modules (unit suite)
  • Validate contracts and specs

Pull request pipeline (on PR):

  • Build all affected modules
  • Test with integration suite (L2)
  • Security scans (SAST, vulnerabilities, IaC)
  • Validate dependencies
  • Generate test report

Release pipeline (on tag):

  • Build release artifacts
  • Run production-verification suite
  • Generate SBOM
  • Compliance checks
  • Create GitHub release
  • Deploy to staging

Key Concepts Covered

  • Quality gates and their purposes
  • Test suite selection per stage
  • Incremental builds in CI
  • Pipeline orchestration with r2r
  • Monitoring and troubleshooting
  • Performance optimization

GitHub Actions Best Practices

  • Use r2r get changed-modules-ci for incremental builds
  • Cache Go modules: actions/cache@v4
  • Run tests in parallel where possible
  • Set appropriate timeouts
  • Use matrix builds for multi-platform
  • Store artifacts for debugging

Example: Complete CI Workflow

name: CI
on:
  push:
    branches: [main]
  pull_request:

jobs:
  validate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - uses: actions/setup-go@v5
        with:
          go-version: '1.21'

      - name: Install r2r CLI
        run: |
          curl -fsSL https://raw.githubusercontent.com/ready-to-release/eac/main/scripts/sh/cli/install.sh | bash
          echo "$HOME/.local/bin" >> $GITHUB_PATH

      - name: Get changed modules
        id: changed
        run: echo "modules=$(r2r get changed-modules-ci)" >> $GITHUB_OUTPUT

      - name: Build
        if: steps.changed.outputs.modules != ''
        run: r2r build ⟪ steps.changed.outputs.modules ⟫

      - name: Test (unit suite)
        if: steps.changed.outputs.modules != ''
        run: r2r test ⟪ steps.changed.outputs.modules ⟫

      - name: Validate
        run: r2r validate

Troubleshooting CI Failures

Common issues and solutions:

  • Build fails in CI but passes locally: Check environment differences
  • Tests timeout: Increase timeout or optimize tests
  • Flaky tests: Use r2r show test-timings to identify
  • Cache issues: Clear cache and rebuild

Next Steps

After completing this tutorial, you'll have a complete CI/CD pipeline. Continue to Multi-Module Development to learn how to manage dependencies across multiple modules.


Tutorials | How-to Guides | Explanation | Reference

You are here: Tutorials — learning-oriented guides that take you through steps to complete a project.