Skip to content

Commit e18bb9b

Browse files
committed
ci(debian): ajouter la pipeline de tests automatisés pour Debian/Linux
1 parent f7a087a commit e18bb9b

2 files changed

Lines changed: 72 additions & 2 deletions

File tree

.github/workflows/ci-debian.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: CI Debian
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test-debian:
11+
name: Tests sur Debian/Linux
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Récupérer le code
16+
uses: actions/checkout@v4
17+
18+
- name: Configurer Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: "3.x"
22+
23+
- name: Installer les dépendances
24+
run: |
25+
pip install flask
26+
sudo apt-get install -y tree
27+
28+
- name: Vérifier les imports (architecture Moteur/)
29+
run: |
30+
python3 -c "from Moteur.base.moteur_base import choisir_moteur"
31+
python3 -c "from Moteur.linux.moteur_linux import MoteurLinux"
32+
33+
- name: Vérifier la version
34+
run: python3 lsit.py --version
35+
36+
- name: Générer un rapport TXT
37+
run: python3 lsit.py --format txt
38+
39+
- name: Vérifier que le rapport TXT existe et n'est pas vide
40+
run: |
41+
test -f rapport_lsit.txt
42+
test -s rapport_lsit.txt
43+
44+
- name: Générer un rapport JSON
45+
run: python3 lsit.py --format json
46+
47+
- name: Vérifier que le rapport JSON est valide
48+
run: |
49+
test -f rapport_lsit.json
50+
python3 -c "
51+
import json
52+
with open('rapport_lsit.json') as f:
53+
data = json.load(f)
54+
champs = ['date','machine','ram','cpu','processus','arborescence',
55+
'securite_ports','securite_sudoers','stockage','uptime','load_average']
56+
for champ in champs:
57+
assert champ in data, f'Champ manquant : {champ}'
58+
print('JSON valide — tous les champs présents.')
59+
"
60+
61+
- name: Vérifier que le serveur Flask démarre
62+
run: |
63+
python3 lsit.py --serve &
64+
SERVER_PID=$!
65+
sleep 3
66+
curl --fail --silent http://localhost:5000 > /dev/null
67+
curl --fail --silent http://localhost:5000/api/donnees > /dev/null
68+
kill $SERVER_PID

lsit.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,17 @@ def mode_txt(donnees: dict) -> None:
7373
f.write(donnees["securite_ports"])
7474

7575
print("Rapport TXT généré avec succès !")
76-
input("Appuyez sur Entrée pour revenir au menu...")
76+
if sys.stdin.isatty():
77+
input("Appuyez sur Entrée pour revenir au menu...")
7778

7879

7980
def mode_json(donnees: dict) -> None:
8081
with open("rapport_lsit.json", "w") as f:
8182
json.dump(donnees, f, indent=4)
8283

8384
print("Rapport JSON généré avec succès !")
84-
input("Appuyez sur Entrée pour revenir au menu...")
85+
if sys.stdin.isatty():
86+
input("Appuyez sur Entrée pour revenir au menu...")
8587

8688

8789
def mode_serve() -> None:

0 commit comments

Comments
 (0)