Merge branch 'sprint_orders' of https://github.com/remiv1/acfc_intra … #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: 🐍 CI/CD Pipeline - Validation Python | |
| on: | |
| push: | |
| branches: ['**'] | |
| pull_request: | |
| branches: ['main'] | |
| workflow_dispatch: | |
| env: | |
| PYTHON_VERSION: '3.12' | |
| NODE_VERSION: '18' | |
| jobs: | |
| test-unit: | |
| name: Tests Unitaires | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout du code | |
| uses: actions/checkout@v4 | |
| - name: Configuration Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Cache des dépendances Python | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-*.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Installation des dépendances | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements-test.txt | |
| pip install -r requirements-app.txt | |
| pip install -r requirements-api.txt | |
| - name: Vérification de la syntaxe Python | |
| run: | | |
| python -m py_compile app_acfc/**/*.py | |
| python -m py_compile app_acfc/**/*.py | |
| python -m py_compile api_acfc/*.py | |
| python -m py_compile tests/**/*.py | |
| - name: Tests unitaires avec pytest | |
| run: | | |
| pytest tests/unit/ -v --tb=short --cov=app_acfc --cov=api_acfc --cov-report=xml --cov-report=html | |
| - name: Upload des rapports de couverture | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-reports-unit | |
| path: | | |
| coverage.xml | |
| htmlcov/ | |
| test-integration: | |
| name: Tests d'Intégration | |
| runs-on: ubuntu-latest | |
| needs: test-unit | |
| services: | |
| mariadb: | |
| image: mariadb:10.6 | |
| env: | |
| MYSQL_ROOT_PASSWORD: test_password | |
| MYSQL_DATABASE: acfc_test | |
| MYSQL_USER: acfc_user | |
| MYSQL_PASSWORD: acfc_password | |
| ports: | |
| - 3306:3306 | |
| options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
| mongodb: | |
| image: mongo:5.0 | |
| env: | |
| MONGO_INITDB_ROOT_USERNAME: admin | |
| MONGO_INITDB_ROOT_PASSWORD: test_password | |
| MONGO_INITDB_DATABASE: acfc_test | |
| ports: | |
| - 27017:27017 | |
| steps: | |
| - name: Checkout du code | |
| uses: actions/checkout@v4 | |
| - name: Configuration Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Installation des dépendances | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements-test.txt | |
| pip install -r requirements-app.txt | |
| pip install -r requirements-api.txt | |
| - name: Attente des services | |
| run: | | |
| # Attendre que MariaDB soit prêt | |
| until mysqladmin ping -h 127.0.0.1 -P 3306 -u root -ptest_password --silent; do | |
| echo 'Attente de MariaDB...' | |
| sleep 2 | |
| done | |
| # Attendre que MongoDB soit prêt | |
| until mongo --host 127.0.0.1:27017 --eval "db.runCommand('ping').ok" --quiet; do | |
| echo 'Attente de MongoDB...' | |
| sleep 2 | |
| done | |
| - name: Initialisation de la base de données | |
| run: | | |
| python init_database.py | |
| env: | |
| DATABASE_URL: mysql://acfc_user:acfc_password@127.0.0.1:3306/acfc_test | |
| MONGODB_URL: mongodb://admin:test_password@127.0.0.1:27017/acfc_test | |
| - name: Tests d'intégration | |
| run: | | |
| pytest tests/integration/ -v --tb=short --cov-append --cov=app_acfc --cov=api_acfc | |
| env: | |
| DATABASE_URL: mysql://acfc_user:acfc_password@127.0.0.1:3306/acfc_test | |
| MONGODB_URL: mongodb://admin:test_password@127.0.0.1:27017/acfc_test | |
| FLASK_ENV: testing | |
| test-e2e: | |
| name: Tests End-to-End | |
| runs-on: ubuntu-latest | |
| needs: [test-unit, test-integration] | |
| steps: | |
| - name: Checkout du code | |
| uses: actions/checkout@v4 | |
| - name: Configuration Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Configuration Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: Installation des dépendances Python | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements-test.txt | |
| pip install -r requirements-app.txt | |
| pip install -r requirements-api.txt | |
| - name: Installation de Chrome pour les tests | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y google-chrome-stable | |
| - name: Tests End-to-End | |
| run: | | |
| pytest tests/e2e/ -v --tb=short | |
| security-scan: | |
| name: Analyse de Sécurité | |
| runs-on: ubuntu-latest | |
| needs: test-unit | |
| steps: | |
| - name: Checkout du code | |
| uses: actions/checkout@v4 | |
| - name: Configuration Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Installation de bandit | |
| run: | | |
| python -m pip install bandit[toml] | |
| - name: Scan de sécurité avec Bandit | |
| run: | | |
| bandit -r app_acfc/ api_acfc/ -f json -o bandit-report.json | |
| bandit -r app_acfc/ api_acfc/ -f txt | |
| - name: Upload du rapport Bandit | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: security-report | |
| path: bandit-report.json | |
| code-quality: | |
| name: Qualité du Code | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout du code | |
| uses: actions/checkout@v4 | |
| - name: Configuration Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Installation des outils de qualité | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install flake8 black isort mypy pylint | |
| - name: Vérification du formatage avec Black | |
| continue-on-error: true | |
| run: | | |
| black --check --diff app_acfc/ api_acfc/ tests/ | |
| - name: Vérification des imports avec isort | |
| continue-on-error: true | |
| run: | | |
| isort --check-only --diff app_acfc/ api_acfc/ tests/ | |
| - name: Analyse avec Flake8 | |
| continue-on-error: true | |
| run: | | |
| flake8 app_acfc/ api_acfc/ tests/ --max-line-length=100 --extend-ignore=E203,W503 | |
| - name: Analyse avec Pylint | |
| continue-on-error: true | |
| run: | | |
| pylint app_acfc/ api_acfc/ --output-format=json > pylint-report.json || true | |
| pylint app_acfc/ api_acfc/ --output-format=text | |
| - name: Upload du rapport Pylint | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: pylint-report | |
| path: pylint-report.json | |
| test-demo: | |
| name: Tests de Démonstration | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.message, '[demo]') | |
| steps: | |
| - name: Checkout du code | |
| uses: actions/checkout@v4 | |
| - name: Configuration Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Installation des dépendances | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements-test.txt | |
| pip install -r requirements-app.txt | |
| - name: Tests de démonstration | |
| run: | | |
| pytest tests/demo/ -v -s --tb=short | |
| deploy-staging: | |
| name: Déploiement Staging | |
| runs-on: ubuntu-latest | |
| needs: [test-unit, test-integration, test-e2e, security-scan, code-quality] | |
| if: github.ref == 'refs/heads/develop' && github.event_name == 'push' | |
| steps: | |
| - name: Checkout du code | |
| uses: actions/checkout@v4 | |
| - name: Déploiement vers Staging | |
| run: | | |
| echo "Déploiement vers l'environnement de staging" | |
| # Ici, ajouter les commandes de déploiement spécifiques | |
| # Par exemple : docker-compose up -d, kubectl apply, etc. | |
| deploy-production: | |
| name: Déploiement Production | |
| runs-on: ubuntu-latest | |
| needs: [test-unit, test-integration, test-e2e, security-scan, code-quality] | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| steps: | |
| - name: Checkout du code | |
| uses: actions/checkout@v4 | |
| - name: Déploiement vers Production | |
| run: | | |
| echo "Déploiement vers l'environnement de production" | |
| # Ici, ajouter les commandes de déploiement spécifiques | |
| cleanup: | |
| name: Nettoyage | |
| runs-on: ubuntu-latest | |
| needs: [deploy-staging, deploy-production] | |
| if: always() | |
| steps: | |
| - name: Nettoyage des artefacts temporaires | |
| run: | | |
| echo "Nettoyage des ressources temporaires" | |
| # Commandes de nettoyage si nécessaire |