Add CI sanity check

+ compose healthcheck
This commit is contained in:
Roy Crihfield 2024-07-08 17:49:37 +08:00
parent 60e83a1e2c
commit 5661187a32
2 changed files with 24 additions and 16 deletions

View File

@ -1,20 +1,22 @@
name: Docker Build name: Basic test
on: [pull_request] on: [pull_request]
jobs: jobs:
build: basic-test:
name: Run docker build name: Build and sanity check
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v4
- name: Run docker build - name: Build Docker images
run: docker compose build run: docker compose build
test: - name: Run Docker containers
# Add a dummy job to avoid failing GitHub CI checks. run: docker compose up -d
# Other checks to be added later. - name: Check migration version
name: Dummy job timeout-minutes: 1
runs-on: ubuntu-latest run: |
steps: while
- name: Run dummy job version=$(docker compose run --rm migrations version 2>&1 | tail -1 | awk '{print $(NF)}')
run: echo "Empty dummy job" [[ $version != 21 ]]; do
echo "Incorrect version: $version"
echo "Retrying..."
done

View File

@ -2,13 +2,14 @@ services:
migrations: migrations:
restart: on-failure restart: on-failure
depends_on: depends_on:
- ipld-eth-db ipld-eth-db:
condition: service_healthy
# Use local build # Use local build
build: build:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile
# Use an existing image # Use an existing image
image: cerc/ipld-eth-db image: cerc/ipld-eth-db:local
environment: environment:
DATABASE_USER: "vdbm" DATABASE_USER: "vdbm"
DATABASE_NAME: "cerc_testing" DATABASE_NAME: "cerc_testing"
@ -26,3 +27,8 @@ services:
POSTGRES_PASSWORD: "password" POSTGRES_PASSWORD: "password"
ports: ports:
- "127.0.0.1:8077:5432" - "127.0.0.1:8077:5432"
healthcheck:
test: ["CMD", "pg_isready", "-U", "vdbm"]
interval: 2s
timeout: 1s
retries: 3