controller.xql -> controller-develop.xql; controller-legacy.xql -> co… #23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [ main, develop, dev, dev-* ] | |
| pull_request: | |
| branches: [ main, develop, dev ] | |
| workflow_dispatch: | |
| jobs: | |
| build-test: | |
| name: Build and Test Package | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build package (without data) | |
| run: npm run dist | |
| - name: Check package was created | |
| run: | | |
| if [ ! -f dist/api-*.xar ]; then | |
| echo "Error: Package file not created" | |
| exit 1 | |
| fi | |
| ls -lh dist/api-*.xar | |
| echo "Package size: $(du -h dist/api-*.xar | cut -f1)" | |
| - name: Upload package artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: api-package | |
| path: dist/api-*.xar | |
| retention-days: 7 | |
| docker-build-test: | |
| name: Docker Build and Integration Test | |
| runs-on: ubuntu-latest | |
| needs: build-test | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| load: true | |
| tags: bw-api:test | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Check image size | |
| run: | | |
| docker images bw-api:test | |
| SIZE=$(docker images bw-api:test --format "{{.Size}}") | |
| echo "Docker image size: $SIZE" | |
| - name: Start container | |
| run: | | |
| docker run -d --name bw-api-test \ | |
| -p 8080:8080 \ | |
| -e EXIST_PASSWORD=testpass123 \ | |
| -e EXIST_ENV=development \ | |
| -e EXIST_CONTEXT_PATH=/exist \ | |
| bw-api:test | |
| echo "Container started, waiting for eXist-DB to initialize..." | |
| - name: Wait for eXist-DB startup | |
| run: | | |
| echo "Waiting 60 seconds for full startup (eXist + package deployment)..." | |
| sleep 120 | |
| - name: Check container is running | |
| run: | | |
| if ! docker ps | grep -q bw-api-test; then | |
| echo "Error: Container not running" | |
| docker logs bw-api-test | |
| exit 1 | |
| fi | |
| echo "Container is running" | |
| - name: Test eXist-DB is accessible | |
| run: | | |
| echo "Testing eXist-DB main page..." | |
| curl -f http://localhost:8080/exist/ || { | |
| echo "Error: eXist-DB not accessible" | |
| docker logs bw-api-test | |
| exit 1 | |
| } | |
| echo "✓ eXist-DB is accessible" | |
| - name: Test API app is deployed | |
| run: | | |
| echo "Testing API application..." | |
| curl -f http://localhost:8080/exist/apps/api/ || { | |
| echo "Error: API app not deployed" | |
| docker logs bw-api-test | |
| exit 1 | |
| } | |
| echo "✓ API app is deployed" | |
| - name: Test Controller-based IIIF endpoints | |
| run: | | |
| echo "Testing Controller-based IIIF endpoint..." | |
| RESPONSE=$(curl -s http://localhost:8080/exist/apps/api/iiif/documents.json) | |
| # Check if we get valid JSON with array structure | |
| if ! echo "$RESPONSE" | jq -e 'type == "array"' > /dev/null 2>&1; then | |
| echo "Error: Invalid response from IIIF endpoint" | |
| echo "Response: $RESPONSE" | |
| exit 1 | |
| fi | |
| echo "✓ Controller-based endpoints are working" | |
| echo "Sample response:" | |
| echo "$RESPONSE" | jq -r '.[0].id // empty' | head -3 | |
| - name: Test OpenAPI spec availability | |
| run: | | |
| echo "Testing OpenAPI spec endpoint..." | |
| SPEC=$(curl -s http://localhost:8080/exist/apps/api/openapi.json) | |
| # Validate it's valid JSON | |
| if ! echo "$SPEC" | jq empty 2>/dev/null; then | |
| echo "Error: OpenAPI spec is not valid JSON" | |
| echo "Response: $SPEC" | |
| exit 1 | |
| fi | |
| echo "✓ OpenAPI spec is available and valid JSON" | |
| echo " Sample keys:" | |
| echo "$SPEC" | jq -r 'keys | .[0:5]' | |
| - name: Test Swagger UI is accessible | |
| run: | | |
| echo "Testing Swagger UI..." | |
| curl -f http://localhost:8080/exist/apps/api/docs.html || { | |
| echo "Error: Swagger UI not accessible" | |
| exit 1 | |
| } | |
| echo "✓ Swagger UI is accessible" | |
| - name: Check deployment in logs | |
| if: always() | |
| run: | | |
| echo "Checking for deployment messages..." | |
| docker logs bw-api-test 2>&1 | grep -i "post-install\|deployed" || { | |
| echo "Warning: No deployment messages found in logs" | |
| echo "Full logs:" | |
| docker logs bw-api-test 2>&1 | tail -50 | |
| } | |
| - name: Show container logs on failure | |
| if: failure() | |
| run: | | |
| echo "=== Container Logs ===" | |
| docker logs bw-api-test | |
| echo "=== Container Status ===" | |
| docker ps -a | grep bw-api-test | |
| - name: Stop container | |
| if: always() | |
| run: docker rm -f bw-api-test || true | |
| docker-data-test: | |
| name: Docker with Data Test | |
| runs-on: ubuntu-latest | |
| needs: docker-build-test | |
| if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Docker image with data | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| load: true | |
| tags: bw-api:test-data | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Check image size with data | |
| run: | | |
| docker images bw-api:test-data | |
| SIZE=$(docker images bw-api:test-data --format "{{.Size}}") | |
| echo "Docker image size with data: $SIZE" | |
| - name: Start container with data | |
| run: | | |
| docker run -d --name bw-api-data-test \ | |
| -p 8080:8080 \ | |
| -e EXIST_PASSWORD=testpass123 \ | |
| bw-api:test-data | |
| echo "Container started, waiting for deployment with data..." | |
| sleep 120 # Data deployment takes longer | |
| - name: Test data is available | |
| run: | | |
| echo "Testing if documents are available..." | |
| RESPONSE=$(curl -s http://localhost:8080/exist/apps/api/iiif/documents.json) | |
| # Response should be a JSON array | |
| DOC_COUNT=$(echo "$RESPONSE" | jq 'length') | |
| if [ "$DOC_COUNT" -eq 0 ]; then | |
| echo "Error: No documents found in API" | |
| echo "Response: $RESPONSE" | |
| exit 1 | |
| fi | |
| echo "✓ Data is available" | |
| echo " Documents found: $DOC_COUNT" | |
| echo " Sample document:" | |
| echo "$RESPONSE" | jq '.[0]' | |
| - name: Stop container | |
| if: always() | |
| run: docker rm -f bw-api-data-test || true | |
| summary: | |
| name: Test Summary | |
| runs-on: ubuntu-latest | |
| needs: [build-test, docker-build-test, docker-data-test] | |
| if: always() | |
| steps: | |
| - name: Check job results | |
| run: | | |
| echo "Build Test: ${{ needs.build-test.result }}" | |
| echo "Docker Build Test: ${{ needs.docker-build-test.result }}" | |
| echo "Docker Data Test: ${{ needs.docker-data-test.result }}" | |
| if [ "${{ needs.build-test.result }}" != "success" ] || \ | |
| [ "${{ needs.docker-build-test.result }}" != "success" ]; then | |
| echo "❌ Required tests failed" | |
| exit 1 | |
| fi | |
| echo "✅ All required tests passed" |