diff --git a/.github/workflows/dev-setup.yml b/.github/workflows/dev-setup.yml new file mode 100644 index 000000000000..49aa643443ed --- /dev/null +++ b/.github/workflows/dev-setup.yml @@ -0,0 +1,26 @@ +# Testing development setup in https://warehouse.readthedocs.io/development/getting-started.html + +name: Dev Setup + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: make build + - run: | + # `make serve` daemonized + docker-compose up -d + - run: docker-compose ps + - run: ./bin/wait-for-db.sh + - run: make initdb + - run: make tests diff --git a/bin/wait-for-db.sh b/bin/wait-for-db.sh new file mode 100755 index 000000000000..b8a10e6dd035 --- /dev/null +++ b/bin/wait-for-db.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# healthy +# unhealthy +# starting + +CONTAINER=warehouse_db_1 +check() { + docker inspect --format "{{.State.Health.Status }}" $CONTAINER +} + +while [[ "$STATUS" != "healthy" ]] +do + STATUS=$(check) + echo "$STATUS ${SECONDS}" + (( SECONDS > 60 )) && exit 1 + sleep 3 +done diff --git a/docker-compose.yml b/docker-compose.yml index ed532f801f71..410f708bbdad 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,6 +29,11 @@ services: ports: # 5432 may already in use by another PostgreSQL on host - "5433:5432" + healthcheck: + test: ["CMD-SHELL", "pg_isready"] + interval: 5s + timeout: 5s + retries: 10 redis: image: redis:4.0