-
Notifications
You must be signed in to change notification settings - Fork 113
66 lines (52 loc) · 1.73 KB
/
verify.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Verify
on:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.sha }}
cancel-in-progress: true
jobs:
formatting-lint:
name: Check for formatting & lint errors
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
with:
# Make sure the actual branch is checked out when running on pull requests
ref: ${{ github.head_ref }}
- name: Setup Node
uses: actions/[email protected]
with:
node-version-file: .nvmrc
cache: 'npm'
- name: Install Dependencies
run: npm ci
- id: files
uses: Ana06/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Filter JS/TS Files
run: |
echo "${{ steps.files.outputs.added_modified }}" | tr ' ' '\n' | grep -E '\.(js|ts|jsx|tsx)$' > changed_files.txt
if [ ! -s changed_files.txt ]; then
echo "No JS/TS files to format or lint."
exit 0
fi
- name: Run format Checks
run: |
if [ -s changed_files.txt ]; then
npx prettier --write $(cat changed_files.txt)
fi
- run: git diff --exit-code
- name: Formatting Error message
if: ${{ failure() }}
run: |
echo 'prettier formatting failure. Ensure you run `npm run format` and commit the files.'
- name: Run eslint Checks
run: |
npx eslint ${{steps.files.outputs.added_modified}} --fix
- run: git diff --exit-code
- name: Eslint Error message
if: ${{ failure() }}
run: |
echo 'Eslint failure. Ensure you run `npm run lint:fix` and commit the files.'