Skip to content

Commit b6167d6

Browse files
feat(ci): add GitHub Actions workflow for unit and end-to-end testing
1 parent c391782 commit b6167d6

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
workflow_dispatch:
6+
7+
jobs:
8+
unit-tests:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v5
13+
14+
- name: Setup Node.js
15+
uses: actions/setup-node@v4
16+
with:
17+
node-version: 20
18+
cache: npm
19+
20+
- name: Install dependencies
21+
run: npm ci
22+
23+
- name: Run unit tests with coverage
24+
run: npm run coverage
25+
26+
e2e-tests:
27+
runs-on: ubuntu-latest
28+
needs: unit-tests
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v5
32+
33+
- name: Build Docker image
34+
run: docker build -t fastrender-test .
35+
36+
- name: Start container
37+
run: docker run -d --name fastrender -p 3000:3000 fastrender-test
38+
39+
- name: Wait for server to be ready
40+
run: |
41+
for i in $(seq 1 30); do
42+
if curl -s http://localhost:3000/docs > /dev/null 2>&1; then
43+
echo "Server is ready"
44+
exit 0
45+
fi
46+
echo "Waiting for server... ($i/30)"
47+
sleep 2
48+
done
49+
echo "Server failed to start"
50+
docker logs fastrender
51+
exit 1
52+
53+
- name: Setup Node.js
54+
uses: actions/setup-node@v4
55+
with:
56+
node-version: 20
57+
cache: npm
58+
59+
- name: Install dependencies
60+
run: npm ci
61+
62+
- name: Run E2E tests
63+
run: npm run test:e2e
64+
65+
- name: Print container logs on failure
66+
if: failure()
67+
run: docker logs fastrender
68+
69+
- name: Stop container
70+
if: always()
71+
run: docker rm -f fastrender

0 commit comments

Comments
 (0)