ci:(deps): bump actions/setup-node from 3 to 6 #16
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 - Algorith | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main ] | |
| release: | |
| types: [ published ] | |
| env: | |
| NODE_VERSION: '18' | |
| CACHE_VERSION: 'v1' | |
| jobs: | |
| # Job 1: Tests et Validation | |
| test: | |
| name: 🧪 Tests & Quality Checks | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [14, 16, 18, 20] | |
| steps: | |
| - name: 📥 Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: 🔧 Setup Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'npm' | |
| - name: 🧹 Clean NPM Cache | |
| run: | | |
| npm cache clean --force | |
| echo "✅ NPM cache cleaned" | |
| - name: 📦 Install Dependencies | |
| run: | | |
| # Installation propre pour éviter les problèmes de cache | |
| rm -rf node_modules package-lock.json || true | |
| npm install | |
| npm ci | |
| npm ls # Vérifier la santé des dépendances | |
| - name: 🔍 Lint & Format Check | |
| run: | | |
| # Vérifier que les fichiers sont bien formatés | |
| echo "Checking file formatting..." | |
| find . -name "*.js" -not -path "./node_modules/*" | wc -l | |
| - name: 🧪 Run Unit Tests | |
| run: | | |
| npm test | |
| echo "✅ All tests passed for Node.js ${{ matrix.node-version }}" | |
| - name: 📊 Run Benchmarks | |
| run: | | |
| echo "Running performance benchmarks..." | |
| npm run benchmark | |
| echo "✅ Benchmarks completed successfully" | |
| - name: 📈 Upload Test Results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results-node-${{ matrix.node-version }} | |
| path: | | |
| benchmark-results.json | |
| test-results/ | |
| retention-days: 30 | |
| # Job 2: Analyse de Couverture de Code | |
| coverage: | |
| name: 📊 Code Coverage | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - name: 📥 Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: 🔧 Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| - name: 📦 Install Dependencies | |
| run: npm ci | |
| - name: 🧪 Run Coverage Tests | |
| run: | | |
| npm run test:coverage | |
| echo "✅ Coverage analysis completed" | |
| - name: 📤 Upload Coverage to Codecov | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: ./coverage/lcov.info | |
| flags: unittests | |
| name: algorith-coverage | |
| fail_ci_if_error: false | |
| # Job 3: Analyse de Sécurité | |
| security: | |
| name: 🔒 Security Audit | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 📥 Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: 🔧 Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| - name: 📦 Install Dependencies | |
| run: npm ci | |
| - name: 🔍 NPM Security Audit | |
| run: | | |
| npm audit --audit-level=moderate | |
| echo "✅ Security audit completed" | |
| - name: 🔐 Check for Vulnerable Dependencies | |
| run: | | |
| npx audit-ci --moderate | |
| echo "✅ Vulnerability check completed" | |
| # Job 4: Validation de la Documentation | |
| docs: | |
| name: 📚 Documentation Validation | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 📥 Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: 🔧 Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: 📝 Validate Documentation | |
| run: | | |
| echo "Validating documentation files..." | |
| # Vérifier la présence des fichiers essentiels | |
| test -f README.md && echo "✅ README.md present" | |
| test -f CHANGELOG.md && echo "✅ CHANGELOG.md present" | |
| test -f LICENSE && echo "✅ LICENSE present" | |
| test -f CONTRIBUTING.md && echo "✅ CONTRIBUTING.md present" | |
| test -f EXAMPLES.md && echo "✅ EXAMPLES.md present" | |
| test -f ARCHITECTURE.md && echo "✅ ARCHITECTURE.md present" | |
| # Vérifier que README n'est pas vide | |
| test -s README.md && echo "✅ README.md is not empty" | |
| # Vérifier les définitions TypeScript | |
| test -f index.d.ts && echo "✅ TypeScript definitions present" | |
| echo "📚 Documentation validation completed" | |
| # Job 5: Test de Performance et Régression | |
| performance: | |
| name: ⚡ Performance Tests | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - name: 📥 Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: 🔧 Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| - name: 📦 Install Dependencies | |
| run: npm ci | |
| - name: ⚡ Run Performance Benchmarks | |
| run: | | |
| echo "Running detailed performance analysis..." | |
| npm run benchmark > benchmark-output.txt | |
| # Analyser les résultats de performance | |
| echo "Performance Analysis:" | |
| grep "ops/sec" benchmark-output.txt | |
| # Vérifier que les performances sont acceptables | |
| echo "✅ Performance benchmarks completed" | |
| - name: 📊 Save Performance Results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: performance-results | |
| path: | | |
| benchmark-output.txt | |
| benchmark-results.json | |
| # Job 6: Test de Compatibilité Multi-OS | |
| compatibility: | |
| name: 🖥️ Cross-Platform Compatibility | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| node-version: [16, 18, 20] | |
| steps: | |
| - name: 📥 Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: 🔧 Setup Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'npm' | |
| - name: 📦 Install Dependencies | |
| run: npm ci | |
| - name: 🧪 Run Tests | |
| run: | | |
| npm test | |
| echo "✅ Tests passed on ${{ matrix.os }} with Node.js ${{ matrix.node-version }}" | |
| # Job 7: Publication NPM (seulement sur release) | |
| publish: | |
| name: 📦 Publish to NPM | |
| runs-on: ubuntu-latest | |
| needs: [test, coverage, security, docs, performance, compatibility] | |
| if: github.event_name == 'release' && github.event.action == 'published' | |
| steps: | |
| - name: 📥 Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: 🔧 Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: 📦 Install Dependencies | |
| run: npm ci | |
| - name: 🧪 Final Tests Before Publishing | |
| run: | | |
| npm test | |
| npm run benchmark | |
| echo "✅ Pre-publish validation completed" | |
| - name: 🏗️ Build Package | |
| run: | | |
| echo "Preparing package for publication..." | |
| npm pack --dry-run | |
| - name: 📦 Publish to NPM | |
| run: | | |
| echo "Publishing to NPM..." | |
| npm publish | |
| echo "🎉 Package published successfully!" | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: 📢 Create Release Summary | |
| run: | | |
| echo "## 🎉 Release Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "- Package: algorith@$(node -p "require('./package.json').version")" >> $GITHUB_STEP_SUMMARY | |
| echo "- Published to: https://www.npmjs.com/package/algorith" >> $GITHUB_STEP_SUMMARY | |
| echo "- Release: ${{ github.event.release.tag_name }}" >> $GITHUB_STEP_SUMMARY | |
| # Job 8: Notification et Déploiement | |
| notify: | |
| name: 📢 Notifications & Cleanup | |
| runs-on: ubuntu-latest | |
| needs: [test, coverage, security, docs, performance, compatibility] | |
| if: always() | |
| steps: | |
| - name: 📊 Check Job Results | |
| run: | | |
| echo "## 📋 Pipeline Results" >> $GITHUB_STEP_SUMMARY | |
| echo "- Tests: ${{ needs.test.result }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- Coverage: ${{ needs.coverage.result }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- Security: ${{ needs.security.result }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- Documentation: ${{ needs.docs.result }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- Performance: ${{ needs.performance.result }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- Compatibility: ${{ needs.compatibility.result }}" >> $GITHUB_STEP_SUMMARY | |
| - name: 🎉 Success Notification | |
| if: ${{ needs.test.result == 'success' && needs.coverage.result == 'success' }} | |
| run: | | |
| echo "✅ All checks passed! Ready for production." >> $GITHUB_STEP_SUMMARY | |
| - name: ❌ Failure Notification | |
| if: ${{ needs.test.result == 'failure' || needs.coverage.result == 'failure' }} | |
| run: | | |
| echo "❌ Some checks failed. Please review the logs." >> $GITHUB_STEP_SUMMARY |