Skip to content

Commit fa08173

Browse files
committed
ESLint: Fix Caching, add error summary
1 parent 4de3b21 commit fa08173

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

.github/workflows/pr-test-and-lint.yml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,9 @@ jobs:
6565
env:
6666
cache-name: cache-eslint
6767
with:
68-
path: ~/.eslintcache
69-
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('.eslintrc') }}
70-
restore-keys: |
71-
${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('.eslintrc') }}
72-
${{ runner.os }}-${{ env.cache-name }}-
68+
path: |
69+
.eslintcache
70+
key: ${{ runner.os }}-eslint-${{ hashFiles('**/pnpm-lock.json', '**/eslint.config.js') }}
7371

7472
- name: Install
7573
run: pnpm install --frozen-lockfile --prefer-offline
@@ -92,12 +90,24 @@ jobs:
9290

9391
- name: Annotate ESLint Results
9492
if: ${{ github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' }}
95-
uses: ataylorme/eslint-annotate-action@v2
93+
uses: ataylorme/eslint-annotate-action@v3
9694
with:
97-
repo-token: "${{ secrets.GITHUB_TOKEN }}"
95+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
9896
report-json: "eslint.results.json"
99-
fail-on-warning: true
97+
fail-on-warning: false
98+
fail-on-error: false
10099

101-
- name: Check If ESLint Failed
100+
- name: Show ESLint Summary and Failures
102101
if : steps.eslint-continue.outcome == 'failure'
103-
run: exit 1
102+
run: |
103+
ERRORS=$(cat eslint.results.json | jq '[.[] | select(.errorCount > 0)] | length')
104+
WARNINGS=$(cat eslint.results.json | jq '[.[] | select(.warningCount > 0)] | length')
105+
106+
echo "Files with errors: $ERRORS"
107+
echo "Files with warnings: $WARNINGS"
108+
109+
if [ "$ERRORS" -gt 0 ]; then
110+
echo "::error::Found linting errors in $ERRORS files"
111+
pnpm lintcached
112+
exit 1
113+
fi

0 commit comments

Comments
 (0)