move workflow files - add prettier formatting and format #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: TypeScript Type Check | |
| on: | |
| pull_request: | |
| branches: [ '*' ] | |
| paths: | |
| - 'PROJECTS/api-security-scanner/frontend/**/*.ts' | |
| - 'PROJECTS/api-security-scanner/frontend/**/*.tsx' | |
| - 'PROJECTS/api-security-scanner/frontend/tsconfig*.json' | |
| - 'PROJECTS/api-security-scanner/frontend/package.json' | |
| - '.github/workflows/typescript-check.yml' | |
| jobs: | |
| typescript-check: | |
| name: TypeScript Type Check | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| contents: read | |
| defaults: | |
| run: | |
| working-directory: PROJECTS/api-security-scanner/frontend | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: PROJECTS/api-security-scanner/frontend/package-lock.json | |
| - name: Install dependencies | |
| run: | | |
| for i in {1..3}; do | |
| echo "Attempt $i of 3..." | |
| if npm install; then | |
| echo "✅ npm install succeeded" | |
| break | |
| else | |
| echo "⚠️ npm install failed, retrying in 10 seconds..." | |
| sleep 10 | |
| fi | |
| done | |
| - name: Run TypeScript type checking | |
| id: typescript_check | |
| run: | | |
| echo "Running TypeScript type checking..." | |
| if npm run lint:types > typescript-output.txt 2>&1; then | |
| echo "TYPESCRIPT_PASSED=true" >> $GITHUB_ENV | |
| echo "✅ No TypeScript type errors found!" | |
| echo "ERROR_COUNT=0" >> $GITHUB_ENV | |
| else | |
| echo "TYPESCRIPT_PASSED=false" >> $GITHUB_ENV | |
| # Count error lines (lines that contain errors) | |
| error_count=$(grep -c "error TS" typescript-output.txt || echo "0") | |
| echo "ERROR_COUNT=$error_count" >> $GITHUB_ENV | |
| echo "⚠️ TypeScript found $error_count type errors!" | |
| fi | |
| cat typescript-output.txt | |
| continue-on-error: true | |
| - name: Create TypeScript Summary | |
| id: create_summary | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| { | |
| echo '## 📝 TypeScript Type Check Results' | |
| echo '' | |
| if [[ "${{ env.TYPESCRIPT_PASSED }}" == "true" ]]; then | |
| echo '### ✅ **Perfect! No TypeScript type errors found** 🎉' | |
| echo '' | |
| echo 'Your TypeScript code passes all strict type checking requirements!' | |
| echo '' | |
| echo '**What was checked:**' | |
| echo '- Strict type checking with `exactOptionalPropertyTypes`' | |
| echo '- No unused locals or parameters' | |
| echo '- Proper return types and void expressions' | |
| echo '- Module resolution and import/export syntax' | |
| else | |
| echo '### ❌ **TypeScript found ${{ env.ERROR_COUNT }} type errors**' | |
| echo '' | |
| echo 'Please review and fix the TypeScript type errors below:' | |
| echo '' | |
| echo '<details><summary>📋 View detailed TypeScript output</summary>' | |
| echo '' | |
| echo '```' | |
| head -100 typescript-output.txt | |
| echo '```' | |
| echo '</details>' | |
| echo '' | |
| echo '**How to fix:**' | |
| echo '1. Run `cd frontend && npm run lint:types` locally to see the type errors' | |
| echo '2. Fix the reported TypeScript type issues' | |
| echo '3. Ensure all variables have proper types and return types are explicit' | |
| echo '4. Push your changes to update this PR' | |
| fi | |
| echo '' | |
| echo '**Commands:**' | |
| echo '- `cd frontend && npm run lint:types` - Run TypeScript type checking' | |
| echo '- `cd frontend && npm run build` - Run full build with type checking' | |
| echo '- TypeScript config: `frontend/tsconfig.app.json`' | |
| echo '' | |
| echo '<!-- typescript-check-comment-marker -->' | |
| } > typescript-report.md | |
| - name: Post PR Comment | |
| if: github.event_name == 'pull_request' | |
| uses: peter-evans/create-or-update-comment@v4 | |
| with: | |
| issue-number: ${{ github.event.pull_request.number }} | |
| body-path: PROJECTS/api-security-scanner/frontend/typescript-report.md | |
| edit-mode: replace | |
| - name: Exit with proper code | |
| run: | | |
| if [[ "${{ env.TYPESCRIPT_PASSED }}" == "false" ]]; then | |
| echo "❌ TypeScript type checking failed. Please fix the type errors above." | |
| exit 1 | |
| else | |
| echo "✅ All TypeScript type checks passed!" | |
| exit 0 | |
| fi |