Skip to content

Commit f55ec21

Browse files
Harshit Guptaclaude
andcommitted
feat: add JS/TS and Python linting workflows for PRs
Add two GitHub Actions workflows triggered on PRs to main: - js-lint: runs ESLint and Prettier on changed frontend files using project-local config and dependencies - python-lint: runs ruff check and ruff format on changed Python files Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent eec70e7 commit f55ec21

File tree

2 files changed

+144
-0
lines changed

2 files changed

+144
-0
lines changed

.github/workflows/js-lint.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: JavaScript/TypeScript Code Quality
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
js-lint:
12+
runs-on: ubuntu-latest
13+
defaults:
14+
run:
15+
working-directory: frontend
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Get changed JS/TS files
21+
id: changed-files
22+
uses: tj-actions/changed-files@v46
23+
with:
24+
files: |
25+
frontend/**/*.js
26+
frontend/**/*.ts
27+
frontend/**/*.jsx
28+
frontend/**/*.tsx
29+
frontend/**/*.css
30+
frontend/**/*.json
31+
frontend/**/*.mjs
32+
33+
- name: Set up Node.js
34+
if: steps.changed-files.outputs.any_changed == 'true'
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version: '18'
38+
39+
- name: Install dependencies
40+
if: steps.changed-files.outputs.any_changed == 'true'
41+
run: npm ci
42+
43+
- name: Run ESLint on changed files
44+
if: steps.changed-files.outputs.any_changed == 'true'
45+
env:
46+
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
47+
run: |
48+
echo "Linting changed JS/TS files:"
49+
# Filter to only .ts/.tsx/.js/.jsx files for ESLint
50+
ESLINT_FILES=""
51+
for file in ${ALL_CHANGED_FILES}; do
52+
# Strip frontend/ prefix since working-directory is frontend
53+
relative_file="${file#frontend/}"
54+
if [ -f "$relative_file" ] && echo "$relative_file" | grep -qE '\.(ts|tsx|js|jsx)$'; then
55+
ESLINT_FILES="$ESLINT_FILES $relative_file"
56+
echo " $relative_file"
57+
fi
58+
done
59+
if [ -n "$ESLINT_FILES" ]; then
60+
npx eslint $ESLINT_FILES
61+
else
62+
echo "No JS/TS files to lint"
63+
fi
64+
65+
- name: Run Prettier check on changed files
66+
if: steps.changed-files.outputs.any_changed == 'true'
67+
env:
68+
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
69+
run: |
70+
echo "Checking format of changed files:"
71+
PRETTIER_FILES=""
72+
for file in ${ALL_CHANGED_FILES}; do
73+
relative_file="${file#frontend/}"
74+
if [ -f "$relative_file" ]; then
75+
PRETTIER_FILES="$PRETTIER_FILES $relative_file"
76+
echo " $relative_file"
77+
fi
78+
done
79+
if [ -n "$PRETTIER_FILES" ]; then
80+
npx prettier --check $PRETTIER_FILES
81+
else
82+
echo "No files to check"
83+
fi
84+
85+
- name: Skip message
86+
if: steps.changed-files.outputs.any_changed == 'false'
87+
run: echo "No JavaScript/TypeScript files changed - skipping JS/TS linting"

.github/workflows/python-lint.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Python Code Quality
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
python-lint:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Get changed Python files
18+
id: changed-files
19+
uses: tj-actions/changed-files@v46
20+
with:
21+
files: |
22+
**/*.py
23+
24+
- name: Set up Python
25+
if: steps.changed-files.outputs.any_changed == 'true'
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: '3.11'
29+
30+
- name: Install uv
31+
if: steps.changed-files.outputs.any_changed == 'true'
32+
uses: astral-sh/setup-uv@v3
33+
34+
- name: Install ruff
35+
if: steps.changed-files.outputs.any_changed == 'true'
36+
run: uv tool install ruff
37+
38+
- name: Run ruff check on changed files
39+
if: steps.changed-files.outputs.any_changed == 'true'
40+
env:
41+
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
42+
run: |
43+
echo "Checking changed Python files:"
44+
echo "${ALL_CHANGED_FILES}" | tr ' ' '\n'
45+
uv tool run ruff check --output-format=github ${ALL_CHANGED_FILES}
46+
47+
- name: Run ruff format check on changed files
48+
if: steps.changed-files.outputs.any_changed == 'true'
49+
env:
50+
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
51+
run: |
52+
echo "Checking format of changed Python files:"
53+
uv tool run ruff format --check ${ALL_CHANGED_FILES}
54+
55+
- name: Skip message
56+
if: steps.changed-files.outputs.any_changed == 'false'
57+
run: echo "No Python files changed - skipping Python linting"

0 commit comments

Comments
 (0)