issue 77 pt3 golangci
This commit is contained in:
parent
7168174006
commit
d5f71f5f01
|
|
@ -1,120 +0,0 @@
|
|||
name: ESLint Check
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ '*' ]
|
||||
paths:
|
||||
- 'PROJECTS/api-security-scanner/frontend/**/*.ts'
|
||||
- 'PROJECTS/api-security-scanner/frontend/**/*.tsx'
|
||||
- 'PROJECTS/api-security-scanner/frontend/eslint.config.js'
|
||||
- 'PROJECTS/api-security-scanner/frontend/tsconfig*.json'
|
||||
- 'PROJECTS/api-security-scanner/frontend/package.json'
|
||||
- '.github/workflows/eslint-check.yml'
|
||||
|
||||
jobs:
|
||||
eslint-check:
|
||||
name: ESLint TypeScript 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: npm install
|
||||
|
||||
- name: Run ESLint
|
||||
id: eslint_check
|
||||
run: |
|
||||
echo "Running ESLint on TypeScript/React files..."
|
||||
if npm run lint:eslint > eslint-output.txt 2>&1; then
|
||||
echo "ESLINT_PASSED=true" >> $GITHUB_ENV
|
||||
echo "✅ No ESLint errors found!"
|
||||
echo "ERROR_COUNT=0" >> $GITHUB_ENV
|
||||
else
|
||||
echo "ESLINT_PASSED=false" >> $GITHUB_ENV
|
||||
# Count error lines (lines that contain file paths with problems)
|
||||
error_count=$(grep -c "^/" eslint-output.txt || echo "0")
|
||||
echo "ERROR_COUNT=$error_count" >> $GITHUB_ENV
|
||||
echo "⚠️ ESLint found issues in $error_count files!"
|
||||
fi
|
||||
cat eslint-output.txt
|
||||
continue-on-error: true
|
||||
|
||||
- name: Create ESLint Summary
|
||||
id: create_summary
|
||||
if: github.event_name == 'pull_request'
|
||||
run: |
|
||||
{
|
||||
echo '## 🔍 ESLint Results'
|
||||
echo ''
|
||||
|
||||
if [[ "${{ env.ESLINT_PASSED }}" == "true" ]]; then
|
||||
echo '### ✅ **Perfect! No ESLint issues found** 🎉'
|
||||
echo ''
|
||||
echo 'Your TypeScript and React code follows all the coding standards perfectly!'
|
||||
echo ''
|
||||
echo '**What was checked:**'
|
||||
echo '- TypeScript strict type checking and stylistic rules'
|
||||
echo '- React component patterns and hooks usage'
|
||||
echo '- Code complexity, naming conventions, and best practices'
|
||||
echo '- Accessibility (jsx-a11y) and React Refresh compatibility'
|
||||
else
|
||||
echo '### ❌ **ESLint found issues in ${{ env.ERROR_COUNT }} files**'
|
||||
echo ''
|
||||
echo 'Please review and fix the TypeScript/React issues below:'
|
||||
echo ''
|
||||
echo '<details><summary>📋 View detailed ESLint output</summary>'
|
||||
echo ''
|
||||
echo '```'
|
||||
head -100 eslint-output.txt
|
||||
echo '```'
|
||||
echo '</details>'
|
||||
echo ''
|
||||
echo '**How to fix:**'
|
||||
echo '1. Run `cd frontend && npm run lint:eslint` locally to see the issues'
|
||||
echo '2. Fix the reported TypeScript, React, and code quality problems'
|
||||
echo '3. For auto-fixable issues: `cd frontend && npx eslint . --ext .ts,.tsx --fix`'
|
||||
echo '4. Push your changes to update this PR'
|
||||
fi
|
||||
echo ''
|
||||
echo '**Commands:**'
|
||||
echo '- `cd frontend && npm run lint:eslint` - Run ESLint'
|
||||
echo '- `cd frontend && npx eslint . --ext .ts,.tsx --fix` - Auto-fix issues'
|
||||
echo '- ESLint config: `frontend/eslint.config.js`'
|
||||
echo ''
|
||||
echo '<!-- eslint-check-comment-marker -->'
|
||||
} > eslint-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/eslint-report.md
|
||||
edit-mode: replace
|
||||
|
||||
- name: Exit with proper code
|
||||
run: |
|
||||
if [[ "${{ env.ESLINT_PASSED }}" == "false" ]]; then
|
||||
echo "❌ ESLint checks failed. Please fix the issues above."
|
||||
exit 1
|
||||
else
|
||||
echo "✅ All ESLint checks passed!"
|
||||
exit 0
|
||||
fi
|
||||
|
|
@ -1,129 +0,0 @@
|
|||
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
|
||||
Loading…
Reference in New Issue