|
| 1 | +name: Build and Test System |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + build-api: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Checkout repository |
| 15 | + uses: actions/checkout@v3 |
| 16 | + |
| 17 | + - name: Set up Docker Buildx |
| 18 | + uses: docker/setup-buildx-action@v2 |
| 19 | + |
| 20 | + - name: Build API service |
| 21 | + uses: docker/build-push-action@v4 |
| 22 | + with: |
| 23 | + context: ./api |
| 24 | + push: false |
| 25 | + load: true |
| 26 | + tags: lucidata-api:latest |
| 27 | + cache-from: type=gha |
| 28 | + cache-to: type=gha,mode=max |
| 29 | + |
| 30 | + build-llm-engine: |
| 31 | + runs-on: ubuntu-latest |
| 32 | + steps: |
| 33 | + - name: Checkout repository |
| 34 | + uses: actions/checkout@v3 |
| 35 | + |
| 36 | + - name: Set up Docker Buildx |
| 37 | + uses: docker/setup-buildx-action@v2 |
| 38 | + |
| 39 | + - name: Build LLM Engine service |
| 40 | + uses: docker/build-push-action@v4 |
| 41 | + with: |
| 42 | + context: ./llm_engine |
| 43 | + push: false |
| 44 | + load: true |
| 45 | + tags: lucidata-llm-engine:latest |
| 46 | + cache-from: type=gha |
| 47 | + cache-to: type=gha,mode=max |
| 48 | + |
| 49 | + build-query-runner: |
| 50 | + runs-on: ubuntu-latest |
| 51 | + steps: |
| 52 | + - name: Checkout repository |
| 53 | + uses: actions/checkout@v3 |
| 54 | + |
| 55 | + - name: Set up Docker Buildx |
| 56 | + uses: docker/setup-buildx-action@v2 |
| 57 | + |
| 58 | + - name: Build Query Runner service |
| 59 | + uses: docker/build-push-action@v4 |
| 60 | + with: |
| 61 | + context: ./query_runner |
| 62 | + push: false |
| 63 | + load: true |
| 64 | + tags: lucidata-query-runner:latest |
| 65 | + cache-from: type=gha |
| 66 | + cache-to: type=gha,mode=max |
| 67 | + |
| 68 | + system-test: |
| 69 | + needs: [build-api, build-llm-engine, build-query-runner] |
| 70 | + runs-on: ubuntu-latest |
| 71 | + steps: |
| 72 | + - name: Checkout repository |
| 73 | + uses: actions/checkout@v3 |
| 74 | + |
| 75 | + # Save and load images from the build jobs |
| 76 | + - name: Set up Docker Buildx |
| 77 | + uses: docker/setup-buildx-action@v2 |
| 78 | + |
| 79 | + # Download the images built in the previous jobs |
| 80 | + - name: Download API image |
| 81 | + uses: docker/build-push-action@v4 |
| 82 | + with: |
| 83 | + context: ./api |
| 84 | + load: true |
| 85 | + tags: lucidata-api:latest |
| 86 | + cache-from: type=gha |
| 87 | + outputs: type=docker,dest=/tmp/api-image.tar |
| 88 | + |
| 89 | + - name: Download LLM Engine image |
| 90 | + uses: docker/build-push-action@v4 |
| 91 | + with: |
| 92 | + context: ./llm_engine |
| 93 | + load: true |
| 94 | + tags: lucidata-llm-engine:latest |
| 95 | + cache-from: type=gha |
| 96 | + outputs: type=docker,dest=/tmp/llm-engine-image.tar |
| 97 | + |
| 98 | + - name: Download Query Runner image |
| 99 | + uses: docker/build-push-action@v4 |
| 100 | + with: |
| 101 | + context: ./query_runner |
| 102 | + load: true |
| 103 | + tags: lucidata-query-runner:latest |
| 104 | + cache-from: type=gha |
| 105 | + outputs: type=docker,dest=/tmp/query-runner-image.tar |
| 106 | + |
| 107 | + - name: Load saved images |
| 108 | + run: | |
| 109 | + docker load < /tmp/api-image.tar |
| 110 | + docker load < /tmp/llm-engine-image.tar |
| 111 | + docker load < /tmp/query-runner-image.tar |
| 112 | + docker images |
| 113 | +
|
| 114 | + - name: Start services with docker compose |
| 115 | + run: | |
| 116 | + # Use the pre-built images instead of rebuilding |
| 117 | + docker compose up -d |
| 118 | + env: |
| 119 | + COMPOSE_DOCKER_CLI_BUILD: 0 |
| 120 | + DOCKER_BUILDKIT: 1 |
| 121 | + |
| 122 | + - name: Wait for services to be healthy |
| 123 | + run: | |
| 124 | + # Give services some time to start up |
| 125 | + echo "Waiting for services to start..." |
| 126 | + sleep 60 |
| 127 | + |
| 128 | + # Check if API is healthy |
| 129 | + if curl -s http://localhost:8000/api/health > /dev/null; then |
| 130 | + echo "API is healthy" |
| 131 | + else |
| 132 | + echo "API health check failed" |
| 133 | + docker compose logs |
| 134 | + exit 1 |
| 135 | + fi |
| 136 | + |
| 137 | + echo "All services are running properly!" |
| 138 | +
|
| 139 | + - name: Stop services |
| 140 | + if: always() # Ensures this step runs even if previous steps fail |
| 141 | + run: docker compose down |
0 commit comments