Files
dance-lessons-coach/adr/0017-trunk-based-development-workflow.md
Gabriel Radureau db09d0ace1 📝 docs(adr): homogenize all 23 ADR headers to canonical format
Audit 2026-05-02 (Tâche 6 Phase A) had identified 3 inconsistent
formats across the ADR corpus :
- F1 list bullets : `* Status:` / `* Date:` / `* Deciders:` (11 ADRs)
- F2 bold fields : `**Status:**` / `**Date:**` / `**Authors:**` (9 ADRs)
- F3 dedicated section : `## Status\n**Value** ` (5 ADRs)

Mixed metadata names (Authors / Deciders / Decision Date / Implementation
Date / Implementation Status / Last Updated) and decorative emojis on
status values made the corpus hard to scan or template against.

Canonical format adopted (see adr/README.md for full template) :
    # NN. Title

    **Status:** <Proposed|Accepted|Implemented|Partially Implemented|
                  Approved|Rejected|Deferred|Deprecated|Superseded by ADR-NNNN>
    **Date:** YYYY-MM-DD
    **Authors:** Name(s)
    [optional **Field:** ... lines]

    ## Context...

Transformations applied (via /tmp/homogenize-adrs.py) :
- F1 list bullets → bold fields
- F2 cleanup : `**Deciders:**` → `**Authors:**`, strip status emojis
- F3 sections : `## Status\n**Value** ` → `**Status:** Value`
- Strip decorative emojis from `**Status:**` and `**Implementation Status:**`
- Convert any `* Implementation Status:` / `* Last Updated:` /
  `* Decision Drivers:` / `* Decision Date:` to bold equivalents
- Date typo fix : `2024-04-XX` → `2026-04-XX` for ADRs 0018, 0019
  (already noted in PR #17 but here re-applied since branch starts
  from origin/main pre-PR17)
- Normalize multiple blank lines after header (max 1)

21 / 23 ADRs modified. 0010 and 0012 were already conform.
0011 and 0014 do not exist in the repo (cf. README index update).

Body content of each ADR is preserved unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 00:27:42 +02:00

9.8 KiB

17. Trunk-Based Development Workflow for CI/CD Safety

Date: 2026-04-05 Status: Approved Authors: Arcodange Team Decision Date: 2026-04-05 Implementation Status: Implemented

Context

dance-lessons-coach requires a safe workflow for making CI/CD changes to prevent breaking the main branch. The current workflow allows direct pushes to main, which poses risks for CI/CD configuration changes that could break the entire pipeline.

Decision Drivers

  • Safety: Prevent CI/CD misconfigurations from breaking main branch
  • Review Process: Ensure all CI/CD changes are properly reviewed
  • Trunk-Based: Maintain trunk-based development principles
  • Branch Protection: Protect main branch from direct CI/CD changes
  • Validation: Automatically validate workflow changes before merge
  • Rollback: Easy rollback capability for CI/CD issues

Decision

We will implement a Trunk-Based Development Workflow with Branch Protection specifically designed for CI/CD safety.

Selected Architecture: Protected Trunk with Validation Gates

graph TD
    A[Developer] -->|Create Branch| B[ci/* or feature/*]
    B -->|Push Changes| C[Git Server]
    C -->|Trigger| D[CI/CD Pipeline]
    D -->|Run| E[Workflow Validation Job]
    E -->|Success| F[Pull Request]
    F -->|Review| G[Team Review]
    G -->|Approve| H[Merge to Main]
    H -->|Trigger| I[Main Branch Pipeline]
    I -->|Success| J[Production]
    
    E -->|Failure| K[Fix Issues]
    K -->|Loop| B

Workflow Components

1. Branch Strategy

Branch Type Pattern Purpose Protection
Main main Production-ready code 🔒 Fully Protected
CI Updates ci/* CI/CD configuration changes 🛡️ Protected
Features feature/* New functionality 🛡️ Protected
Fixes fix/* Bug fixes 🛡️ Protected
Refactor refactor/* Code improvements 🛡️ Protected

2. Branch Protection Rules

Main Branch Protection:

  • Require pull request reviews (min 1 approval)
  • Require status checks to pass
  • Include administrators
  • Dismiss stale pull request approvals when new commits are pushed
  • Require conversation resolution before merging

Required Status Checks:

  • build-test - All tests must pass
  • lint-format - Code must be properly formatted
  • workflow-validation - CI/CD changes must be validated

3. CI/CD Workflow Triggers

on:
  workflow_dispatch: true
  push:
    branches:
      - main
      - 'ci/**'
      - 'feature/**'
      - 'fix/**'
      - 'refactor/**'
  pull_request:
    branches:
      - main
    types: [opened, synchronize, reopened, labeled]

4. Workflow Validation Job

A new workflow-validation job runs on:

  • All pull requests targeting main
  • Any push to ci/* branches

Validation Steps:

  1. YAML syntax validation
  2. Workflow structure validation
  3. Breaking change detection
  4. Required field verification

5. Merge Process for CI/CD Changes

# 1. Create dedicated CI branch
git checkout -b ci/update-workflow-v1

# 2. Make CI/CD changes
# (edit .gitea/workflows/ci-cd.yaml, scripts/cicd/, etc.)

# 3. Test locally first
./scripts/cicd.sh validate
./scripts/cicd.sh test-simple

# 4. Commit with clear message
git add .gitea/workflows/ci-cd.yaml scripts/cicd/
git commit -m "ci: update workflow with trunk protection"

# 5. Push and create PR
git push origin ci/update-workflow-v1
# Create Pull Request from ci/update-workflow-v1 to main

# 6. CI/CD pipeline automatically validates the workflow
# 7. Team reviews the changes
# 8. Merge after approval

Implementation

Workflow File Updates

.gitea/workflows/ci-cd.yaml:

  • Added workflow-validation job
  • Extended branch triggers to include ci/**, feature/**, fix/**, refactor/**
  • Added pull request triggers
  • Made version-check job depend on workflow-validation

Script Updates

scripts/cicd/validate-workflow.sh:

  • Enhanced to validate workflow changes in PR context
  • Added breaking change detection

Branch Protection Setup

Manual Gitea Configuration:

  1. Go to Repository Settings → Branches
  2. Add branch protection rule for main
  3. Enable required status checks
  4. Add workflow-validation to required checks

Consequences

Positive:

  • Main branch protected from CI/CD misconfigurations
  • All CI/CD changes go through validation and review
  • Automatic detection of workflow breaking changes
  • Clear rollback path (revert PR if issues arise)
  • Maintains trunk-based development principles
  • Encourages small, frequent CI/CD improvements

Negative:

  • Slightly more complex process for CI/CD changes
  • Requires discipline to use proper branch naming
  • Initial setup of branch protection rules

Future Enhancements

  1. Automatic Rollback: Add automatic rollback for failed CI/CD changes
  2. Canary Deployments: Test workflow changes on subset of runs first
  3. Workflow Diff Visualization: Show workflow changes in PR comments
  4. Breaking Change Detection: More sophisticated breaking change analysis
  5. Approver Assignment: Auto-assign CI/CD experts for workflow PRs

References

Implementation Observations

Gitea & GitHub Actions Compatibility Testing

Test Date: 2026-04-05 Test Method: act (GitHub Actions runner) with Gitea workflow syntax Result: FULL COMPATIBILITY CONFIRMED

Test Command

echo 'm' | act -n -W .gitea/workflows/ci-cd.yaml

Observations

  1. Syntax Compatibility:

    • Gitea workflow files work perfectly with GitHub Actions runner
    • All GitHub Actions syntax supported in Gitea
    • No syntax modifications needed
  2. Job Execution:

    • All jobs parsed correctly (build-test, lint-format, workflow-validation, version-check)
    • Job dependencies resolved properly
    • Conditional execution (if:) works as expected
  3. Action Compatibility:

    • actions/checkout@v4 - Working
    • actions/setup-go@v4 - Working
    • Standard GitHub actions work in Gitea context
  4. Local Testing Benefits:

    • No Gitea instance required for development
    • Instant feedback on workflow changes
    • Dry run mode prevents accidental executions
    • Container-based ensures clean environment
  5. Performance:

    • Fast execution (dry run completed in <1 second)
    • Minimal resource usage
    • Docker layer caching works efficiently

Sample Dry Run Output

*DRYRUN* [dance-lessons-coach CI/CD/Build and Test     ] ⭐ Run Set up job
*DRYRUN* [dance-lessons-coach CI/CD/Build and Test     ] 🚀  Start image=node:16-buster-slim
*DRYRUN* [dance-lessons-coach CI/CD/Build and Test     ]   ✅  Success - Set up job
*DRYRUN* [dance-lessons-coach CI/CD/Build and Test     ] ⭐ Run Main Checkout code
*DRYRUN* [dance-lessons-coach CI/CD/Build and Test     ]   ✅  Success - Main Checkout code [4.038875ms]
... (all steps succeeded)
*DRYRUN* [dance-lessons-coach CI/CD/Build and Test     ] 🏁  Job succeeded

1. Install act

# macOS (Homebrew)
brew install act

# Linux
curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash

2. Configure act

mkdir -p ~/Library/Application\ Support/act
cat > ~/Library/Application\ Support/act/actrc << 'EOF'
{
  "defaultImage": "medium:latest",
  "containerArchitecture": "linux/amd64"
}
EOF

3. Test Workflow Changes

# Dry run (no execution)
act -n -W .gitea/workflows/ci-cd.yaml

# Full test execution
act -W .gitea/workflows/ci-cd.yaml

# Test specific job
act -j build-test -W .gitea/workflows/ci-cd.yaml

4. Development Cycle

# 1. Create feature branch
git checkout -b ci/new-feature

# 2. Make workflow changes
# (edit .gitea/workflows/ci-cd.yaml)

# 3. Test locally
act -n -W .gitea/workflows/ci-cd.yaml

# 4. Commit and push
git add .gitea/workflows/ci-cd.yaml
git commit -m "ci: add new feature to workflow"
git push origin ci/new-feature

# 5. Create PR and let CI validate
# 6. Merge after approval

Benefits of This Approach

No Remote Dependencies - Test without Gitea instance Instant Feedback - Catch issues before pushing Reduced PR Churn - Fewer workflow patch iterations Better Developer Experience - Local testing = faster iteration Production Confidence - What works locally works in Gitea Team Efficiency - No more "wait and see" with remote CI

Future Enhancements

  1. CI/CD Test Script - Add act testing to our CI/CD scripts
  2. Pre-commit Hook - Automatically validate workflows before commit
  3. GitHub Actions Cache - Speed up local testing with caching
  4. Matrix Testing - Test across multiple runner versions
  5. Workflow Visualization - Generate diagrams from workflow files

Decision Record

Approved by: Arcodange Team Approved on: 2026-04-05 Implementation Owner: CI/CD Team Reviewers: Development Team Tested by: Local act dry run Compatibility: GitHub Actions ↔ Gitea Actions

Change Log:

  • 2026-04-05: Initial decision and implementation
  • 2026-04-05: Added workflow validation job
  • 2026-04-05: Updated branch protection rules
  • 2026-04-05: Confirmed Gitea/GitHub compatibility via act testing
  • 2026-04-05: Documented local development workflow