99 tests :
1010 name : " Unit and E2E Tests"
1111 runs-on : ubuntu-latest
12+ permissions :
13+ contents : read
14+ pull-requests : write
1215 steps :
1316 - name : Checkout code
1417 uses : actions/checkout@v4
@@ -28,10 +31,16 @@ jobs:
2831 run : docker compose up -d
2932
3033 - name : Wait for container to be ready
34+ id : container-startup
3135 run : |
36+ START_TIME=$(date +%s%3N)
3237 for i in {1..30}; do
3338 if curl -f http://localhost:3000/v1/health > /dev/null 2>&1; then
34- echo "Container is ready!"
39+ END_TIME=$(date +%s%3N)
40+ STARTUP_TIME_MS=$((END_TIME - START_TIME))
41+ STARTUP_TIME=$(echo "scale=2; $STARTUP_TIME_MS / 1000" | bc)
42+ echo "startup_time=$STARTUP_TIME" >> $GITHUB_OUTPUT
43+ echo "Container is ready in ${STARTUP_TIME}s!"
3544 exit 0
3645 fi
3746 echo "Waiting for container... ($i/30)"
4251 docker compose logs
4352 exit 1
4453
54+ - name : Collect Docker stats
55+ if : github.event_name == 'pull_request'
56+ continue-on-error : true
57+ id : docker-stats
58+ run : |
59+ # Get image size
60+ IMAGE_SIZE=$(docker images appwrite/browser:local --format "{{.Size}}")
61+
62+ # Get container stats
63+ CONTAINER_ID=$(docker compose ps -q appwrite-browser)
64+ MEMORY_USAGE=$(docker stats $CONTAINER_ID --no-stream --format "{{.MemUsage}}" | cut -d'/' -f1 | xargs)
65+
66+ # Quick screenshot benchmark (3 runs, average)
67+ TOTAL=0
68+ for i in {1..3}; do
69+ START=$(date +%s%3N)
70+ curl -s -X POST http://localhost:3000/v1/screenshots \
71+ -H "Content-Type: application/json" \
72+ -d '{"url":"https://appwrite.io"}' \
73+ -o /dev/null
74+ END=$(date +%s%3N)
75+ DURATION=$((END - START))
76+ TOTAL=$((TOTAL + DURATION))
77+ done
78+ SCREENSHOT_AVG_MS=$((TOTAL / 3))
79+ SCREENSHOT_AVG=$(echo "scale=2; $SCREENSHOT_AVG_MS / 1000" | bc)
80+
81+ # Store in GitHub output
82+ echo "image_size=$IMAGE_SIZE" >> $GITHUB_OUTPUT
83+ echo "memory_usage=$MEMORY_USAGE" >> $GITHUB_OUTPUT
84+ echo "screenshot_time=$SCREENSHOT_AVG" >> $GITHUB_OUTPUT
85+
86+ - name : Comment PR with stats
87+ if : github.event_name == 'pull_request' && steps.docker-stats.outcome == 'success'
88+ continue-on-error : true
89+ uses : marocchino/sticky-pull-request-comment@v2
90+ with :
91+ header : docker-image-stats
92+ skip_unchanged : true
93+ message : |
94+ ## Docker Image Stats
95+
96+ | Metric | Value |
97+ |--------|-------|
98+ | Image Size | ${{ steps.docker-stats.outputs.image_size }} |
99+ | Memory Usage | ${{ steps.docker-stats.outputs.memory_usage }} |
100+ | Cold Start Time | ${{ steps.container-startup.outputs.startup_time }}s |
101+ | Screenshot Time | ${{ steps.docker-stats.outputs.screenshot_time }}s |
102+
103+ <sub>Screenshot benchmark: Average of 3 runs on https://appwrite.io</sub>
104+
45105 - name : Run e2e tests
46106 run : bun test:e2e
47107
0 commit comments