From 35a5a56d4f46996a4ad3e1b4b5f1f49e913eadee Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 13:41:01 +0200 Subject: [PATCH 01/44] =?UTF-8?q?feat:=20premier=20commit=20=E2=80=94=20ac?= =?UTF-8?q?tivation=20de=20la=20CI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- notes.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 notes.md diff --git a/notes.md b/notes.md new file mode 100644 index 0000000..634ab3a --- /dev/null +++ b/notes.md @@ -0,0 +1 @@ +# Mon TP GitHub Actions \ No newline at end of file From 47b50899527f8d887707d5ffb9fe6138d63e47f3 Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 13:52:37 +0200 Subject: [PATCH 02/44] doc : Update readme --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 4abe121..5212faa 100644 --- a/README.md +++ b/README.md @@ -198,11 +198,18 @@ Ouvrez le fichier `.github/workflows/ci.yml` déjà présent dans ce repo. Répondez aux questions suivantes **sans modifier le fichier** : 1. Sur quelle(s) branche(s) ce workflow se déclenche-t-il ? + - Le workflow se déclenche sur la branche "main" 2. Combien de jobs contient-il ? + - Il contient un job 3. Sur quel système d'exploitation tourne-t-il ? + - Il tourne sur ubuntu 4. Quelle action installe Python ? + - - uses: actions/setup-python@v5 + with: + python-version: '3.12' 5. Quelle commande lance les tests ? + Vérifiez vos réponses en allant dans l'onglet **Actions** de votre repo GitHub après votre premier push. --- From 62bb87bbfbbd0d9dd8de07d867dabb978c78567d Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 13:55:32 +0200 Subject: [PATCH 03/44] feat : Add hello.yml file --- .github/workflows/hello.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/hello.yml diff --git a/.github/workflows/hello.yml b/.github/workflows/hello.yml new file mode 100644 index 0000000..36dcda2 --- /dev/null +++ b/.github/workflows/hello.yml @@ -0,0 +1,24 @@ +name: Hello NexaCloud + +on: + push: + branches: [main] + workflow_dispatch: # permet de déclencher manuellement depuis l'interface GitHub + +jobs: + salutation: + runs-on: ubuntu-latest + + steps: + - name: Checkout du code + uses: actions/checkout@v4 + + - name: Informations sur l'environnement + run: | + echo "Repo : ${{ github.repository }}" + echo "Branche : ${{ github.ref_name }}" + echo "Commit : ${{ github.sha }}" + echo "Acteur : ${{ github.actor }}" + + - name: Lister les fichiers du repo + run: ls -la From ad93dbc4f26b9182eb91dd335a0f7822897a1030 Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 14:13:08 +0200 Subject: [PATCH 04/44] feat : show date --- .github/workflows/hello.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/hello.yml b/.github/workflows/hello.yml index 36dcda2..aae5574 100644 --- a/.github/workflows/hello.yml +++ b/.github/workflows/hello.yml @@ -22,3 +22,6 @@ jobs: - name: Lister les fichiers du repo run: ls -la + + - name: Afficher la date et l'heure + run: date From 923c8004e005fc33dc0f949880010b5944d7d4e4 Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 14:20:33 +0200 Subject: [PATCH 05/44] feat: install python and run test --- .github/workflows/hello.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/hello.yml b/.github/workflows/hello.yml index aae5574..5ec3a99 100644 --- a/.github/workflows/hello.yml +++ b/.github/workflows/hello.yml @@ -25,3 +25,14 @@ jobs: - name: Afficher la date et l'heure run: date + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install dependencies + run: pip install -r requirements.txt + + - name: Run tests + run: pytest ressources/ -v From 29b6aa73c3201e355bd97c4f2eab75a4b672a926 Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 14:22:01 +0200 Subject: [PATCH 06/44] fix: fix requirements.txt path --- .github/workflows/hello.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hello.yml b/.github/workflows/hello.yml index 5ec3a99..3148e0c 100644 --- a/.github/workflows/hello.yml +++ b/.github/workflows/hello.yml @@ -32,7 +32,7 @@ jobs: python-version: "3.11" - name: Install dependencies - run: pip install -r requirements.txt + run: pip install -r ressources/requirements.txt - name: Run tests run: pytest ressources/ -v From 9c2e60d4acd6894085d2c9d46e57c242ed086a20 Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 14:25:59 +0200 Subject: [PATCH 07/44] fix : remove steps friom file to add it in ci.yml --- .github/workflows/hello.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/hello.yml b/.github/workflows/hello.yml index 3148e0c..aae5574 100644 --- a/.github/workflows/hello.yml +++ b/.github/workflows/hello.yml @@ -25,14 +25,3 @@ jobs: - name: Afficher la date et l'heure run: date - - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: "3.11" - - - name: Install dependencies - run: pip install -r ressources/requirements.txt - - - name: Run tests - run: pytest ressources/ -v From 0b51502f6d0a985c1c33ee8afb0cef31fc96c7fd Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 14:26:19 +0200 Subject: [PATCH 08/44] feat: Add steps to install python dependencies --- .github/workflows/ci.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0a27357..c027da3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,9 +2,9 @@ name: CI on: push: - branches: [ "main" ] + branches: ["main"] pull_request: - branches: [ "main" ] + branches: ["main"] jobs: build: @@ -16,3 +16,14 @@ jobs: - name: Example step run: echo "Add your build/test steps here!" + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install dependencies + run: pip install -r ressources/requirements.txt + + - name: Run tests + run: pytest ressources/ -v From 9b98fa094d2de6dce24ee38ecd67ebfb21d37632 Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 14:28:52 +0200 Subject: [PATCH 09/44] feat: Add steps to check lint --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c027da3..ec0d65c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,3 +27,9 @@ jobs: - name: Run tests run: pytest ressources/ -v + + - name: Install flake8 + run: pip install flake8 + + - name: Lint with flake8 + run: flake8 ressources/ --config ressources/.flake8 From 556cbf37e767b63a6e26eba0f8009185811b9239 Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 14:34:47 +0200 Subject: [PATCH 10/44] feat: update to test ci error --- ressources/test_app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ressources/test_app.py b/ressources/test_app.py index ce56a43..e328cb1 100644 --- a/ressources/test_app.py +++ b/ressources/test_app.py @@ -18,7 +18,7 @@ def test_index_status(client): response = client.get("/") assert response.status_code == 200 data = response.get_json() - assert data["status"] == "ok" + assert data["status"] == "not ok" assert data["service"] == "NexaCloud API" From 8690a2507ec30ecd57e78375ebe7f7bcbb8fd80e Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 14:36:28 +0200 Subject: [PATCH 11/44] fix: correction of status value for test_index_status test --- ressources/test_app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ressources/test_app.py b/ressources/test_app.py index e328cb1..ce56a43 100644 --- a/ressources/test_app.py +++ b/ressources/test_app.py @@ -18,7 +18,7 @@ def test_index_status(client): response = client.get("/") assert response.status_code == 200 data = response.get_json() - assert data["status"] == "not ok" + assert data["status"] == "ok" assert data["service"] == "NexaCloud API" From b54f06446cd14ca6d154ca071a6d3cf2dbac9e4c Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 14:46:12 +0200 Subject: [PATCH 12/44] feat: Update to add to job in parallel --- .github/workflows/ci.yml | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ec0d65c..ecb9a31 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,35 +1,44 @@ -name: CI +name: CI — NexaCloud API on: push: - branches: ["main"] + branches: [main] pull_request: - branches: ["main"] + branches: [main] jobs: - build: + lint: runs-on: ubuntu-latest steps: - - name: Checkout code + - name: Checkout uses: actions/checkout@v4 - - name: Example step - run: echo "Add your build/test steps here!" + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Installer flake8 + run: pip install flake8 + + - name: Lint avec flake8 + run: flake8 ressources/ --config ressources/.flake8 + + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 - name: Setup Python uses: actions/setup-python@v5 with: python-version: "3.11" - - name: Install dependencies + - name: Installer les dépendances run: pip install -r ressources/requirements.txt - - name: Run tests + - name: Lancer les tests run: pytest ressources/ -v - - - name: Install flake8 - run: pip install flake8 - - - name: Lint with flake8 - run: flake8 ressources/ --config ressources/.flake8 From 9ad1def97ad67077adfc986bb6dc73f6f36d94f9 Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 14:46:34 +0200 Subject: [PATCH 13/44] feat: test if API_KEY exist --- .github/workflows/secrets.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/secrets.yml diff --git a/.github/workflows/secrets.yml b/.github/workflows/secrets.yml new file mode 100644 index 0000000..e163308 --- /dev/null +++ b/.github/workflows/secrets.yml @@ -0,0 +1,15 @@ +name: Demo Secrets + +on: + workflow_dispatch: + +jobs: + demo: + runs-on: ubuntu-latest + + steps: + - name: Utiliser le secret + run: | + echo "La clé existe : ${{ secrets.API_KEY != '' }}" + # ⚠️ Cette ligne sera masquée dans les logs : + echo "Valeur : ${{ secrets.API_KEY }}" From a5f53ac91f29f347c36b40fec49cf59ecbf7afde Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 14:55:51 +0200 Subject: [PATCH 14/44] feat: Add pip on cache - run test with coverage and generate and upload html report --- .github/workflows/ci.yml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ecb9a31..3a82bc3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,5 +40,21 @@ jobs: - name: Installer les dépendances run: pip install -r ressources/requirements.txt - - name: Lancer les tests - run: pytest ressources/ -v + - name: Tests with coverage + run: pytest ressources/ -v --cov=ressources --cov-report=term-missing + + - name: Generate the HTML report + run: pytest ressources/ --cov=ressources --cov-report=html + + - name: Upload the report + uses: actions/upload-artifact@v4 + with: + name: rapport-couverture + path: htmlcov/ + + # Mettre en cache les dépendances pip (accélère les builds suivants) + - name: Cache pip + uses: actions/cache@v4 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('ressources/requirements.txt') }} From 7338bdf6ec85d6a3efecbb14a87c84f42da74c87 Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 15:04:39 +0200 Subject: [PATCH 15/44] feat: Add environment variable and add condition to check if API_KEY exist --- .github/workflows/secrets.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/secrets.yml b/.github/workflows/secrets.yml index e163308..11cec49 100644 --- a/.github/workflows/secrets.yml +++ b/.github/workflows/secrets.yml @@ -7,9 +7,14 @@ jobs: demo: runs-on: ubuntu-latest + env: + API_KEY: ${{ secrets.API_KEY }} + steps: - - name: Utiliser le secret + - name: Vérifier que le secret est défini run: | - echo "La clé existe : ${{ secrets.API_KEY != '' }}" - # ⚠️ Cette ligne sera masquée dans les logs : - echo "Valeur : ${{ secrets.API_KEY }}" + if [ -z "$API_KEY" ]; then + echo "❌ Le secret API_KEY n'est pas défini" + exit 1 + fi + echo "✅ Le secret API_KEY est défini (${#API_KEY} caractères)" From 91c1a3014cc3a6f117284d223e884120c9a861d2 Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 15:08:43 +0200 Subject: [PATCH 16/44] feat: Add deploy.yml to deploy in staging and production environment --- .github/workflows/deploy.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..3f09c68 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,22 @@ +name: Deploy + +on: + workflow_dispatch: + +jobs: + deploy-staging: + runs-on: ubuntu-latest + environment: staging # utilise l'environnement staging + + steps: + - name: Déployer en staging + run: echo "Déploiement en staging..." + + deploy-production: + runs-on: ubuntu-latest + environment: production # TODO: ajouter la dépendance sur deploy-staging + needs: deploy-staging + + steps: + - name: Déployer en production + run: echo "Déploiement en production !" From a34c9f688324dbbe8f1351b3cd606e86cef6fd46 Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 15:16:21 +0200 Subject: [PATCH 17/44] feat(deploy.yml): Update to choose environment --- .github/workflows/deploy.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3f09c68..05470ef 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,21 +2,21 @@ name: Deploy on: workflow_dispatch: + inputs: + environment: + description: "Choose the deployment environment" + required: true + default: "staging" + type: choice + options: + - staging + - production jobs: - deploy-staging: + deploy: runs-on: ubuntu-latest - environment: staging # utilise l'environnement staging + environment: ${{ inputs.environment }} steps: - - name: Déployer en staging - run: echo "Déploiement en staging..." - - deploy-production: - runs-on: ubuntu-latest - environment: production # TODO: ajouter la dépendance sur deploy-staging - needs: deploy-staging - - steps: - - name: Déployer en production - run: echo "Déploiement en production !" + - name: "Déployer en ${{ inputs.environment }}" + run: echo "Déploiement en ${{ inputs.environment }}..." From e3ef99b20f5d61844e5fd2f4210a8ff4651835c9 Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 15:32:52 +0200 Subject: [PATCH 18/44] feat(cicd.yml): Add script to deploy on azure services --- .github/workflows/cicd.yml | 56 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/cicd.yml diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml new file mode 100644 index 0000000..10cb1a3 --- /dev/null +++ b/.github/workflows/cicd.yml @@ -0,0 +1,56 @@ +name: CI/CD — NexaCloud API + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + # ── Job 1 : Qualité ──────────────────────────────────────────────── + qualite: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - run: pip install -r ressources/requirements.txt + + - name: Lint + run: flake8 ressources/ --config ressources/.flake8 + + - name: Tests + run: pytest ressources/ -v --cov=ressources + + # ── Job 2 : Staging ─────────────────────────────────────────────── + staging: + runs-on: ubuntu-latest + needs: qualite + environment: staging + if: github.ref_name == 'main' + + steps: + - uses: actions/checkout@v4 + + - name: Deploy Staging on Azure App Service + run: | + echo "Deploying staging to Azure App Service..." + + + # ── Job 3 : Production ──────────────────────────────────────────── + production: + runs-on: ubuntu-latest + needs: staging + environment: production + if: github.ref_name == 'main' + + steps: + - uses: actions/checkout@v4 + + - name: Deploy Production on Azure App Service + run: | + echo "Deploying production to Azure App Service..." From 829352c11e27d65d38eeef32df462ce02a2f5eec Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 16:01:35 +0200 Subject: [PATCH 19/44] chore: --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 78e7733..5490ba9 100644 --- a/.gitignore +++ b/.gitignore @@ -36,9 +36,12 @@ override.tf.json .terraformrc terraform.rc +# Ignore pre-commit configuration file if it contains sensitive data or is specific to local development +.pre-commit-config.yaml + # Optional: ignore graph output files generated by `terraform graph` # *.dot # Optional: ignore plan files saved before destroying Terraform configuration # Uncomment the line below if you want to ignore planout files. -# planout \ No newline at end of file +# planout From b88cce6ac88f21a90bf99b6bbb6bed0cc2ece6b4 Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 16:02:28 +0200 Subject: [PATCH 20/44] docs: remove empty space --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5212faa..b51e198 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # TP GitHub Actions — CI/CD et automatisation -**Durée estimée :** 6h -**Prérequis :** Git, GitHub, bases Bash ou PowerShell (TPs précédents) +**Durée estimée :** 6h +**Prérequis :** Git, GitHub, bases Bash ou PowerShell (TPs précédents) **Environnement :** tout OS avec Git installé et un compte GitHub actif --- @@ -249,7 +249,7 @@ Commitez et pushez. Observez l'exécution dans l'onglet **Actions**. > ✏️ **À vous** > -> Ajoutez un step qui affiche la date et l'heure du runner avec `date`. +> Ajoutez un step qui affiche la date et l'heure du runner avec `date`. > Puis déclenchez le workflow **manuellement** depuis l'interface GitHub (bouton "Run workflow").
From 5983ad914386cdcf144c78db58897c3d91148452 Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 16:02:45 +0200 Subject: [PATCH 21/44] refactor: refacto file --- .github/workflows/cicd.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 10cb1a3..8a78663 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -35,11 +35,11 @@ jobs: steps: - uses: actions/checkout@v4 - + - name: Deploy Staging on Azure App Service run: | echo "Deploying staging to Azure App Service..." - + # ── Job 3 : Production ──────────────────────────────────────────── production: From bc34117b3b548ac1d40e37c23d5125ceb2adb06a Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 16:03:57 +0200 Subject: [PATCH 22/44] test: Add empty space --- ressources/app.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ressources/app.py b/ressources/app.py index d7e75f2..60026e7 100644 --- a/ressources/app.py +++ b/ressources/app.py @@ -23,6 +23,7 @@ def index(): @app.route("/health") def health(): + return jsonify({"status": "healthy"}) From 5b3404fa4aa392bcbdd437a1446d0e3b111a180a Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 16:04:40 +0200 Subject: [PATCH 23/44] refacto:r: remove empty space --- ressources/app.py | 1 - 1 file changed, 1 deletion(-) diff --git a/ressources/app.py b/ressources/app.py index 60026e7..d7e75f2 100644 --- a/ressources/app.py +++ b/ressources/app.py @@ -23,7 +23,6 @@ def index(): @app.route("/health") def health(): - return jsonify({"status": "healthy"}) From c1be86323811c67a35003616c708cbce9213024e Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 16:04:53 +0200 Subject: [PATCH 24/44] refactor: refacto --- notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notes.md b/notes.md index 634ab3a..2c821cd 100644 --- a/notes.md +++ b/notes.md @@ -1 +1 @@ -# Mon TP GitHub Actions \ No newline at end of file +# Mon TP GitHub Actions From 02b0ec0e1db0c2fdba39802aa036243cda903489 Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 16:24:22 +0200 Subject: [PATCH 25/44] chore: Add setup-hooks.sh --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 5490ba9..34d894f 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,9 @@ terraform.rc # Ignore pre-commit configuration file if it contains sensitive data or is specific to local development .pre-commit-config.yaml +# Ignore setup script for git hooks if it is specific to local development and not needed in the repository +setup-hooks.sh + # Optional: ignore graph output files generated by `terraform graph` # *.dot From e5529a0916e708d74c46b5e20782b6445d1c346d Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 16:26:59 +0200 Subject: [PATCH 26/44] chore: Add python cache --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 34d894f..b6b4f9d 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,11 @@ terraform.rc # Ignore setup script for git hooks if it is specific to local development and not needed in the repository setup-hooks.sh +# Ignore Python cache files and compiled bytecode, which are not necessary to include in version control +__pycache__/ +*.pyc + + # Optional: ignore graph output files generated by `terraform graph` # *.dot From 7317ca81012ca3c68c5d680df4b2bc0cc43dec01 Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 16:48:24 +0200 Subject: [PATCH 27/44] chore: Add .pre-commit-config.yaml --- .pre-commit-config.yaml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..bb4ae21 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,23 @@ +repos: + - repo: https://github.com/pycqa/flake8 + rev: 7.0.0 + hooks: + - id: flake8 + args: [--config, ressources/.flake8] + files: ressources/.*\.py$ + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-merge-conflict + - id: check-added-large-files + args: [--maxkb=500] + + - repo: https://github.com/pycqa/isort + rev: 5.13.2 + hooks: + - id: isort # trie automatiquement les imports Python + files: ressources/.*\.py$ From a42836ed9bd4ccb51670745ef653017fa9da3ec8 Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 16:48:41 +0200 Subject: [PATCH 28/44] chore: remove pre-commit from gitignore --- .gitignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index b6b4f9d..f0d695f 100644 --- a/.gitignore +++ b/.gitignore @@ -36,9 +36,6 @@ override.tf.json .terraformrc terraform.rc -# Ignore pre-commit configuration file if it contains sensitive data or is specific to local development -.pre-commit-config.yaml - # Ignore setup script for git hooks if it is specific to local development and not needed in the repository setup-hooks.sh From 46f08c867415fd22c77ba6bd0a715dba597f6feb Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 16:48:57 +0200 Subject: [PATCH 29/44] feat: Add pre-commit job --- .github/workflows/ci.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a82bc3..33bca04 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,16 @@ on: branches: [main] jobs: + pre-commit: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Run pre-commit hooks + uses: pre-commit/action@v3.0.1 + lint: runs-on: ubuntu-latest From 3ef2d3bf7bc59bdeae442087d9acf2db553c356b Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 16:49:35 +0200 Subject: [PATCH 30/44] feat: Add dependabot.yml --- .github/dependabot.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..b3d2a93 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,21 @@ +version: 2 + +updates: + # ── Mettre à jour les actions GitHub ────────────────────────────── + - package-ecosystem: "github-actions" + directory: "/" # cherche dans .github/workflows/ + schedule: + interval: "weekly" # vérifie chaque semaine + labels: + - "dependencies" + - "github-actions" + + # ── Mettre à jour les dépendances Python ────────────────────────── + - package-ecosystem: "pip" + directory: "/ressources" # cherche requirements.txt ici + schedule: + interval: "weekly" + labels: + - "dependencies" + - "python" + open-pull-requests-limit: 5 # max 5 PRs ouvertes en même temps From 2d583023e735a29b1e00c23ca15d711e8a8e1c9b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Jun 2026 14:51:51 +0000 Subject: [PATCH 31/44] chore(deps): bump actions/cache from 4 to 5 Bumps [actions/cache](https://github.com/actions/cache) from 4 to 5. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/cache dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 33bca04..a817f22 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,7 +64,7 @@ jobs: # Mettre en cache les dépendances pip (accélère les builds suivants) - name: Cache pip - uses: actions/cache@v4 + uses: actions/cache@v5 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ hashFiles('ressources/requirements.txt') }} From fe5c4e48b15aa73fccad896d73fbd778c32f8525 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Jun 2026 14:51:54 +0000 Subject: [PATCH 32/44] chore(deps): bump actions/upload-artifact from 4 to 7 Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 7. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v4...v7) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-version: '7' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 33bca04..e0dbb72 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,7 +57,7 @@ jobs: run: pytest ressources/ --cov=ressources --cov-report=html - name: Upload the report - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: rapport-couverture path: htmlcov/ From e2340fb2751fb2f7f13ca0e4aecd8d1750732d4b Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Thu, 4 Jun 2026 16:52:04 +0200 Subject: [PATCH 33/44] chore: Add comment to enable dependabot --- .github/dependabot.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index b3d2a93..734d14d 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,3 +1,5 @@ +# dependabot.yml + version: 2 updates: From bd5399a955f0be068492c996b1b4b9c19627722c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Jun 2026 14:52:06 +0000 Subject: [PATCH 34/44] chore(deps): bump flask from 3.0.3 to 3.1.3 in /ressources Bumps [flask](https://github.com/pallets/flask) from 3.0.3 to 3.1.3. - [Release notes](https://github.com/pallets/flask/releases) - [Changelog](https://github.com/pallets/flask/blob/main/CHANGES.rst) - [Commits](https://github.com/pallets/flask/compare/3.0.3...3.1.3) --- updated-dependencies: - dependency-name: flask dependency-version: 3.1.3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- ressources/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ressources/requirements.txt b/ressources/requirements.txt index ff3cf3e..ba72839 100644 --- a/ressources/requirements.txt +++ b/ressources/requirements.txt @@ -1,4 +1,4 @@ -flask==3.0.3 +flask==3.1.3 pytest==8.2.0 pytest-cov==5.0.0 flake8==7.0.0 From 8979004f140a4b33efb417abd387834743a9c92f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Jun 2026 14:52:12 +0000 Subject: [PATCH 35/44] chore(deps): bump pytest from 8.2.0 to 9.0.3 in /ressources Bumps [pytest](https://github.com/pytest-dev/pytest) from 8.2.0 to 9.0.3. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/8.2.0...9.0.3) --- updated-dependencies: - dependency-name: pytest dependency-version: 9.0.3 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- ressources/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ressources/requirements.txt b/ressources/requirements.txt index ff3cf3e..f24d0b4 100644 --- a/ressources/requirements.txt +++ b/ressources/requirements.txt @@ -1,5 +1,5 @@ flask==3.0.3 -pytest==8.2.0 +pytest==9.0.3 pytest-cov==5.0.0 flake8==7.0.0 gunicorn==26.0.0 From f3ce2ec63a5dd326d80a0d98f01f48ea6b8debd0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Jun 2026 14:57:32 +0000 Subject: [PATCH 36/44] chore(deps): bump pytest-cov from 5.0.0 to 7.1.0 in /ressources Bumps [pytest-cov](https://github.com/pytest-dev/pytest-cov) from 5.0.0 to 7.1.0. - [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest-cov/compare/v5.0.0...v7.1.0) --- updated-dependencies: - dependency-name: pytest-cov dependency-version: 7.1.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- ressources/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ressources/requirements.txt b/ressources/requirements.txt index 2fdc3dd..7ca45ce 100644 --- a/ressources/requirements.txt +++ b/ressources/requirements.txt @@ -1,5 +1,5 @@ flask==3.1.3 pytest==9.0.3 -pytest-cov==5.0.0 +pytest-cov==7.1.0 flake8==7.0.0 gunicorn==26.0.0 From 3be084d876e44c63ea60a508ee0103cfa466c66b Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Fri, 5 Jun 2026 09:03:24 +0200 Subject: [PATCH 37/44] refactor : refacto code --- .github/workflows/cicd.yml | 79 +++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 8a78663..2ee156c 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -1,56 +1,55 @@ name: CI/CD — NexaCloud API on: - push: - branches: [main] - pull_request: - branches: [main] + push: + branches: [main] + pull_request: + branches: [main] jobs: - # ── Job 1 : Qualité ──────────────────────────────────────────────── - qualite: - runs-on: ubuntu-latest + # ── Job 1 : Qualité ──────────────────────────────────────────────── + qualite: + runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 + steps: + - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: "3.11" + - uses: actions/setup-python@v5 + with: + python-version: "3.11" - - run: pip install -r ressources/requirements.txt + - run: pip install -r ressources/requirements.txt - - name: Lint - run: flake8 ressources/ --config ressources/.flake8 + - name: Lint + run: flake8 ressources/ --config ressources/.flake8 - - name: Tests - run: pytest ressources/ -v --cov=ressources + - name: Tests + run: pytest ressources/ -v --cov=ressources - # ── Job 2 : Staging ─────────────────────────────────────────────── - staging: - runs-on: ubuntu-latest - needs: qualite - environment: staging - if: github.ref_name == 'main' + # ── Job 2 : Staging ─────────────────────────────────────────────── + staging: + runs-on: ubuntu-latest + needs: qualite + environment: staging + if: github.ref_name == 'main' - steps: - - uses: actions/checkout@v4 + steps: + - uses: actions/checkout@v4 - - name: Deploy Staging on Azure App Service - run: | - echo "Deploying staging to Azure App Service..." + - name: Deploy Staging on Azure App Service + run: | + echo "Deploying staging to Azure App Service..." + # ── Job 3 : Production ──────────────────────────────────────────── + production: + runs-on: ubuntu-latest + needs: staging + environment: production + if: github.ref_name == 'main' - # ── Job 3 : Production ──────────────────────────────────────────── - production: - runs-on: ubuntu-latest - needs: staging - environment: production - if: github.ref_name == 'main' + steps: + - uses: actions/checkout@v4 - steps: - - uses: actions/checkout@v4 - - - name: Deploy Production on Azure App Service - run: | - echo "Deploying production to Azure App Service..." + - name: Deploy Production on Azure App Service + run: | + echo "Deploying production to Azure App Service..." From 71d8a1c991af91fd7948ffdbcb5cb3cf2232d7b8 Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Fri, 5 Jun 2026 09:03:28 +0200 Subject: [PATCH 38/44] refactor : refacto code --- .github/workflows/hello.yml | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/hello.yml b/.github/workflows/hello.yml index aae5574..5e19fe4 100644 --- a/.github/workflows/hello.yml +++ b/.github/workflows/hello.yml @@ -1,27 +1,27 @@ name: Hello NexaCloud on: - push: - branches: [main] - workflow_dispatch: # permet de déclencher manuellement depuis l'interface GitHub + push: + branches: [main] + workflow_dispatch: # permet de déclencher manuellement depuis l'interface GitHub jobs: - salutation: - runs-on: ubuntu-latest + salutation: + runs-on: ubuntu-latest - steps: - - name: Checkout du code - uses: actions/checkout@v4 + steps: + - name: Checkout du code + uses: actions/checkout@v4 - - name: Informations sur l'environnement - run: | - echo "Repo : ${{ github.repository }}" - echo "Branche : ${{ github.ref_name }}" - echo "Commit : ${{ github.sha }}" - echo "Acteur : ${{ github.actor }}" + - name: Informations sur l'environnement + run: | + echo "Repo : ${{ github.repository }}" + echo "Branche : ${{ github.ref_name }}" + echo "Commit : ${{ github.sha }}" + echo "Acteur : ${{ github.actor }}" - - name: Lister les fichiers du repo - run: ls -la + - name: Lister les fichiers du repo + run: ls -la - - name: Afficher la date et l'heure - run: date + - name: Afficher la date et l'heure + run: date From b23af94367944993ca5df95d8b3977d86446bd12 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Jun 2026 07:07:38 +0000 Subject: [PATCH 39/44] chore(deps): bump actions/checkout from 4 to 6 Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 6. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v4...v6) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 6 +++--- .github/workflows/cicd.yml | 6 +++--- .github/workflows/hello.yml | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a817f22..0a78bef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Run pre-commit hooks uses: pre-commit/action@v3.0.1 @@ -22,7 +22,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup Python uses: actions/setup-python@v5 @@ -40,7 +40,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup Python uses: actions/setup-python@v5 diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 2ee156c..d9c5d40 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - uses: actions/setup-python@v5 with: @@ -34,7 +34,7 @@ jobs: if: github.ref_name == 'main' steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Deploy Staging on Azure App Service run: | @@ -48,7 +48,7 @@ jobs: if: github.ref_name == 'main' steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Deploy Production on Azure App Service run: | diff --git a/.github/workflows/hello.yml b/.github/workflows/hello.yml index 5e19fe4..388af3f 100644 --- a/.github/workflows/hello.yml +++ b/.github/workflows/hello.yml @@ -11,7 +11,7 @@ jobs: steps: - name: Checkout du code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Informations sur l'environnement run: | From a71e67dd7ae05f92dac5f4143ecfb1b607caf06a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Jun 2026 07:07:59 +0000 Subject: [PATCH 40/44] chore(deps): bump actions/setup-python from 5 to 6 Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5 to 6. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v5...v6) --- updated-dependencies: - dependency-name: actions/setup-python dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 4 ++-- .github/workflows/cicd.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a817f22..4555b0e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: "3.11" @@ -43,7 +43,7 @@ jobs: uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: "3.11" diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 2ee156c..80e484e 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: actions/setup-python@v6 with: python-version: "3.11" From f70bcce0b0d72285b6153cbd2509f088d4449f16 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Jun 2026 07:08:23 +0000 Subject: [PATCH 41/44] chore(deps): bump flake8 from 7.0.0 to 7.3.0 in /ressources Bumps [flake8](https://github.com/pycqa/flake8) from 7.0.0 to 7.3.0. - [Commits](https://github.com/pycqa/flake8/compare/7.0.0...7.3.0) --- updated-dependencies: - dependency-name: flake8 dependency-version: 7.3.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- ressources/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ressources/requirements.txt b/ressources/requirements.txt index 7ca45ce..5df0e38 100644 --- a/ressources/requirements.txt +++ b/ressources/requirements.txt @@ -1,5 +1,5 @@ flask==3.1.3 pytest==9.0.3 pytest-cov==7.1.0 -flake8==7.0.0 +flake8==7.3.0 gunicorn==26.0.0 From 686bdf1f5292d5888c677056769902164d3306a0 Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Fri, 5 Jun 2026 10:02:37 +0200 Subject: [PATCH 42/44] feat: Add CODEOWNERS --- .github/CODEOWNERS | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..7a53bb1 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,12 @@ +# Par défaut : tout changement requiert une review de ces personnes +* @MalikCherfi + +# Les workflows CI/CD ne peuvent être modifiés que par le lead DevOps +.github/workflows/ @MalikCherfi + +# Le fichier de dépendances requiert une validation technique +ressources/requirements.txt @MalikCherfi + +# Les fichiers de sécurité requièrent une double validation +.github/dependabot.yml @MalikCherfi +.github/CODEOWNERS @MalikCherfi From 755703fc715fbd72b2057ce08a25ca82dc8365e6 Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Fri, 5 Jun 2026 10:10:21 +0200 Subject: [PATCH 43/44] feat: log errors --- ressources/app.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ressources/app.py b/ressources/app.py index d7e75f2..e3885f4 100644 --- a/ressources/app.py +++ b/ressources/app.py @@ -38,5 +38,12 @@ def logs_critical(): return jsonify({"critical_count": seuil, "alerte": alerte}) +@app.route("/logs/error") +def logs_error(): + seuil = LOG_SUMMARY["error"] + alerte = seuil > 0 + return jsonify({"error_count": seuil, "alerte": alerte}) + + if __name__ == "__main__": app.run(debug=True, port=5001) From 6f6acdd6bf553c68efc356bee34e243b8d03b059 Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Fri, 5 Jun 2026 10:10:41 +0200 Subject: [PATCH 44/44] feat: test log error function --- ressources/test_app.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ressources/test_app.py b/ressources/test_app.py index ce56a43..be9e3dc 100644 --- a/ressources/test_app.py +++ b/ressources/test_app.py @@ -57,3 +57,13 @@ def test_logs_critical_alerte(client): assert "critical_count" in data assert "alerte" in data assert data["alerte"] is True + + +def test_logs_error_alerte(client): + """L'alerte est active quand il y a des erreurs.""" + response = client.get("/logs/error") + assert response.status_code == 200 + data = response.get_json() + assert "error_count" in data + assert "alerte" in data + assert data["alerte"] is True