Establish comprehensive quality infrastructure for a project that previously had zero tests, enabling confident refactoring and community contributions with automated guardrails. Port upstream enhancements for font normalization, image element support, and arrow binding preservation. 🏗️ Testing infrastructure: - Unit tests for SQLite persistence layer and element validation helpers - Integration tests for REST API, WebSocket broadcast, and arrow binding - E2E tests with Playwright for canvas rendering and real-time sync - Vitest + Playwright configuration with proper isolation 👷 CI/CD pipeline: - Auto-versioning from conventional commits on push to main - Auto-publish to NPM and Docker Hub on GitHub release - Matrix testing across Node 18/20/22 with pinned dependencies - Docker health check with diagnostic logging on failure - Preserve rollup status checks for branch protection gates 📦 Developer experience: - Interactive setup wizard for first-time configuration - Canvas clear confirmation and scene description tools - Frontend helpers extracted for testability 🔧 Upstream feature ports: - Font family normalization (string names to numeric IDs) - Image element support with file management API - Arrow binding preservation through server round-trips - Vite config fix for font subsetting worker chunk names - Idempotent database initialization for standalone Docker mode 🐛 Docker fixes: - Set EXCALIDRAW_DB_PATH in both Dockerfiles to writable /app/data/ - Make initDb() idempotent and closeDb() reset-safe for test isolation 🎯 Provides the safety net needed for rapid iteration — every PR is validated across 120 test cases before merge, and releases are fully automated from commit to published package. Co-authored-by: sanjibdevnathlabs <devnath.sanjib@gmail.com>
150 lines
5.0 KiB
YAML
150 lines
5.0 KiB
YAML
name: Docker Build
|
|
|
|
# PR validation and manual builds. Production pushes are handled by release.yml.
|
|
on:
|
|
pull_request:
|
|
branches: [main]
|
|
paths:
|
|
- 'Dockerfile*'
|
|
- 'src/**'
|
|
- 'frontend/**'
|
|
- 'package.json'
|
|
workflow_dispatch:
|
|
inputs:
|
|
push:
|
|
description: 'Push images to Docker Hub'
|
|
required: true
|
|
type: boolean
|
|
default: false
|
|
|
|
env:
|
|
IMAGE_NAME_MCP: sanjibdevnath/mcp-excalidraw-local
|
|
IMAGE_NAME_CANVAS: sanjibdevnath/mcp-excalidraw-local-canvas
|
|
|
|
jobs:
|
|
build-mcp:
|
|
name: Build MCP Server image
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to Docker Hub
|
|
if: github.event_name == 'workflow_dispatch' && github.event.inputs.push == 'true'
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Extract metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ env.IMAGE_NAME_MCP }}
|
|
tags: |
|
|
type=ref,event=pr
|
|
type=sha,prefix=sha-
|
|
|
|
- name: Build MCP Server image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
push: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.push == 'true' }}
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
build-canvas:
|
|
name: Build Canvas Server image
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to Docker Hub
|
|
if: github.event_name == 'workflow_dispatch' && github.event.inputs.push == 'true'
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Extract metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ env.IMAGE_NAME_CANVAS }}
|
|
tags: |
|
|
type=ref,event=pr
|
|
type=sha,prefix=sha-
|
|
|
|
- name: Build Canvas Server image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile.canvas
|
|
push: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.push == 'true' }}
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
test-images:
|
|
name: Test Docker images
|
|
needs: [build-mcp, build-canvas]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Build and test Canvas image locally
|
|
run: |
|
|
docker build -f Dockerfile.canvas -t canvas-test .
|
|
docker run -d -p 3000:3000 --name test-canvas canvas-test
|
|
HEALTHY=false
|
|
for i in $(seq 1 30); do
|
|
if curl -sf http://localhost:3000/health > /dev/null 2>&1; then
|
|
echo "Health check passed on attempt $i"
|
|
HEALTHY=true
|
|
break
|
|
fi
|
|
echo "Waiting for server... ($i/30)"
|
|
sleep 1
|
|
done
|
|
if [ "$HEALTHY" != "true" ]; then
|
|
echo "::error::Health check failed after 30 attempts"
|
|
docker logs test-canvas
|
|
docker stop test-canvas || true
|
|
exit 1
|
|
fi
|
|
curl -sf http://localhost:3000/health | jq .
|
|
docker stop test-canvas
|
|
|
|
docker-status:
|
|
runs-on: ubuntu-latest
|
|
continue-on-error: false
|
|
name: Docker Build Status Check
|
|
needs: [build-mcp, build-canvas, test-images]
|
|
if: always()
|
|
permissions:
|
|
statuses: write
|
|
steps:
|
|
- name: Failed
|
|
id: failed
|
|
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
|
|
run: |
|
|
curl -X POST -H "Content-Type: application/json" -H "Authorization: token ${{ github.token }}" \
|
|
-d '{ "state" : "failure" , "context" : "github/docker-build-check" , "description" : "Docker build failed", "target_url" : "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" }' \
|
|
https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }}
|
|
exit 1
|
|
- name: Success
|
|
if: steps.failed.conclusion == 'skipped'
|
|
run: |
|
|
curl -X POST -H "Content-Type: application/json" -H "Authorization: token ${{ github.token }}" \
|
|
-d '{ "state" : "success" , "context" : "github/docker-build-check" , "description" : "Docker build passed", "target_url" : "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" }' \
|
|
https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }}
|