-
Notifications
You must be signed in to change notification settings - Fork 62
51 lines (42 loc) · 1.3 KB
/
ci.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
name: CI Testing
on: pull_request
permissions: read-all
jobs:
lint-and-test:
name: Run ESLint, TypeScript, and Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: cache node modules
id: cache-dep
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-lint-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
if: steps.cache-dep.outputs.cache-hit != 'true'
run: npm ci
- name: Collect changed files
run: |
git diff ${{ github.event.pull_request.base.sha }} ${{ github.sha }} --diff-filter=ACM --name-only | grep -E '\.(js|jsx|ts|tsx)$' > ~/lintable_files || true
echo "Files to lint:"
cat ~/lintable_files
- name: Lint
run: |
if [ -s ~/lintable_files ]; then
npx eslint $(cat ~/lintable_files)
else
echo "No files to lint"
fi
- name: TypeScript Checker
run: npx tsc --emitDeclarationOnly
- name: Run Tests
run: npm run test