📝 docs: update CI/CD documentation for container/services approach

This commit is contained in:
2026-04-08 11:19:06 +02:00
parent db60de80ad
commit ec869d6d5b
2 changed files with 142 additions and 10 deletions

View File

@@ -43,11 +43,69 @@ go run ./cmd/greet
## CI/CD Pipeline
dance-lessons-coach includes a portable CI/CD pipeline using GitHub Actions syntax:
dance-lessons-coach features an optimized CI/CD pipeline using GitHub Actions with container/services architecture:
### Features
-**Multi-platform**: Works on Gitea, GitHub, and GitLab
-**Build & Test**: Automated Go builds and tests
### Key Features
-**Container-based execution**: All steps run in pre-built Docker cache images
-**Service-based PostgreSQL**: Automatic database service provisioning
-**Smart caching**: Dependency-aware cache invalidation
-**Multi-platform**: Compatible with Gitea, GitHub, and GitLab
-**Fast execution**: No Docker Compose overhead
-**Reliable testing**: Full database connectivity with proper environment setup
### Architecture
The pipeline uses GitHub Actions' native `container` and `services` directives instead of Docker Compose:
```yaml
jobs:
ci-pipeline:
container:
image: gitea.arcodange.lab/arcodange/dance-lessons-coach-build-cache:${{ needs.build-cache.outputs.deps_hash }}
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: dance_lessons_coach_bdd_test
```
### Benefits
1. **Performance**: Direct container execution without compose overhead
2. **Reliability**: Service containers managed by GitHub Actions
3. **Simplicity**: Cleaner workflow definition
4. **Portability**: Works across CI platforms
5. **Caching**: Intelligent dependency-based cache rebuilding
### Workflow Steps
1. **Build Cache**: Creates Docker image with Go tools and dependencies
2. **CI Pipeline**: Runs tests, builds binaries, and generates documentation
3. **Database Tests**: Connects to PostgreSQL service container
4. **Coverage Reporting**: Updates coverage badges automatically
5. **Artifact Publishing**: Builds and pushes Docker images (main branch only)
### Environment Configuration
The pipeline automatically sets up database environment variables:
```bash
echo "DLC_DATABASE_HOST=postgres" >> $GITHUB_ENV
echo "DLC_DATABASE_PORT=5432" >> $GITHUB_ENV
echo "DLC_DATABASE_USER=postgres" >> $GITHUB_ENV
echo "DLC_DATABASE_PASSWORD=postgres" >> $GITHUB_ENV
echo "DLC_DATABASE_NAME=dance_lessons_coach_bdd_test" >> $GITHUB_ENV
echo "DLC_DATABASE_SSL_MODE=disable" >> $GITHUB_ENV
```
### Status
[![Build Status](https://gitea.arcodange.fr/api/badges/arcodange/dance-lessons-coach/status)](https://gitea.arcodange.fr/arcodange/dance-lessons-coach)
[![Coverage](https://img.shields.io/badge/coverage-0%-red?style=flat-square)](https://gitea.arcodange.lab/arcodange/dance-lessons-coach)
=======
-**Linting**: Code quality checks with `go fmt` and `go vet`
-**Version Management**: Automatic version detection
-**Portable**: Uses standard GitHub Actions workflow format

View File

@@ -1,10 +1,10 @@
# 16. CI/CD Pipeline Design for Multi-Platform Compatibility
**Date:** 2026-04-05
**Status:** 🟡 Proposed
**Status:** ✅ Accepted
**Authors:** Arcodange Team
**Decision Date:** TBD
**Implementation Status:** Not Started
**Decision Date:** 2026-04-08
**Implementation Status:** ✅ Completed
## Context
@@ -758,7 +758,81 @@ graph TD
---
**Status:** Proposed
**Next Review:** 2026-04-12
## Implementation Status
### ✅ Completed - Container/Services Architecture
The CI/CD pipeline has been successfully implemented using GitHub Actions' container/services architecture:
**Key Implementation Details:**
1. **Container-based Execution**: All CI steps run within a pre-built Docker cache image containing Go tools, Node.js, and PostgreSQL client
2. **Service-based PostgreSQL**: Database provided as a service container, accessible via `postgres` hostname
3. **Smart Caching**: Dependency hash calculated from `go.mod`, `go.sum`, and `Dockerfile.build` for accurate cache invalidation
4. **Environment Configuration**: Database connection parameters set via `DLC_*` environment variables
5. **Simplified Workflow**: Removed Docker Compose overhead and unnecessary setup steps
**Current Workflow Structure:**
```yaml
jobs:
build-cache:
name: Build Docker Cache
# Calculates dependency hash and builds cache image if needed
ci-pipeline:
name: CI Pipeline
needs: build-cache
container:
image: gitea.arcodange.lab/arcodange/dance-lessons-coach-build-cache:${{ needs.build-cache.outputs.deps_hash }}
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: dance_lessons_coach_bdd_test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set database environment variables
run: |
echo "DLC_DATABASE_HOST=postgres" >> $GITHUB_ENV
echo "DLC_DATABASE_PORT=5432" >> $GITHUB_ENV
# ... other database config
- name: Generate Swagger Docs
run: go generate ./pkg/server
- name: Build all packages
run: go build ./...
- name: Wait for PostgreSQL to be ready
run: pg_isready -h postgres -p 5432
- name: Run tests with coverage
run: go test ./... -coverprofile=coverage.out
- name: Build binaries
run: ./scripts/build.sh
```
**Performance Improvements:**
-**Faster execution**: Direct container execution without compose overhead
-**Reliable caching**: Accurate dependency tracking with multi-file hash
-**Simpler debugging**: Clear container boundaries and service networking
-**Better portability**: Standard GitHub Actions patterns work across platforms
**Verification:**
-**Workflow 465**: Both jobs completed successfully (2026-04-08)
-**All tests passing**: Database connectivity working correctly
-**Coverage reporting**: Badges updating automatically
-**Binary builds**: Scripts executing properly in container environment
**Status:** ✅ Accepted
**Implementation Date:** 2026-04-08
**Implementation Owner:** Arcodange Team
**Approvers Needed:** @gabrielradureau
**Reviewers:** @gabrielradureau