Dependency Health Check #412
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: Dependency Health Check | |
| on: | |
| push: | |
| branches: [ main, dev ] | |
| pull_request: | |
| branches: [ main, dev ] | |
| schedule: | |
| # Run daily at 2 AM UTC | |
| - cron: '0 2 * * *' | |
| jobs: | |
| dependency-health: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run dependency health check | |
| run: npm run deps:check | |
| continue-on-error: true | |
| - name: Run import validation | |
| run: npm run deps:validate | |
| continue-on-error: true | |
| - name: Generate dependency map | |
| run: npm run deps:map | |
| continue-on-error: true | |
| - name: Check import organization | |
| run: npm run organize:imports:dry | |
| continue-on-error: true | |
| - name: Run linting | |
| run: npm run lint | |
| continue-on-error: true | |
| - name: Type check | |
| run: npx tsc --noEmit | |
| continue-on-error: true | |
| - name: Check for circular dependencies | |
| run: | | |
| if npm run deps:check 2>&1 | grep -q "CIRCULAR DEPENDENCIES"; then | |
| echo "::warning::Circular dependencies detected" | |
| fi | |
| continue-on-error: true | |
| - name: Bundle size check | |
| run: | | |
| npm run build | |
| npx bundlesize | |
| continue-on-error: true | |
| - name: Upload dependency reports | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: dependency-reports | |
| path: | | |
| dependency-report.json | |
| dependency-report.txt | |
| dependency-map.mermaid | |
| dependency-map.dot | |
| retention-days: 30 | |
| - name: Comment PR with dependency issues | |
| if: github.event_name == 'pull_request' && failure() | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| let comment = '## 🔍 Dependency Health Check Results\n\n'; | |
| try { | |
| const report = JSON.parse(fs.readFileSync('dependency-report.json', 'utf8')); | |
| if (report.circularDependencies && report.circularDependencies.length > 0) { | |
| comment += '### ❌ Circular Dependencies Found\n'; | |
| report.circularDependencies.slice(0, 5).forEach((cycle, index) => { | |
| comment += `${index + 1}. \`${cycle.join(' → ')}\`\n`; | |
| }); | |
| if (report.circularDependencies.length > 5) { | |
| comment += `... and ${report.circularDependencies.length - 5} more\n`; | |
| } | |
| comment += '\n'; | |
| } | |
| comment += '### 📊 Statistics\n'; | |
| comment += `- Total files analyzed: ${report.stats.totalFiles}\n`; | |
| comment += `- Total dependencies: ${report.stats.totalDependencies}\n`; | |
| comment += `- Circular dependencies: ${report.stats.circularCount}\n\n`; | |
| comment += '### 🔧 Next Steps\n'; | |
| comment += '1. Review the circular dependencies and refactor if necessary\n'; | |
| comment += '2. Run `npm run deps:fix` to automatically fix import path issues\n'; | |
| comment += '3. Check the full report in the workflow artifacts\n'; | |
| } catch (error) { | |
| comment += '❌ Could not parse dependency report. Check the workflow logs for details.\n'; | |
| } | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: comment | |
| }); | |
| security-audit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run security audit | |
| run: npm audit --audit-level=moderate | |
| - name: Check for outdated packages | |
| run: npm outdated || true | |
| - name: License check | |
| run: npx license-checker --summary | |
| continue-on-error: true |