-
-
Notifications
You must be signed in to change notification settings - Fork 1
141 lines (125 loc) · 5.01 KB
/
Copy pathtest.yml
File metadata and controls
141 lines (125 loc) · 5.01 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Testing & Coverage
on:
push:
branches: [main, dev]
pull_request:
branches: [main, dev]
jobs:
test-coverage:
name: Test Suite & Coverage Report
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Verify Node.js version meets requirements
run: |
echo "Node.js version:"
node --version
echo "npm version:"
npm --version
echo "Checking Node.js version compatibility..."
node -e "
const version = process.version;
const major = parseInt(version.slice(1).split('.')[0]);
const required = 16;
console.log(\`Node.js \${version} (major: \${major})\`);
if (major < required) {
console.error(\`❌ Node.js \${major} is below minimum required version \${required}\`);
process.exit(1);
} else {
console.log(\`✅ Node.js \${major} meets minimum requirement \${required}\`);
}
"
- name: Enable Corepack for pnpm
run: |
echo "Current Node.js version:"
node --version
echo "Enabling Corepack..."
corepack enable
echo "Preparing pnpm 9.15.4..."
corepack prepare pnpm@9.15.4 --activate
echo "pnpm setup complete"
- name: Verify pnpm version
run: |
echo "pnpm version:"
pnpm --version
echo "Checking package manager field..."
node -e "console.log('packageManager:', require('./package.json').packageManager)"
- name: Install dependencies
run: |
echo "Installing dependencies with pnpm..."
echo "Current working directory: $(pwd)"
echo "Files in directory:"
ls -la
echo "Installing..."
pnpm install --frozen-lockfile
echo "Dependencies installed successfully"
- name: Verify installation
run: |
echo "Checking node_modules..."
ls -la node_modules/ | head -10
echo "Checking TypeScript and Jest installation..."
# Check TypeScript
if pnpm tsc --version > /dev/null 2>&1; then
echo "✅ TypeScript: $(pnpm tsc --version)"
elif npx tsc --version > /dev/null 2>&1; then
echo "✅ TypeScript: $(npx tsc --version)"
else
echo "⚠️ TypeScript: Not accessible via pnpm/npx, checking package.json..."
TS_VERSION=$(node -e "const pkg = require('./package.json'); console.log(pkg.devDependencies?.typescript || '')")
if [ -n "$TS_VERSION" ] && [ "$TS_VERSION" != "undefined" ]; then
echo " ✅ TypeScript is listed in devDependencies: $TS_VERSION"
else
echo " ❌ TypeScript may not be installed"
fi
fi
# Check Jest
if pnpm jest --version > /dev/null 2>&1; then
echo "✅ Jest: $(pnpm jest --version)"
elif npx jest --version > /dev/null 2>&1; then
echo "✅ Jest: $(npx jest --version)"
else
echo "⚠️ Jest: Not accessible via pnpm/npx, checking package.json..."
JEST_VERSION=$(node -e "const pkg = require('./package.json'); console.log(pkg.devDependencies?.jest || '')")
if [ -n "$JEST_VERSION" ] && [ "$JEST_VERSION" != "undefined" ]; then
echo " ✅ Jest is listed in devDependencies: $JEST_VERSION"
else
echo " ❌ Jest may not be installed"
fi
fi
echo "✅ Dependency verification completed"
- name: Run test suite with coverage and threshold check
run: |
echo "Running full test suite with coverage..."
echo "Coverage threshold: 80% (configured in jest.config.cjs)"
pnpm test -- --coverage --watchAll=false
echo "✅ Test suite passed with coverage requirements"
- name: Validate coverage reports exist
run: |
echo "Validating coverage report generation..."
if [ ! -f "./coverage/lcov.info" ]; then
echo "❌ Coverage report not generated"
exit 1
fi
echo "✅ Coverage reports generated successfully"
echo "Coverage report size:"
ls -lh ./coverage/lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/lcov.info
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
verbose: true
- name: Upload coverage reports as artifacts
uses: actions/upload-artifact@v4
with:
name: coverage-reports
path: coverage/
retention-days: 7