Skip to content

Commit e51309c

Browse files
authored
Merge pull request #13 from appwrite/add-stats-on-pr
2 parents ff2bc5b + 231a696 commit e51309c

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

.github/workflows/test.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ jobs:
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
@@ -42,6 +45,71 @@ jobs:
4245
docker compose logs
4346
exit 1
4447
48+
- name: Collect Docker stats
49+
if: github.event_name == 'pull_request'
50+
continue-on-error: true
51+
id: docker-stats
52+
run: |
53+
# Get image size
54+
IMAGE_SIZE=$(docker images appwrite/browser:local --format "{{.Size}}")
55+
56+
# Get container stats
57+
CONTAINER_ID=$(docker compose ps -q appwrite-browser)
58+
MEMORY_USAGE=$(docker stats $CONTAINER_ID --no-stream --format "{{.MemUsage}}" | cut -d'/' -f1 | xargs)
59+
60+
# Quick screenshot benchmark (3 runs, average)
61+
TOTAL=0
62+
for i in {1..3}; do
63+
START=$(date +%s%3N)
64+
curl -s -X POST http://localhost:3000/v1/screenshots \
65+
-H "Content-Type: application/json" \
66+
-d '{"url":"https://appwrite.io"}' \
67+
-o /dev/null
68+
END=$(date +%s%3N)
69+
DURATION=$((END - START))
70+
TOTAL=$((TOTAL + DURATION))
71+
done
72+
SCREENSHOT_AVG_MS=$((TOTAL / 3))
73+
SCREENSHOT_AVG=$(echo "scale=2; $SCREENSHOT_AVG_MS / 1000" | bc)
74+
75+
# Measure fresh startup time
76+
START_TIME=$(date +%s%3N)
77+
docker compose restart appwrite-browser
78+
for i in {1..30}; do
79+
if curl -f http://localhost:3000/v1/health > /dev/null 2>&1; then
80+
END_TIME=$(date +%s%3N)
81+
STARTUP_TIME_MS=$((END_TIME - START_TIME))
82+
break
83+
fi
84+
sleep 0.1
85+
done
86+
STARTUP_TIME=$(echo "scale=2; $STARTUP_TIME_MS / 1000" | bc)
87+
88+
# Store in GitHub output
89+
echo "image_size=$IMAGE_SIZE" >> $GITHUB_OUTPUT
90+
echo "memory_usage=$MEMORY_USAGE" >> $GITHUB_OUTPUT
91+
echo "startup_time=$STARTUP_TIME" >> $GITHUB_OUTPUT
92+
echo "screenshot_time=$SCREENSHOT_AVG" >> $GITHUB_OUTPUT
93+
94+
- name: Comment PR with stats
95+
if: github.event_name == 'pull_request' && steps.docker-stats.outcome == 'success'
96+
continue-on-error: true
97+
uses: marocchino/sticky-pull-request-comment@v2
98+
with:
99+
header: docker-image-stats
100+
skip_unchanged: true
101+
message: |
102+
## Docker Image Stats
103+
104+
| Metric | Value |
105+
|--------|-------|
106+
| Image Size | ${{ steps.docker-stats.outputs.image_size }} |
107+
| Memory Usage | ${{ steps.docker-stats.outputs.memory_usage }} |
108+
| Startup Time | ${{ steps.docker-stats.outputs.startup_time }}s |
109+
| Screenshot Time | ${{ steps.docker-stats.outputs.screenshot_time }}s |
110+
111+
<sub>Screenshot benchmark: Average of 3 runs on https://appwrite.io</sub>
112+
45113
- name: Run e2e tests
46114
run: bun test:e2e
47115

src/utils/clean-modules.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ async function removeUnnecessaryFiles(): Promise<void> {
170170
);
171171
await deletePath(`${NODE_MODULES}/@sentry`);
172172
await deletePath(`${NODE_MODULES}/@opentelemetry`);
173+
await deletePath(`${NODE_MODULES}/axe-core/axe.js`);
173174
await deletePath(`${NODE_MODULES}/lighthouse/cli`);
174175
await deletePath(`${NODE_MODULES}/lighthouse/build-tracker.config.js`);
175176
await deletePath(`${NODE_MODULES}/lighthouse/commitlint.config.js`);

0 commit comments

Comments
 (0)