Skip to content

Commit 0c4a227

Browse files
move workflow files - add prettier formatting and format
1 parent d1bf2cf commit 0c4a227

File tree

23 files changed

+773
-123
lines changed

23 files changed

+773
-123
lines changed

.github/workflows/eslint-check.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: ESLint Check
2+
3+
on:
4+
pull_request:
5+
branches: [ '*' ]
6+
paths:
7+
- 'PROJECTS/api-security-scanner/frontend/**/*.ts'
8+
- 'PROJECTS/api-security-scanner/frontend/**/*.tsx'
9+
- 'PROJECTS/api-security-scanner/frontend/eslint.config.js'
10+
- 'PROJECTS/api-security-scanner/frontend/tsconfig*.json'
11+
- 'PROJECTS/api-security-scanner/frontend/package.json'
12+
- '.github/workflows/eslint-check.yml'
13+
14+
jobs:
15+
eslint-check:
16+
name: ESLint TypeScript Check
17+
runs-on: ubuntu-latest
18+
19+
permissions:
20+
pull-requests: write
21+
contents: read
22+
23+
defaults:
24+
run:
25+
working-directory: PROJECTS/api-security-scanner/frontend
26+
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v4
30+
31+
- name: Setup Node.js
32+
uses: actions/setup-node@v4
33+
with:
34+
node-version: '20'
35+
cache: 'npm'
36+
cache-dependency-path: PROJECTS/api-security-scanner/frontend/package-lock.json
37+
38+
- name: Install dependencies
39+
run: npm install
40+
41+
- name: Run ESLint
42+
id: eslint_check
43+
run: |
44+
echo "Running ESLint on TypeScript/React files..."
45+
if npm run lint:eslint > eslint-output.txt 2>&1; then
46+
echo "ESLINT_PASSED=true" >> $GITHUB_ENV
47+
echo "✅ No ESLint errors found!"
48+
echo "ERROR_COUNT=0" >> $GITHUB_ENV
49+
else
50+
echo "ESLINT_PASSED=false" >> $GITHUB_ENV
51+
# Count error lines (lines that contain file paths with problems)
52+
error_count=$(grep -c "^/" eslint-output.txt || echo "0")
53+
echo "ERROR_COUNT=$error_count" >> $GITHUB_ENV
54+
echo "⚠️ ESLint found issues in $error_count files!"
55+
fi
56+
cat eslint-output.txt
57+
continue-on-error: true
58+
59+
- name: Create ESLint Summary
60+
id: create_summary
61+
if: github.event_name == 'pull_request'
62+
run: |
63+
{
64+
echo '## 🔍 ESLint Results'
65+
echo ''
66+
67+
if [[ "${{ env.ESLINT_PASSED }}" == "true" ]]; then
68+
echo '### ✅ **Perfect! No ESLint issues found** 🎉'
69+
echo ''
70+
echo 'Your TypeScript and React code follows all the coding standards perfectly!'
71+
echo ''
72+
echo '**What was checked:**'
73+
echo '- TypeScript strict type checking and stylistic rules'
74+
echo '- React component patterns and hooks usage'
75+
echo '- Code complexity, naming conventions, and best practices'
76+
echo '- Accessibility (jsx-a11y) and React Refresh compatibility'
77+
else
78+
echo '### ❌ **ESLint found issues in ${{ env.ERROR_COUNT }} files**'
79+
echo ''
80+
echo 'Please review and fix the TypeScript/React issues below:'
81+
echo ''
82+
echo '<details><summary>📋 View detailed ESLint output</summary>'
83+
echo ''
84+
echo '```'
85+
head -100 eslint-output.txt
86+
echo '```'
87+
echo '</details>'
88+
echo ''
89+
echo '**How to fix:**'
90+
echo '1. Run `cd frontend && npm run lint:eslint` locally to see the issues'
91+
echo '2. Fix the reported TypeScript, React, and code quality problems'
92+
echo '3. For auto-fixable issues: `cd frontend && npx eslint . --ext .ts,.tsx --fix`'
93+
echo '4. Push your changes to update this PR'
94+
fi
95+
echo ''
96+
echo '**Commands:**'
97+
echo '- `cd frontend && npm run lint:eslint` - Run ESLint'
98+
echo '- `cd frontend && npx eslint . --ext .ts,.tsx --fix` - Auto-fix issues'
99+
echo '- ESLint config: `frontend/eslint.config.js`'
100+
echo ''
101+
echo '<!-- eslint-check-comment-marker -->'
102+
} > eslint-report.md
103+
104+
- name: Post PR Comment
105+
if: github.event_name == 'pull_request'
106+
uses: peter-evans/create-or-update-comment@v4
107+
with:
108+
issue-number: ${{ github.event.pull_request.number }}
109+
body-path: PROJECTS/api-security-scanner/frontend/eslint-report.md
110+
edit-mode: replace
111+
112+
- name: Exit with proper code
113+
run: |
114+
if [[ "${{ env.ESLINT_PASSED }}" == "false" ]]; then
115+
echo "❌ ESLint checks failed. Please fix the issues above."
116+
exit 1
117+
else
118+
echo "✅ All ESLint checks passed!"
119+
exit 0
120+
fi

.github/workflows/lint.yml

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
name: Lint & Type Check
2+
3+
on:
4+
push:
5+
branches: [ 'main' ]
6+
pull_request:
7+
branches: [ '*' ]
8+
workflow_dispatch:
9+
10+
11+
jobs:
12+
lint:
13+
name: Run Linters
14+
runs-on: ubuntu-latest
15+
16+
permissions:
17+
pull-requests: write
18+
contents: read
19+
20+
defaults:
21+
run:
22+
working-directory: PROJECTS/api-security-scanner/backend
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: Set up Python
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: '3.12'
32+
33+
- name: Cache pip dependencies
34+
uses: actions/cache@v4
35+
with:
36+
path: ~/.cache/pip
37+
key: ${{ runner.os }}-pip-${{ hashFiles('PROJECTS/api-security-scanner/backend/pyproject.toml') }}
38+
restore-keys: |
39+
${{ runner.os }}-pip-
40+
41+
- name: Install dependencies
42+
run: |
43+
python -m pip install --upgrade pip
44+
pip install -e ".[dev]"
45+
46+
- name: Run pylint
47+
id: pylint
48+
run: |
49+
echo "Running pylint..."
50+
if pylint . > pylint-output.txt 2>&1; then
51+
echo "PYLINT_PASSED=true" >> $GITHUB_ENV
52+
echo "✅ No pylint errors found!"
53+
else
54+
echo "PYLINT_PASSED=false" >> $GITHUB_ENV
55+
echo "⚠️ Pylint found issues!"
56+
fi
57+
cat pylint-output.txt
58+
continue-on-error: true
59+
60+
- name: Run ruff
61+
id: ruff
62+
run: |
63+
echo "Running ruff check..."
64+
if ruff check . > ruff-output.txt 2>&1; then
65+
echo "RUFF_PASSED=true" >> $GITHUB_ENV
66+
echo "✅ No ruff errors found!"
67+
else
68+
echo "RUFF_PASSED=false" >> $GITHUB_ENV
69+
echo "⚠️ Ruff found issues"
70+
fi
71+
cat ruff-output.txt
72+
continue-on-error: true
73+
74+
- name: Run mypy
75+
id: mypy
76+
run: |
77+
echo "Running mypy..."
78+
if mypy . > mypy-output.txt 2>&1; then
79+
echo "MYPY_PASSED=true" >> $GITHUB_ENV
80+
echo "✅ No mypy errors found"
81+
else
82+
echo "MYPY_PASSED=false" >> $GITHUB_ENV
83+
echo "⚠️ Mypy found issues"
84+
fi
85+
cat mypy-output.txt
86+
continue-on-error: true
87+
88+
- name: Create Lint Summary
89+
id: create_summary
90+
if: github.event_name == 'pull_request'
91+
run: |
92+
{
93+
echo '## 🔍 Lint & Type Check Results'
94+
echo ''
95+
96+
# Pylint Status
97+
if [[ "${{ env.PYLINT_PASSED }}" == "true" ]]; then
98+
echo '### ✅ Pylint: **Passed**'
99+
echo 'No pylint issues found.'
100+
else
101+
echo '### ⚠️ Pylint: **Issues Found**'
102+
echo '<details><summary>View pylint output</summary>'
103+
echo ''
104+
echo '```'
105+
head -100 pylint-output.txt
106+
echo '```'
107+
echo '</details>'
108+
fi
109+
echo ''
110+
111+
# Ruff Status
112+
if [[ "${{ env.RUFF_PASSED }}" == "true" ]]; then
113+
echo '### ✅ Ruff: **Passed**'
114+
echo 'No ruff issues found.'
115+
else
116+
echo '### ⚠️ Ruff: **Issues Found**'
117+
echo '<details><summary>View ruff output</summary>'
118+
echo ''
119+
echo '```'
120+
head -100 ruff-output.txt
121+
echo '```'
122+
echo '</details>'
123+
fi
124+
echo ''
125+
126+
# Mypy Status
127+
if [[ "${{ env.MYPY_PASSED }}" == "true" ]]; then
128+
echo '### ✅ Mypy: **Passed**'
129+
echo 'No mypy issues found.'
130+
else
131+
echo '### ⚠️ Mypy: **Issues Found**'
132+
echo '<details><summary>View mypy output</summary>'
133+
echo ''
134+
echo '```'
135+
head -100 mypy-output.txt
136+
echo '```'
137+
echo '</details>'
138+
fi
139+
echo ''
140+
141+
# Overall Summary
142+
if [[ "${{ env.PYLINT_PASSED }}" == "true" ]] && [[ "${{ env.RUFF_PASSED }}" == "true" ]] && [[ "${{ env.MYPY_PASSED }}" == "true" ]]; then
143+
echo '---'
144+
echo '### All checks passed!'
145+
else
146+
echo '---'
147+
echo '### Review the issues above and consider fixing them.'
148+
fi
149+
echo ''
150+
echo '<!-- lint-check-comment-marker -->'
151+
} > ../lint-report.md
152+
153+
- name: Post PR Comment
154+
if: github.event_name == 'pull_request'
155+
uses: peter-evans/create-or-update-comment@v4
156+
with:
157+
issue-number: ${{ github.event.pull_request.number }}
158+
body-path: PROJECTS/api-security-scanner/lint-report.md
159+
comment-marker: lint-check-comment-marker

0 commit comments

Comments
 (0)