Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ jobs:
tests:
name: "Unit and E2E Tests"
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -42,6 +45,71 @@ jobs:
docker compose logs
exit 1

- name: Collect Docker stats
if: github.event_name == 'pull_request'
continue-on-error: true
id: docker-stats
run: |
# Get image size
IMAGE_SIZE=$(docker images appwrite/browser:local --format "{{.Size}}")

# Get container stats
CONTAINER_ID=$(docker compose ps -q appwrite-browser)
MEMORY_USAGE=$(docker stats $CONTAINER_ID --no-stream --format "{{.MemUsage}}" | cut -d'/' -f1 | xargs)

# Quick screenshot benchmark (3 runs, average)
TOTAL=0
for i in {1..3}; do
START=$(date +%s%3N)
curl -s -X POST http://localhost:3000/v1/screenshots \
-H "Content-Type: application/json" \
-d '{"url":"https://appwrite.io"}' \
-o /dev/null
END=$(date +%s%3N)
DURATION=$((END - START))
TOTAL=$((TOTAL + DURATION))
done
SCREENSHOT_AVG_MS=$((TOTAL / 3))
SCREENSHOT_AVG=$(echo "scale=2; $SCREENSHOT_AVG_MS / 1000" | bc)

# Measure fresh startup time
START_TIME=$(date +%s%3N)
docker compose restart appwrite-browser
for i in {1..30}; do
if curl -f http://localhost:3000/v1/health > /dev/null 2>&1; then
END_TIME=$(date +%s%3N)
STARTUP_TIME_MS=$((END_TIME - START_TIME))
break
fi
sleep 0.1
done
STARTUP_TIME=$(echo "scale=2; $STARTUP_TIME_MS / 1000" | bc)

# Store in GitHub output
echo "image_size=$IMAGE_SIZE" >> $GITHUB_OUTPUT
echo "memory_usage=$MEMORY_USAGE" >> $GITHUB_OUTPUT
echo "startup_time=$STARTUP_TIME" >> $GITHUB_OUTPUT
echo "screenshot_time=$SCREENSHOT_AVG" >> $GITHUB_OUTPUT

- name: Comment PR with stats
if: github.event_name == 'pull_request' && steps.docker-stats.outcome == 'success'
continue-on-error: true
uses: marocchino/sticky-pull-request-comment@v2
with:
header: docker-image-stats
skip_unchanged: true
message: |
## Docker Image Stats

| Metric | Value |
|--------|-------|
| Image Size | ${{ steps.docker-stats.outputs.image_size }} |
| Memory Usage | ${{ steps.docker-stats.outputs.memory_usage }} |
| Startup Time | ${{ steps.docker-stats.outputs.startup_time }}s |
| Screenshot Time | ${{ steps.docker-stats.outputs.screenshot_time }}s |

<sub>Screenshot benchmark: Average of 3 runs on https://appwrite.io</sub>

- name: Run e2e tests
run: bun test:e2e

Expand Down
1 change: 1 addition & 0 deletions src/utils/clean-modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ async function removeUnnecessaryFiles(): Promise<void> {
);
await deletePath(`${NODE_MODULES}/@sentry`);
await deletePath(`${NODE_MODULES}/@opentelemetry`);
await deletePath(`${NODE_MODULES}/axe-core/axe.js`);
await deletePath(`${NODE_MODULES}/lighthouse/cli`);
await deletePath(`${NODE_MODULES}/lighthouse/build-tracker.config.js`);
await deletePath(`${NODE_MODULES}/lighthouse/commitlint.config.js`);
Expand Down