|
7 | 7 | branches: [main] |
8 | 8 |
|
9 | 9 | jobs: |
10 | | - # Code quality checks (lint + format) |
11 | | - quality: |
12 | | - name: Code Quality |
| 10 | + ci: |
| 11 | + name: CI |
13 | 12 | runs-on: ubuntu-latest |
14 | 13 |
|
15 | 14 | steps: |
16 | | - - uses: actions/checkout@v4 |
| 15 | + - uses: actions/checkout@v6 |
17 | 16 |
|
18 | | - - name: Use Node.js 20.x |
19 | | - uses: actions/setup-node@v4 |
| 17 | + - name: Set up Node.js |
| 18 | + uses: actions/setup-node@v6 |
20 | 19 | with: |
21 | | - node-version: 20.x |
| 20 | + node-version-file: 'package.json' |
22 | 21 | cache: 'npm' |
23 | 22 |
|
24 | 23 | - name: Install dependencies |
25 | 24 | run: npm ci |
26 | 25 |
|
27 | | - - name: Run ESLint |
28 | | - run: npm run lint |
29 | | - |
30 | | - - name: Check formatting |
| 26 | + - name: Check prettier |
31 | 27 | run: npm run format:check |
32 | | - |
33 | | - # Test with coverage |
34 | | - test: |
35 | | - name: Test (Node ${{ matrix.node-version }}) |
36 | | - runs-on: ubuntu-latest |
37 | | - |
38 | | - strategy: |
39 | | - matrix: |
40 | | - node-version: [20.x, 22.x] |
41 | | - |
42 | | - steps: |
43 | | - - uses: actions/checkout@v4 |
44 | 28 |
|
45 | | - - name: Use Node.js ${{ matrix.node-version }} |
46 | | - uses: actions/setup-node@v4 |
47 | | - with: |
48 | | - node-version: ${{ matrix.node-version }} |
49 | | - cache: 'npm' |
50 | | - |
51 | | - - name: Install dependencies |
52 | | - run: npm ci |
53 | | - |
54 | | - - name: Run tests with coverage |
55 | | - run: npm run test:cov |
56 | | - |
57 | | - - name: Upload coverage to Codecov |
58 | | - if: matrix.node-version == '20.x' |
59 | | - uses: codecov/codecov-action@v4 |
60 | | - with: |
61 | | - files: ./coverage/lcov.info |
62 | | - fail_ci_if_error: false |
63 | | - |
64 | | - # Build check |
65 | | - build: |
66 | | - name: Build |
67 | | - runs-on: ubuntu-latest |
68 | | - needs: [quality, test] |
69 | | - |
70 | | - steps: |
71 | | - - uses: actions/checkout@v4 |
72 | | - |
73 | | - - name: Use Node.js 20.x |
74 | | - uses: actions/setup-node@v4 |
75 | | - with: |
76 | | - node-version: 20.x |
77 | | - cache: 'npm' |
| 29 | + - name: Check eslint |
| 30 | + run: npm run lint |
78 | 31 |
|
79 | | - - name: Install dependencies |
80 | | - run: npm ci |
| 32 | + - name: Run tests |
| 33 | + run: npm test |
81 | 34 |
|
82 | 35 | - name: Build package |
83 | 36 | run: npm run build |
84 | | - |
85 | | - - name: Check build output |
86 | | - run: | |
87 | | - if [ ! -d "dist" ]; then |
88 | | - echo "Build failed: dist directory not found" |
89 | | - exit 1 |
90 | | - fi |
91 | | - if [ ! -f "dist/index.js" ]; then |
92 | | - echo "Build failed: dist/index.js not found" |
93 | | - exit 1 |
94 | | - fi |
95 | | - if [ ! -f "dist/index.d.ts" ]; then |
96 | | - echo "Build failed: dist/index.d.ts not found" |
97 | | - exit 1 |
98 | | - fi |
99 | | - echo "Build successful!" |
100 | | - |
101 | | - - name: Pack package |
102 | | - run: npm pack |
103 | | - |
104 | | - - name: Upload build artifact |
105 | | - uses: actions/upload-artifact@v4 |
106 | | - with: |
107 | | - name: package-build |
108 | | - path: '*.tgz' |
109 | | - retention-days: 7 |
0 commit comments