From bc3dc737871b29ec1a80ace863abf0e1c95454e1 Mon Sep 17 00:00:00 2001 From: Parthiv Date: Sun, 4 Aug 2024 10:54:26 +0530 Subject: [PATCH] Fixes #966: Add docker and checker.yml configurations for running migrations in CI --- .github/workflows/checker.yml | 47 ++++++++++++++++++++++++++++++++--- apps/server/Dockerfile | 6 +++++ 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/.github/workflows/checker.yml b/.github/workflows/checker.yml index f7b4f396e7..58aca002bd 100644 --- a/.github/workflows/checker.yml +++ b/.github/workflows/checker.yml @@ -14,12 +14,51 @@ jobs: ci: name: Continuous Integration runs-on: ubuntu-latest - timeout-minutes: 5 + timeout-minutes: 15 + services: + sqld: + image: ghcr.io/tursodatabase/libsql-server:latest + ports: + - 8080:8080 + + env: + DATABASE_URL: http://127.0.0.1:8080 + DATABASE_AUTH_TOKEN: "any-token" + steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Set up pnpm + uses: pnpm/action-setup@v4 + with: + version: 9.1.4 + + - name: Set up bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + + - name: Install dependencies + run: pnpm install + + - name: Run database migrations + run: pnpm run migrate + working-directory: ./packages/db + + - name: Build Docker image + run: docker build -t your-image-name --build-arg DATABASE_URL=${{ env.DATABASE_URL }} --build-arg DATABASE_AUTH_TOKEN=${{ env.DATABASE_AUTH_TOKEN }} . + + - name: Run Go setup + uses: actions/setup-go@v5 with: go-version: '>=1.22.0' - - name: Run test + + - name: Run Go tests run: go test -timeout 30s -race -count=1 ./... working-directory: apps/checker diff --git a/apps/server/Dockerfile b/apps/server/Dockerfile index 70be82c390..d9b8a3ab2d 100644 --- a/apps/server/Dockerfile +++ b/apps/server/Dockerfile @@ -15,6 +15,12 @@ RUN rm -rf /app/packages/integrations/vercel # Temp solution for bun RUN bun install --ignore-scripts +# Run Database migrations +WORKDIR /app/packages/db +ENV DATABASE_URL=$DATABASE_URL +ENV DATABASE_AUTH_TOKEN=$DATABASE_AUTH_TOKEN +RUN bun run migrate + EXPOSE 3000 WORKDIR /app/apps/server