File: docker-test.yml

package info (click to toggle)
xandikos 0.3.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,552 kB
  • sloc: python: 17,496; xml: 583; sh: 343; makefile: 64
file content (70 lines) | stat: -rw-r--r-- 1,805 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---
name: Docker Build Test

on:
  pull_request:

jobs:
  docker-build-test:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v6

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Build Docker image
        uses: docker/build-push-action@v6
        with:
          context: .
          file: ./Containerfile
          push: false
          load: true
          tags: xandikos:test
          cache-from: type=gha
          cache-to: type=gha,mode=max

      - name: Run Docker container
        run: |
          docker run -d \
            --name xandikos-test \
            -p 8000:8000 \
            -p 8001:8001 \
            -v xandikos-test-data:/data \
            -e AUTOCREATE=true \
            -e DEFAULTS=true \
            xandikos:test

      - name: Wait for container to be healthy
        run: |
          timeout 30 sh -c 'until docker inspect --format="{{.State.Health.Status}}" xandikos-test 2>/dev/null | grep -q healthy; do sleep 1; done' || {
            echo "Container failed to become healthy"
            docker logs xandikos-test
            exit 1
          }

      - name: Test health endpoint
        run: |
          curl -f http://localhost:8001/health || {
            echo "Health check failed"
            docker logs xandikos-test
            exit 1
          }

      - name: Test main server endpoint
        run: |
          curl -f http://localhost:8000/ || {
            echo "Main server check failed"
            docker logs xandikos-test
            exit 1
          }

      - name: Show container logs
        if: always()
        run: docker logs xandikos-test

      - name: Stop container
        if: always()
        run: docker stop xandikos-test || true