Add github actions test

This commit is contained in:
xbgmsharp
2023-07-10 17:03:03 +02:00
parent cca75d252a
commit e06db937e5

56
.github/workflows/test.yml vendored Normal file
View File

@@ -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