Configuration en variables + tests unitaires BATS
- Conversion config hardcodée en variables (CLUSTER_NODES) - Détection nœud distant data-driven (extensible à 3+ nœuds) - Tests unitaires BATS avec mocks complets (32 tests) - CI/CD Forgejo avec shellcheck et validation syntaxe - Mode test pour sourcing sans exécution du main
This commit is contained in:
parent
de4b630399
commit
dfa5078b47
8 changed files with 908 additions and 15 deletions
105
.forgejo/workflows/test.yml
Normal file
105
.forgejo/workflows/test.yml
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
name: Tests et Vérifications
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, 2.1 ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
name: Tests unitaires BATS
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout du code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Installation de BATS
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y bats
|
||||
|
||||
- name: Afficher version BATS
|
||||
run: bats --version
|
||||
|
||||
- name: Exécuter tests unitaires
|
||||
run: |
|
||||
cd tests
|
||||
bats *.bats
|
||||
|
||||
- name: Upload résultats des tests
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: test-results
|
||||
path: tests/*.log
|
||||
retention-days: 7
|
||||
|
||||
shellcheck:
|
||||
name: Vérification ShellCheck
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout du code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Installation de ShellCheck
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y shellcheck
|
||||
|
||||
- name: Afficher version ShellCheck
|
||||
run: shellcheck --version
|
||||
|
||||
- name: Vérifier le script principal
|
||||
run: |
|
||||
shellcheck -x zfs-nfs-replica.sh || true
|
||||
|
||||
- name: Vérifier les scripts de test
|
||||
run: |
|
||||
shellcheck -x tests/*.bash || true
|
||||
|
||||
syntax:
|
||||
name: Vérification syntaxe Bash
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout du code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Vérifier syntaxe du script principal
|
||||
run: |
|
||||
bash -n zfs-nfs-replica.sh
|
||||
|
||||
- name: Vérifier syntaxe des helpers de test
|
||||
run: |
|
||||
bash -n tests/test_helper.bash
|
||||
|
||||
summary:
|
||||
name: Résumé des tests
|
||||
runs-on: ubuntu-latest
|
||||
needs: [tests, shellcheck, syntax]
|
||||
if: always()
|
||||
|
||||
steps:
|
||||
- name: Afficher résumé
|
||||
run: |
|
||||
echo "=========================================="
|
||||
echo "RÉSUMÉ DES TESTS"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
echo "Tests unitaires: ${{ needs.tests.result }}"
|
||||
echo "ShellCheck: ${{ needs.shellcheck.result }}"
|
||||
echo "Syntaxe Bash: ${{ needs.syntax.result }}"
|
||||
echo ""
|
||||
|
||||
if [[ "${{ needs.tests.result }}" == "success" ]] && \
|
||||
[[ "${{ needs.shellcheck.result }}" == "success" ]] && \
|
||||
[[ "${{ needs.syntax.result }}" == "success" ]]; then
|
||||
echo "✓ Tous les tests sont passés avec succès"
|
||||
exit 0
|
||||
else
|
||||
echo "✗ Certains tests ont échoué"
|
||||
exit 1
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue