From 50f9418a30215647a948b11691589a0bb2db3a7a Mon Sep 17 00:00:00 2001 From: Pavlo Paliychuk Date: Tue, 1 Oct 2024 10:25:12 -0400 Subject: [PATCH] chore: Add build and start CI workflow (#164) * chore: Add build and start CI workflow * chore: Fix docker-compose command * chore: Fix healthcheck port * fix: test docker compose setup * chore: Simulate container start error * chore: Always log service logs * revert dev version changes, and simulate error in the healthcheck * chore: Log docker logs only on failure, revert simulated error * chore: Make release workflows depend on build and start workflow --- .github/workflows/build-and-start-svc.yml | 47 +++++++++++++++++++++ .github/workflows/release-graphiti-core.yml | 1 + .github/workflows/release-service-image.yml | 1 + docker-compose.test.yml | 41 ++++++++++++++++++ server/graph_service/app.py | 0 5 files changed, 90 insertions(+) create mode 100644 .github/workflows/build-and-start-svc.yml create mode 100644 docker-compose.test.yml delete mode 100644 server/graph_service/app.py diff --git a/.github/workflows/build-and-start-svc.yml b/.github/workflows/build-and-start-svc.yml new file mode 100644 index 0000000..4b0db4c --- /dev/null +++ b/.github/workflows/build-and-start-svc.yml @@ -0,0 +1,47 @@ +name: Build and Start Graphiti Service + +on: + pull_request: + branches: [ "main" ] + push: + tags: [ 'v*.*.*' ] +jobs: + build-and-start: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + NEO4J_USER: neo4j + NEO4J_PASSWORD: testpassword + NEO4J_PORT: 7687 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Depot CLI + uses: depot/setup-action@v1 + + - name: Build Graphiti service image with Depot + uses: depot/build-push-action@v1 + with: + context: . + push: false + load: true + tags: graphiti-service:${{ github.sha }} + + - name: Run Docker Compose + run: docker compose -f docker-compose.test.yml up -d --wait + + - name: Check service logs + if: failure() + run: | + echo "Graphiti service logs:" + docker compose -f docker-compose.test.yml logs graph + echo "Neo4j logs:" + docker compose -f docker-compose.test.yml logs neo4j + + - name: Cleanup + if: always() + run: docker compose -f docker-compose.test.yml down \ No newline at end of file diff --git a/.github/workflows/release-graphiti-core.yml b/.github/workflows/release-graphiti-core.yml index 278de4d..5629954 100644 --- a/.github/workflows/release-graphiti-core.yml +++ b/.github/workflows/release-graphiti-core.yml @@ -9,6 +9,7 @@ env: jobs: release: + needs: build-and-start-svc runs-on: ubuntu-latest permissions: id-token: write diff --git a/.github/workflows/release-service-image.yml b/.github/workflows/release-service-image.yml index 2814ca8..845f542 100644 --- a/.github/workflows/release-service-image.yml +++ b/.github/workflows/release-service-image.yml @@ -11,6 +11,7 @@ env: jobs: docker-image: + needs: build-and-start-svc environment: name: release runs-on: ubuntu-latest diff --git a/docker-compose.test.yml b/docker-compose.test.yml new file mode 100644 index 0000000..34f38e2 --- /dev/null +++ b/docker-compose.test.yml @@ -0,0 +1,41 @@ +version: '3.8' + +services: + graph: + image: graphiti-service:${GITHUB_SHA} + ports: + - "8000:8000" + healthcheck: + test: + [ + "CMD", + "python", + "-c", + "import urllib.request; urllib.request.urlopen('http://localhost:8000/healthcheck')", + ] + interval: 10s + timeout: 5s + retries: 3 + depends_on: + neo4j: + condition: service_healthy + environment: + - OPENAI_API_KEY=${OPENAI_API_KEY} + - NEO4J_URI=bolt://neo4j:${NEO4J_PORT} + - NEO4J_USER=${NEO4J_USER} + - NEO4J_PASSWORD=${NEO4J_PASSWORD} + - PORT=8000 + + neo4j: + image: neo4j:5.22.0 + ports: + - "7474:7474" + - "${NEO4J_PORT}:${NEO4J_PORT}" + healthcheck: + test: wget "http://localhost:${NEO4J_PORT}" || exit 1 + interval: 1s + timeout: 10s + retries: 20 + start_period: 3s + environment: + - NEO4J_AUTH=${NEO4J_USER}/${NEO4J_PASSWORD} \ No newline at end of file diff --git a/server/graph_service/app.py b/server/graph_service/app.py deleted file mode 100644 index e69de29..0000000