- Designed trunk-based development workflow with branch protection - Added workflow validation job to prevent main branch breaks - Integrated act (GitHub Actions runner) for local Gitea workflow testing - Created unified CI/CD script interface (scripts/cicd.sh) - Added YAML lint configuration with practical limits (400 chars) - Organized all CI/CD scripts under scripts/cicd/ directory - Confirmed Gitea/GitHub Actions compatibility via local testing - Updated ADR 0017 with implementation details and test results - Enhanced documentation with local development workflow See ADR-0017 for complete trunk-based development workflow documentation. See ADR-0016 for CI/CD pipeline design.
158 lines
4.2 KiB
YAML
158 lines
4.2 KiB
YAML
---
|
|
# DanceLessonsCoach CI/CD Pipeline for Arcodange Gitea
|
|
# Follows Arcodange conventions from webapp workflow
|
|
# Uses .gitea/workflows/ directory and internal registry
|
|
|
|
name: DanceLessonsCoach CI/CD
|
|
|
|
on:
|
|
workflow_dispatch: true
|
|
push:
|
|
branches:
|
|
- main
|
|
- 'ci/**'
|
|
- 'feature/**'
|
|
- 'fix/**'
|
|
- 'refactor/**'
|
|
paths-ignore:
|
|
- 'README.md'
|
|
- 'doc/**'
|
|
- 'adr/**'
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
types: [opened, synchronize, reopened, labeled]
|
|
|
|
# cancel any previously-started runs of this workflow on the same branch
|
|
concurrency:
|
|
group: ${{ github.ref }}-${{ github.workflow }}
|
|
cancel-in-progress: true
|
|
|
|
# Arcodange-specific environment variables
|
|
env:
|
|
GITEA_INTERNAL: "https://gitea.arcodange.lab/"
|
|
GITEA_EXTERNAL: "https://gitea.arcodange.fr/"
|
|
GITEA_ORG: "arcodange"
|
|
GITEA_REPO: "DanceLessonsCoach"
|
|
CI_REGISTRY: "gitea.arcodange.lab"
|
|
|
|
jobs:
|
|
build-test:
|
|
name: Build and Test
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v4
|
|
with:
|
|
go-version: '1.26.1'
|
|
cache: true
|
|
|
|
- name: Install dependencies
|
|
run: go mod tidy
|
|
|
|
- name: Build all packages
|
|
run: go build ./...
|
|
|
|
- name: Run tests with coverage
|
|
run: go test ./... -cover -v
|
|
|
|
- name: Build binaries
|
|
run: ./scripts/build.sh
|
|
|
|
- name: List artifacts
|
|
run: ls -la bin/
|
|
|
|
lint-format:
|
|
name: Lint and Format
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v4
|
|
with:
|
|
go-version: '1.26.1'
|
|
|
|
- name: Run go fmt
|
|
run: go fmt ./...
|
|
|
|
- name: Run go vet
|
|
run: go vet ./...
|
|
|
|
- name: Check for formatting issues
|
|
run: |
|
|
if [ -n "$(go fmt ./...)" ]; then
|
|
echo "❌ Formatting issues found"
|
|
exit 1
|
|
fi
|
|
echo "✅ Code is properly formatted"
|
|
|
|
workflow-validation:
|
|
name: Workflow Validation
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'pull_request' || contains(github.ref, 'ci/')
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Validate workflow syntax
|
|
run: |
|
|
if command -v yq >/dev/null 2>&1; then
|
|
yq eval '.' .gitea/workflows/ci-cd.yaml > /dev/null
|
|
echo "✅ Workflow YAML syntax is valid"
|
|
else
|
|
echo "⚠️ yq not installed, skipping YAML validation"
|
|
fi
|
|
|
|
- name: Run workflow validation script
|
|
run: ./scripts/cicd/validate-workflow.sh
|
|
|
|
- name: Check for breaking changes
|
|
if: github.event_name == 'pull_request'
|
|
run: |
|
|
echo "🔍 Checking workflow changes..."
|
|
changes=$(git diff origin/main -- .gitea/workflows/ci-cd.yaml | grep -q "^-")
|
|
if [ $changes ]; then
|
|
echo "⚠️ Changes detected - review recommended"
|
|
else
|
|
echo "✅ No workflow changes"
|
|
fi
|
|
|
|
version-check:
|
|
name: Version Management
|
|
runs-on: ubuntu-latest
|
|
needs: [build-test, lint-format, workflow-validation]
|
|
if: github.ref == 'refs/heads/main'
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Show current version
|
|
run: |
|
|
source VERSION
|
|
echo "Version: $MAJOR.$MINOR.$PATCH${PRERELEASE:+-$PRERELEASE}"
|
|
echo "GITEA_REPO=$GITEA_ORG/$GITEA_REPO" >> $GITHUB_ENV
|
|
|
|
- name: Check for version bump candidates
|
|
run: |
|
|
echo "📋 Last commit analysis:"
|
|
git log -1 --pretty=%B | head -1
|
|
|
|
if git log -1 --pretty=%B | grep -q "^feat:"; then
|
|
echo "🎯 Feature commit detected - consider MINOR version bump"
|
|
elif git log -1 --pretty=%B | grep -q "^fix:"; then
|
|
echo "🐛 Fix commit detected - consider PATCH version bump"
|
|
elif git log -1 --pretty=%B | grep -q "BREAKING CHANGE"; then
|
|
echo "💥 Breaking change detected - consider MAJOR version bump"
|
|
else
|
|
echo "⏭️ No automatic version bump needed"
|
|
fi
|