-
-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (94 loc) · 3.58 KB
/
Copy pathci.yml
File metadata and controls
106 lines (94 loc) · 3.58 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: TypeScript/Node.js CI
on:
push:
branches: [ main, master, develop ]
pull_request:
branches: [ main, master, develop ]
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Detect package manager
id: detect
run: |
if [ -f "pnpm-lock.yaml" ]; then
echo "pm=pnpm" >> $GITHUB_OUTPUT
elif [ -f "yarn.lock" ]; then
echo "pm=yarn" >> $GITHUB_OUTPUT
elif [ -f "package-lock.json" ] || [ -f "package.json" ]; then
echo "pm=npm" >> $GITHUB_OUTPUT
else
echo "pm=none" >> $GITHUB_OUTPUT
fi
- name: Install pnpm
if: steps.detect.outputs.pm == 'pnpm'
run: npm install -g pnpm
- name: Install dependencies
if: steps.detect.outputs.pm != 'none'
run: |
if [ "${{ steps.detect.outputs.pm }}" == "pnpm" ]; then
pnpm install || true
elif [ "${{ steps.detect.outputs.pm }}" == "yarn" ]; then
yarn install || true
else
npm install || true
fi
- name: Lint with ESLint
continue-on-error: true
if: steps.detect.outputs.pm != 'none'
run: |
if [ "${{ steps.detect.outputs.pm }}" == "pnpm" ]; then
pnpm run lint || echo "::warning::ESLint found issues"
elif [ "${{ steps.detect.outputs.pm }}" == "yarn" ]; then
yarn lint || echo "::warning::ESLint found issues"
else
npm run lint || echo "::warning::ESLint found issues"
fi
- name: Type check with tsc
continue-on-error: true
if: steps.detect.outputs.pm != 'none' && hashFiles('tsconfig.json') != ''
run: |
if [ -f "tsconfig.json" ]; then
npx tsc --noEmit || echo "::warning::TypeScript found type errors"
else
echo "::notice::No tsconfig.json found, skipping type checking"
fi
- name: Run tests
if: steps.detect.outputs.pm != 'none'
run: |
if [ "${{ steps.detect.outputs.pm }}" == "pnpm" ]; then
pnpm test -- --coverage || echo "::notice::No tests configured"
elif [ "${{ steps.detect.outputs.pm }}" == "yarn" ]; then
yarn test --coverage || echo "::notice::No tests configured"
else
npm test -- --coverage || echo "::notice::No tests configured"
fi
- name: Upload coverage to Codecov
if: success() && hashFiles('coverage/lcov.info') != ''
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4
with:
files: ./coverage/lcov.info
fail_ci_if_error: false
flags: unittests
name: codecov-${{ matrix.node-version }}
- name: Build
if: steps.detect.outputs.pm != 'none'
run: |
if [ "${{ steps.detect.outputs.pm }}" == "pnpm" ]; then
pnpm run build || echo "::notice::No build script configured"
elif [ "${{ steps.detect.outputs.pm }}" == "yarn" ]; then
yarn build || echo "::notice::No build script configured"
else
npm run build || echo "::notice::No build script configured"
fi