diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..d7b892a --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,56 @@ +name: Test PostgSail docker & schema + +on: + push: + branches: + - 'main' + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + smoketest: + name: smoketest + runs-on: ubuntu-latest + steps: + - name: Check out the source + uses: actions/checkout@v3 + + - name: Pull Docker image + run: docker pull xbgmsharp/timescaledb-postgis + + - name: Set env + run: cp .env.example .env + + - name: Run PostgSail + # Environment variables + env: + # The hostname used to communicate with the PostgreSQL service container + POSTGRES_HOST: localhost + POSTGRES_PORT: 5432 + POSTGRES_USER: username + POSTGRES_PASSWORD: password + run: | + set -eu + docker-compose container stop || true + docker-compose container rm || true + docker-compose up -d db && sleep 15 && docker-compose up -d api + for _ in {1..120} + do + if [ -z "$(docker container ls -q --filter name=api)" ] + then + echo "REST API container is not running" + exit 1 + fi + curl ${PGSAIL_API_URL} + sleep 1 + done + if ! psql -c "select 1" + then + echo "Cannot connect to PostgreSQL" + exit 1 + fi + + - name: Show the logs + if: always() + run: | + docker-compose logs \ No newline at end of file