Skip to content

Commit cdc5eb3

Browse files
authored
Phase 3: Testing Infrastructure and CI/CD Setup (#3)
* Add functionality * add ci workflow * add dependabot config
1 parent 6c2c2e6 commit cdc5eb3

33 files changed

+2106
-59
lines changed

.github/dependabot.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Dependabot configuration for automatic dependency updates
2+
version: 2
3+
updates:
4+
# Enable version updates for npm packages
5+
- package-ecosystem: "npm"
6+
# Look for package.json and package-lock.json in the root directory
7+
directory: "/"
8+
# Check for updates weekly (daily can be too aggressive for a library)
9+
schedule:
10+
interval: "weekly"
11+
day: "monday"
12+
time: "09:00"
13+
timezone: "UTC"
14+
# Target the main branch for pull requests
15+
target-branch: "main"
16+
# Allow up to 5 open pull requests for npm dependencies
17+
open-pull-requests-limit: 5
18+
# Group updates for easier management
19+
groups:
20+
# Group all development dependencies together
21+
dev-dependencies:
22+
dependency-type: "development"
23+
patterns:
24+
- "*"
25+
update-types:
26+
- "minor"
27+
- "patch"
28+
# Group TypeScript-related updates
29+
typescript:
30+
patterns:
31+
- "typescript"
32+
- "@types/*"
33+
update-types:
34+
- "minor"
35+
- "patch"
36+
# Group testing-related updates
37+
testing:
38+
patterns:
39+
- "vitest"
40+
- "@vitest/*"
41+
update-types:
42+
- "minor"
43+
- "patch"
44+
# Automatically rebase open PRs when conflicts occur
45+
rebase-strategy: "auto"
46+
# Add labels to PRs
47+
labels:
48+
- "dependencies"
49+
- "automated"
50+
# Commit message prefix for consistency
51+
commit-message:
52+
prefix: "chore"
53+
include: "scope"
54+
55+
# Enable version updates for GitHub Actions
56+
- package-ecosystem: "github-actions"
57+
directory: "/"
58+
schedule:
59+
interval: "weekly"
60+
day: "monday"
61+
time: "09:00"
62+
timezone: "UTC"
63+
# Target the main branch for pull requests
64+
target-branch: "main"
65+
# Allow up to 5 open pull requests for Actions updates
66+
open-pull-requests-limit: 5
67+
# Group all Action updates together
68+
groups:
69+
github-actions:
70+
patterns:
71+
- "*"
72+
# Add labels to PRs
73+
labels:
74+
- "dependencies"
75+
- "github-actions"
76+
- "automated"
77+
# Commit message prefix for consistency
78+
commit-message:
79+
prefix: "chore"
80+
include: "scope"

.github/workflows/ci.yml

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
push:
7+
branches: [main]
8+
9+
# Cancel in-progress runs when a new run is triggered on the same branch
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
typecheck:
16+
name: Type Check
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: 20
27+
cache: 'npm'
28+
29+
- name: Install dependencies
30+
run: npm ci
31+
32+
- name: Run TypeScript type checking
33+
run: npm run typecheck
34+
35+
test:
36+
name: Test
37+
runs-on: ubuntu-latest
38+
39+
strategy:
40+
matrix:
41+
node-version: [18, 20, 22]
42+
43+
steps:
44+
- name: Checkout code
45+
uses: actions/checkout@v4
46+
47+
- name: Setup Node.js ${{ matrix.node-version }}
48+
uses: actions/setup-node@v4
49+
with:
50+
node-version: ${{ matrix.node-version }}
51+
cache: 'npm'
52+
53+
- name: Install dependencies
54+
run: npm ci
55+
56+
- name: Run tests
57+
run: npm test
58+
59+
- name: Generate coverage report
60+
if: matrix.node-version == 20
61+
run: npm run test:coverage
62+
63+
- name: Upload coverage reports
64+
if: matrix.node-version == 20
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: coverage-report
68+
path: coverage/
69+
70+
build:
71+
name: Build
72+
runs-on: ubuntu-latest
73+
needs: [typecheck, test]
74+
75+
steps:
76+
- name: Checkout code
77+
uses: actions/checkout@v4
78+
79+
- name: Setup Node.js
80+
uses: actions/setup-node@v4
81+
with:
82+
node-version: 20
83+
cache: 'npm'
84+
85+
- name: Install dependencies
86+
run: npm ci
87+
88+
- name: Build the library
89+
run: npm run build
90+
91+
- name: Verify build outputs
92+
run: |
93+
echo "Checking build outputs..."
94+
ls -la dist/
95+
96+
# Verify expected files exist
97+
if [[ ! -f "dist/index.js" ]]; then
98+
echo "Error: dist/index.js not found"
99+
exit 1
100+
fi
101+
102+
if [[ ! -f "dist/index.cjs" ]]; then
103+
echo "Error: dist/index.cjs not found"
104+
exit 1
105+
fi
106+
107+
if [[ ! -f "dist/index.d.ts" ]]; then
108+
echo "Error: dist/index.d.ts not found"
109+
exit 1
110+
fi
111+
112+
echo "✅ All build outputs verified successfully"
113+
114+
- name: Upload build artifacts
115+
uses: actions/upload-artifact@v4
116+
with:
117+
name: build-artifacts
118+
path: dist/
119+
120+
# Summary job to ensure all checks pass
121+
ci-success:
122+
name: CI Success
123+
runs-on: ubuntu-latest
124+
needs: [typecheck, test, build]
125+
if: always()
126+
127+
steps:
128+
- name: Check all jobs status
129+
run: |
130+
if [[ "${{ needs.typecheck.result }}" != "success" || \
131+
"${{ needs.test.result }}" != "success" || \
132+
"${{ needs.build.result }}" != "success" ]]; then
133+
echo "❌ One or more CI checks failed"
134+
echo "TypeCheck: ${{ needs.typecheck.result }}"
135+
echo "Test: ${{ needs.test.result }}"
136+
echo "Build: ${{ needs.build.result }}"
137+
exit 1
138+
fi
139+
echo "✅ All CI checks passed successfully!"

0 commit comments

Comments
 (0)