|
| 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 |
0 commit comments