Skip to content

Commit 690a04d

Browse files
committed
bugfix. Update code quality workflow to lint only changed files
Modified the ESLint and Prettier actions to process only diff-relevant files instead of the entire codebase. This optimizes the workflow by reducing unnecessary checks and speeds up pipeline execution while ensuring code quality for modified files.
1 parent a08a9c8 commit 690a04d

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

.github/workflows/code_quality_workflow.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
name: ESLint + Prettier
32

43
on: [pull_request]
@@ -8,6 +7,9 @@ jobs:
87
runs-on: ubuntu-latest
98
steps:
109
- uses: actions/checkout@v3
10+
with:
11+
fetch-depth: 0
12+
1113

1214
- name: Setup Node.js
1315
uses: actions/setup-node@v3
@@ -17,14 +19,20 @@ jobs:
1719
- name: Install dependencies
1820
run: npm install
1921

22+
- name: Get list of changed files
23+
id: changed-files
24+
run: |
25+
git fetch origin ${{ github.base_ref }} --depth=1
26+
echo "CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD -- '*.js' '*.jsx' '*.ts' '*.tsx' | paste -sd ' ' -)" >> $GITHUB_ENV
27+
2028
- name: Run ESLint with reviewdog
2129
id: eslint
2230
uses: reviewdog/action-eslint@v1
2331
continue-on-error: true
2432
with:
2533
github_token: ${{ secrets.FRONT_SECRET }}
2634
reporter: github-pr-review
27-
eslint_flags: './**/*.{js,jsx,ts,tsx}'
35+
eslint_flags: ${{ env.CHANGED_FILES }}
2836
fail_level: 'any'
2937

3038
- name: Run Prettier with reviewdog
@@ -35,7 +43,7 @@ jobs:
3543
github_token: ${{ secrets.FRONT_SECRET }}
3644
reporter: github-pr-review
3745
level: warning
38-
prettier_flags: './**/*.{js,jsx,ts,tsx}'
46+
prettier_flags: ${{ env.CHANGED_FILES }}
3947

4048
- name: Check overall result
4149
id: overall

0 commit comments

Comments
 (0)