Skip to content

Commit 4aede59

Browse files
chore: run e2e tests in CI (#35)
* allow dynamic port allocation * rest of the scripts * added e2e workflow * fix workflow
1 parent b0b7fbf commit 4aede59

43 files changed

Lines changed: 1156 additions & 398 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Tusk directories (created by tests, owned by root, cause permission issues)
2+
.tusk/
3+
**/.tusk/
4+
5+
# Dependencies
6+
node_modules/
7+
**/node_modules/
8+
9+
# Build outputs
10+
dist/
11+
build/
12+
*.tsbuildinfo
13+
14+
# Git
15+
.git/
16+
.gitignore
17+
18+
# IDE
19+
.vscode/
20+
.idea/
21+
*.swp
22+
*.swo
23+
*~
24+
25+
# OS
26+
.DS_Store
27+
Thumbs.db
28+
29+
# Testing
30+
coverage/
31+
.nyc_output/
32+
33+
# Environment
34+
.env
35+
.env.local
36+
.env.*.local
37+
38+
# Logs
39+
*.log
40+
npm-debug.log*
41+
yarn-debug.log*
42+
yarn-error.log*
43+
44+
# Misc
45+
.cache/
46+
tmp/
47+
temp/

.github/workflows/e2e.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: E2E Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch: {}
9+
10+
jobs:
11+
e2e:
12+
name: E2E Tests (SDK + CLI)
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 10
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: 22
23+
24+
- name: Setup Docker Buildx
25+
uses: docker/setup-buildx-action@v3
26+
with:
27+
driver: docker
28+
29+
- name: Install SDK dependencies
30+
run: npm install
31+
32+
- name: Build SDK
33+
run: npm run build
34+
35+
- name: Run all E2E tests
36+
env:
37+
DOCKER_DEFAULT_PLATFORM: linux/amd64
38+
run: ./run-all-e2e-tests.sh 2
39+
40+
- name: Cleanup Docker resources
41+
if: always()
42+
run: |
43+
# Stop all running containers
44+
docker ps -aq | xargs -r docker stop || true
45+
docker ps -aq | xargs -r docker rm || true
46+
# Clean up volumes
47+
docker volume prune -f || true
48+
# Clean up networks
49+
docker network prune -f || true

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,7 @@ coverage/
4141
.Trashes
4242
ehthumbs.db
4343
Thumbs.db
44+
45+
# E2E test generated files
46+
**/e2e-tests/**/.tusk/logs/
47+
**/e2e-tests/**/.tusk/traces/

E2E_TESTING_GUIDE.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ This prevents confusion from old test runs and makes it easier to identify curre
5656
Build and start the Docker container in detached mode:
5757

5858
```bash
59-
docker-compose up -d --build --wait
59+
docker compose up -d --build --wait
6060
```
6161

6262
### Step 4: Start Server in RECORD Mode
6363

6464
Start the application server in RECORD mode to capture network traffic:
6565

6666
```bash
67-
docker-compose exec -e TUSK_DRIFT_MODE=RECORD app sh -c "npm run build && npm run dev"
67+
docker compose exec -e TUSK_DRIFT_MODE=RECORD app sh -c "npm run build && npm run dev"
6868
```
6969

7070
Wait a few seconds for the server to fully start (5-10 seconds recommended):
@@ -79,10 +79,10 @@ Use `curl` to make requests to the endpoints you want to test. You can hit one o
7979

8080
```bash
8181
# Example: GET request
82-
docker-compose exec app curl -s http://localhost:3000/test/fetch-get
82+
docker compose exec app curl -s http://localhost:3000/test/fetch-get
8383

8484
# Example: POST request with JSON body
85-
docker-compose exec app curl -s -X POST -H "Content-Type: application/json" \
85+
docker compose exec app curl -s -X POST -H "Content-Type: application/json" \
8686
-d '{"title":"test","body":"test body"}' \
8787
http://localhost:3000/test/fetch-post
8888
```
@@ -102,7 +102,7 @@ sleep 3
102102
Stop the Node.js server process:
103103

104104
```bash
105-
docker-compose exec app pkill -f "node" || true
105+
docker compose exec app pkill -f "node" || true
106106
sleep 2
107107
```
108108

@@ -111,7 +111,7 @@ sleep 2
111111
Run the Tusk CLI to replay the recorded traces:
112112

113113
```bash
114-
docker-compose exec -T app tusk run --print --output-format "json" --enable-service-logs
114+
docker compose exec -T app tusk run --print --output-format "json" --enable-service-logs
115115
```
116116

117117
**Flags explained:**
@@ -180,7 +180,7 @@ When you need to fix instrumentation code:
180180
When you're done testing, clean up the Docker containers:
181181

182182
```bash
183-
docker-compose down
183+
docker compose down
184184
```
185185

186186
## Important Notes
@@ -242,26 +242,26 @@ Use `run.sh` for full test runs, and use the manual steps above for iterative de
242242
rm -rf .tusk/traces/* .tusk/logs/*
243243
244244
# Start containers
245-
docker-compose up -d --build
245+
docker compose up -d --build
246246
247247
# Start server in RECORD mode
248-
docker-compose exec -d -e TUSK_DRIFT_MODE=RECORD app sh -c "npm run build && npm run dev"
248+
docker compose exec -d -e TUSK_DRIFT_MODE=RECORD app sh -c "npm run build && npm run dev"
249249
250250
# Stop server
251-
docker-compose exec app pkill -f "node" || true
251+
docker compose exec app pkill -f "node" || true
252252
253253
# Run tests
254-
docker-compose exec -T app tusk run --print --output-format "json" --enable-service-logs
254+
docker compose exec -T app tusk run --print --output-format "json" --enable-service-logs
255255
256256
# View logs
257-
docker-compose exec app ls .tusk/logs
258-
docker-compose exec app cat .tusk/logs/<log-file>
257+
docker compose exec app ls .tusk/logs
258+
docker compose exec app cat .tusk/logs/<log-file>
259259
260260
# Rebuild SDK (from repo root)
261261
npm run build
262262
263263
# Clean up containers
264-
docker-compose down
264+
docker compose down
265265
266266
# Run full automated test
267267
./run.sh

0 commit comments

Comments
 (0)