Skip to content
On this page

CI/CD Pipeline - R-Type Project by Master KALAMBO DANIEL

Ce document dΓ©crit le pipeline CI/CD complet du projet R-Type utilisant GitHub Actions.

Vue d'ensemble

Le pipeline se compose de 3 jobs principaux :

  1. Build & Test : Compilation et tests unitaires
  2. Docker Build & Push : CrΓ©ation et publication des images Docker
  3. Notify : Notifications de statut

πŸ”„ Workflow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Push/PR   β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Build & Test (Ubuntu)  β”‚
β”‚  - Install dependencies β”‚
β”‚  - Compile with CMake   β”‚
β”‚  - Run tests           β”‚
β”‚  - Upload artifacts     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚ (success)
           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Docker Build & Push    β”‚
β”‚  - Download artifacts   β”‚
β”‚  - Build Server image   β”‚
β”‚  - Build Client image   β”‚
β”‚  - Push to GHCR        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚
           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚     Notifications       β”‚
β”‚  - Summary report       β”‚
β”‚  - Status badges        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Push/PR   β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Build & Test (Ubuntu)  β”‚
β”‚  - Install dependencies β”‚
β”‚  - Compile with CMake   β”‚
β”‚  - Run tests           β”‚
β”‚  - Upload artifacts     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚ (success)
           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Docker Build & Push    β”‚
β”‚  - Download artifacts   β”‚
β”‚  - Build Server image   β”‚
β”‚  - Build Client image   β”‚
β”‚  - Push to GHCR        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚
           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚     Notifications       β”‚
β”‚  - Summary report       β”‚
β”‚  - Status badges        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

DΓ©clenchement

Le pipeline se dΓ©clenche automatiquement sur :

  • βœ… Push sur les branches : main, dev, develop
  • βœ… Pull Request vers main
  • βœ… DΓ©clenchement manuel via l'interface GitHub Actions

Job 1 : Build & Test

Environnement

  • OS : Ubuntu 22.04
  • Compiler : g++ (C++17)
  • Build System : CMake + Ninja
  • Package Manager : Conan 2.0

Γ‰tapes dΓ©taillΓ©es

  1. Checkout du code

    yaml
    - uses: actions/checkout@v4
    
    - uses: actions/checkout@v4
    
    1
  2. Installation des dépendances système

    • CMake, g++, Ninja
    • BibliothΓ¨ques SFML (OpenGL, X11, etc.)
    • Boost libraries
  3. Configuration Conan

    bash
    pip3 install conan==2.0.17
    conan profile detect
    conan install .. --build=missing
    
    pip3 install conan==2.0.17
    conan profile detect
    conan install .. --build=missing
    
    1
    2
    3
  4. Compilation CMake

    bash
    cmake -B build -DCMAKE_BUILD_TYPE=Release
    cmake --build build -j $(nproc)
    
    cmake -B build -DCMAKE_BUILD_TYPE=Release
    cmake --build build -j $(nproc)
    
    1
    2
  5. VΓ©rification des binaires

    • r-type_server
    • r-type_client
    • rtype_game
    • Plugins .so dans LibEngine/Systems/
  6. Upload des artifacts

    • Binaires compilΓ©s
    • Assets
    • Plugins
    • RΓ©tention : 7 jours

Artifacts produits

rtype-binaries-{SHA}/
β”œβ”€β”€ r-type_server
β”œβ”€β”€ r-type_client
β”œβ”€β”€ rtype_game
β”œβ”€β”€ LibEngine/Systems/*.so
└── Assets/**/*
rtype-binaries-{SHA}/
β”œβ”€β”€ r-type_server
β”œβ”€β”€ r-type_client
β”œβ”€β”€ rtype_game
β”œβ”€β”€ LibEngine/Systems/*.so
└── Assets/**/*
1
2
3
4
5
6

Job 2 : Docker Build & Push

Condition : Succès du Job 1 + Push sur main ou dev

Images créées

Image Serveur

  • Base : Ubuntu 22.04
  • Taille : ~200 MB
  • Port : 4242, 8080
  • Registry : ghcr.io/{owner}/{repo}/rtype-server
  • Tags :
    • latest (sur main)
    • {branch} (nom de la branche)
    • {branch}-{sha} (commit hash)

Image Client

  • Base : Ubuntu 22.04 + SFML
  • Taille : ~300 MB
  • Display : X11 forwarding requis
  • Registry : ghcr.io/{owner}/{repo}/rtype-client
  • Tags : (identiques au serveur)

Processus de build

mermaid
graph LR
    A[Download Artifacts] --> B[Prepare Files]
    B --> C[Build Server Image]
    B --> D[Build Client Image]
    C --> E[Push to GHCR]
    D --> E
graph LR
    A[Download Artifacts] --> B[Prepare Files]
    B --> C[Build Server Image]
    B --> D[Build Client Image]
    C --> E[Push to GHCR]
    D --> E
1
2
3
4
5
6

Authentication

Le pipeline utilise automatiquement GITHUB_TOKEN pour :

  • βœ… Pull/Push vers GitHub Container Registry
  • βœ… Permissions : contents:read, packages:write

Job 3 : Notifications

Ce job s'exΓ©cute toujours (mΓͺme en cas d'Γ©chec) et :

  • βœ… Affiche le statut du build
  • βœ… Affiche le statut du dΓ©ploiement Docker
  • βœ… GΓ©nΓ¨re un rΓ©sumΓ© dans GitHub Actions
  • ❌ Γ‰choue si le build a Γ©chouΓ©

Utilisation

DΓ©veloppement local

bash
# Compiler localement
mkdir build && cd build
conan install .. --build=missing
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . -j

# Tester
./r-type_server --help
./r-type_client --help
# Compiler localement
mkdir build && cd build
conan install .. --build=missing
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . -j

# Tester
./r-type_server --help
./r-type_client --help
1
2
3
4
5
6
7
8
9

DΓ©clencher le pipeline

bash
# MΓ©thode 1 : Push sur une branche surveillΓ©e
git add .
git commit -m "feat: nouvelle fonctionnalitΓ©"
git push origin main

# MΓ©thode 2 : Via l'interface GitHub
# Actions > CI/CD Pipeline > Run workflow
# MΓ©thode 1 : Push sur une branche surveillΓ©e
git add .
git commit -m "feat: nouvelle fonctionnalitΓ©"
git push origin main

# MΓ©thode 2 : Via l'interface GitHub
# Actions > CI/CD Pipeline > Run workflow
1
2
3
4
5
6
7

Utiliser les images Docker

bash
# Pull depuis GitHub Container Registry
docker pull ghcr.io/epitechpge3-2025/g-cpp-500-cot-5-1-rtype-2/rtype-server:latest

# Lancer le serveur
docker run -d -p 4242:4242 \
  ghcr.io/epitechpge3-2025/g-cpp-500-cot-5-1-rtype-2/rtype-server:latest
# Pull depuis GitHub Container Registry
docker pull ghcr.io/epitechpge3-2025/g-cpp-500-cot-5-1-rtype-2/rtype-server:latest

# Lancer le serveur
docker run -d -p 4242:4242 \
  ghcr.io/epitechpge3-2025/g-cpp-500-cot-5-1-rtype-2/rtype-server:latest
1
2
3
4
5
6

Monitoring

Via GitHub Actions UI

  1. AccΓ©dez Γ  Actions dans le repository
  2. SΓ©lectionnez le workflow "R-Type CI/CD Pipeline"
  3. Visualisez :
    • Status de chaque job
    • Temps d'exΓ©cution
    • Artifacts disponibles
    • Logs dΓ©taillΓ©s

Badges de statut

Ajoutez ces badges dans votre README :

markdown
![CI/CD](https://github.com/EpitechPGE3-2025/G-CPP-500-COT-5-1-rtype-2/actions/workflows/build.yaml/badge.svg)
![CI/CD](https://github.com/EpitechPGE3-2025/G-CPP-500-COT-5-1-rtype-2/actions/workflows/build.yaml/badge.svg)
1

Consulter les images Docker

bash
# Lister les tags disponibles
docker image ls | grep rtype

# Inspecter une image
docker inspect ghcr.io/epitechpge3-2025/g-cpp-500-cot-5-1-rtype-2/rtype-server:latest
# Lister les tags disponibles
docker image ls | grep rtype

# Inspecter une image
docker inspect ghcr.io/epitechpge3-2025/g-cpp-500-cot-5-1-rtype-2/rtype-server:latest
1
2
3
4
5

πŸ”§ Configuration

Variables d'environnement

DΓ©finies dans .github/workflows/build.yaml :

yaml
env:
  BUILD_TYPE: Release
  CONAN_VERSION: 2.0.17
env:
  BUILD_TYPE: Release
  CONAN_VERSION: 2.0.17
1
2
3

Secrets requis

  • GITHUB_TOKEN : Fourni automatiquement par GitHub Actions

Permissions

Le workflow nΓ©cessite :

yaml
permissions:
  contents: read    # Lire le code
  packages: write   # Publier les images Docker
permissions:
  contents: read    # Lire le code
  packages: write   # Publier les images Docker
1
2
3

πŸ“š Fichiers du pipeline

.github/workflows/
└── build.yaml                 # Pipeline principal

docker/
β”œβ”€β”€ Dockerfile.server          # Image serveur
β”œβ”€β”€ Dockerfile.client          # Image client
β”œβ”€β”€ docker-compose.yml         # Orchestration
└── README.md                  # Documentation Docker

.dockerignore                  # Exclusions Docker
.github/workflows/
└── build.yaml                 # Pipeline principal

docker/
β”œβ”€β”€ Dockerfile.server          # Image serveur
β”œβ”€β”€ Dockerfile.client          # Image client
β”œβ”€β”€ docker-compose.yml         # Orchestration
└── README.md                  # Documentation Docker

.dockerignore                  # Exclusions Docker
1
2
3
4
5
6
7
8
9
10

Avantages :

  • Builds plus rapides (2-3x)
  • RΓ©duction du temps de build
  • RΓ©utilisation des layers Docker

Build parallèle

yaml
cmake --build build -j $(nproc)
cmake --build build -j $(nproc)
1

Utilise tous les cΕ“urs CPU disponibles.

Artifacts retention

yaml
retention-days: 7
retention-days: 7
1

Les artifacts sont conservΓ©s 7 jours pour Γ©conomiser l'espace.

πŸ”— Liens utiles

πŸ“§ Support

En cas de problème :

  1. Consultez les logs GitHub Actions
  2. VΓ©rifiez la documentation Docker
  3. Ouvrez une issue sur GitHub