Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
35a5a56
feat: premier commit — activation de la CI
MalikCherfi Jun 4, 2026
47b5089
doc : Update readme
MalikCherfi Jun 4, 2026
62bb87b
feat : Add hello.yml file
MalikCherfi Jun 4, 2026
ad93dbc
feat : show date
MalikCherfi Jun 4, 2026
923c800
feat: install python and run test
MalikCherfi Jun 4, 2026
29b6aa7
fix: fix requirements.txt path
MalikCherfi Jun 4, 2026
9c2e60d
fix : remove steps friom file to add it in ci.yml
MalikCherfi Jun 4, 2026
0b51502
feat: Add steps to install python dependencies
MalikCherfi Jun 4, 2026
9b98fa0
feat: Add steps to check lint
MalikCherfi Jun 4, 2026
556cbf3
feat: update to test ci error
MalikCherfi Jun 4, 2026
8690a25
fix: correction of status value for test_index_status test
MalikCherfi Jun 4, 2026
b54f064
feat: Update to add to job in parallel
MalikCherfi Jun 4, 2026
9ad1def
feat: test if API_KEY exist
MalikCherfi Jun 4, 2026
a5f53ac
feat: Add pip on cache - run test with coverage and generate and uplo…
MalikCherfi Jun 4, 2026
7338bdf
feat: Add environment variable and add condition to check if API_KEY …
MalikCherfi Jun 4, 2026
91c1a30
feat: Add deploy.yml to deploy in staging and production environment
MalikCherfi Jun 4, 2026
a34c9f6
feat(deploy.yml): Update to choose environment
MalikCherfi Jun 4, 2026
e3ef99b
feat(cicd.yml): Add script to deploy on azure services
MalikCherfi Jun 4, 2026
829352c
chore:
MalikCherfi Jun 4, 2026
b88cce6
docs: remove empty space
MalikCherfi Jun 4, 2026
5983ad9
refactor: refacto file
MalikCherfi Jun 4, 2026
bc34117
test: Add empty space
MalikCherfi Jun 4, 2026
5b3404f
refacto:r: remove empty space
MalikCherfi Jun 4, 2026
c1be863
refactor: refacto
MalikCherfi Jun 4, 2026
02b0ec0
chore: Add setup-hooks.sh
MalikCherfi Jun 4, 2026
e5529a0
chore: Add python cache
MalikCherfi Jun 4, 2026
7317ca8
chore: Add .pre-commit-config.yaml
MalikCherfi Jun 4, 2026
a42836e
chore: remove pre-commit from gitignore
MalikCherfi Jun 4, 2026
46f08c8
feat: Add pre-commit job
MalikCherfi Jun 4, 2026
3ef2d3b
feat: Add dependabot.yml
MalikCherfi Jun 4, 2026
2d58302
chore(deps): bump actions/cache from 4 to 5
dependabot[bot] Jun 4, 2026
fe5c4e4
chore(deps): bump actions/upload-artifact from 4 to 7
dependabot[bot] Jun 4, 2026
e2340fb
chore: Add comment to enable dependabot
MalikCherfi Jun 4, 2026
bd5399a
chore(deps): bump flask from 3.0.3 to 3.1.3 in /ressources
dependabot[bot] Jun 4, 2026
8979004
chore(deps): bump pytest from 8.2.0 to 9.0.3 in /ressources
dependabot[bot] Jun 4, 2026
1795edc
Merge pull request #8 from MalikCherfi/dependabot/pip/ressources/pyte…
MalikCherfi Jun 4, 2026
529364d
Merge branch 'main' into dependabot/pip/ressources/flask-3.1.3
MalikCherfi Jun 4, 2026
37dfdbc
Merge pull request #7 from MalikCherfi/dependabot/pip/ressources/flas…
MalikCherfi Jun 4, 2026
f3ce2ec
chore(deps): bump pytest-cov from 5.0.0 to 7.1.0 in /ressources
dependabot[bot] Jun 4, 2026
3be084d
refactor : refacto code
MalikCherfi Jun 5, 2026
71d8a1c
refactor : refacto code
MalikCherfi Jun 5, 2026
8f70fe3
Merge branch 'main' of github.com:MalikCherfi/tp-github-actions
MalikCherfi Jun 5, 2026
bc57a86
Merge pull request #6 from MalikCherfi/dependabot/pip/ressources/pyte…
MalikCherfi Jun 5, 2026
51ab92d
Merge pull request #1 from MalikCherfi/dependabot/github_actions/acti…
MalikCherfi Jun 5, 2026
b23af94
chore(deps): bump actions/checkout from 4 to 6
dependabot[bot] Jun 5, 2026
a71e67d
chore(deps): bump actions/setup-python from 5 to 6
dependabot[bot] Jun 5, 2026
c26597c
Merge pull request #2 from MalikCherfi/dependabot/github_actions/acti…
MalikCherfi Jun 5, 2026
f70bcce
chore(deps): bump flake8 from 7.0.0 to 7.3.0 in /ressources
dependabot[bot] Jun 5, 2026
569e23f
Merge pull request #3 from MalikCherfi/dependabot/github_actions/acti…
MalikCherfi Jun 5, 2026
54d4e0b
Merge pull request #5 from MalikCherfi/dependabot/pip/ressources/flak…
MalikCherfi Jun 5, 2026
f66c0ca
Merge pull request #4 from MalikCherfi/dependabot/github_actions/acti…
MalikCherfi Jun 5, 2026
686bdf1
feat: Add CODEOWNERS
MalikCherfi Jun 5, 2026
755703f
feat: log errors
MalikCherfi Jun 5, 2026
6f6acdd
feat: test log error function
MalikCherfi Jun 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# dependabot.yml

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
68 changes: 60 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,70 @@
name: CI
name: CI — NexaCloud API

on:
push:
branches: [ "main" ]
branches: [main]
pull_request:
branches: [ "main" ]
branches: [main]

jobs:
build:
pre-commit:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v6

- name: Example step
run: echo "Add your build/test steps here!"
- name: Run pre-commit hooks
uses: pre-commit/action@v3.0.1

lint:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v6

- name: Setup Python
uses: actions/setup-python@v6
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@v6

- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: "3.11"

- name: Installer les dépendances
run: pip install -r ressources/requirements.txt

- 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@v7
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@v5
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('ressources/requirements.txt') }}
55 changes: 55 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
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@v6

- uses: actions/setup-python@v6
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@v6

- 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@v6

- name: Deploy Production on Azure App Service
run: |
echo "Deploying production to Azure App Service..."
22 changes: 22 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Deploy

on:
workflow_dispatch:
inputs:
environment:
description: "Choose the deployment environment"
required: true
default: "staging"
type: choice
options:
- staging
- production

jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}

steps:
- name: "Déployer en ${{ inputs.environment }}"
run: echo "Déploiement en ${{ inputs.environment }}..."
27 changes: 27 additions & 0 deletions .github/workflows/hello.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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@v6

- 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: Afficher la date et l'heure
run: date
20 changes: 20 additions & 0 deletions .github/workflows/secrets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Demo Secrets

on:
workflow_dispatch:

jobs:
demo:
runs-on: ubuntu-latest

env:
API_KEY: ${{ secrets.API_KEY }}

steps:
- name: Vérifier que le secret est défini
run: |
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)"
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,17 @@ override.tf.json
.terraformrc
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

# Optional: ignore plan files saved before destroying Terraform configuration
# Uncomment the line below if you want to ignore planout files.
# planout
# planout
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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$
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

---
Expand Down Expand Up @@ -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.

---
Expand Down Expand Up @@ -242,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").

<details>
Expand Down
1 change: 1 addition & 0 deletions notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Mon TP GitHub Actions
7 changes: 7 additions & 0 deletions ressources/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 4 additions & 4 deletions ressources/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
flask==3.0.3
pytest==8.2.0
pytest-cov==5.0.0
flake8==7.0.0
flask==3.1.3
pytest==9.0.3
pytest-cov==7.1.0
flake8==7.3.0
gunicorn==26.0.0
10 changes: 10 additions & 0 deletions ressources/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading