From f0929fd633e1a33ec205ef7f1af6f695f47f0c2f Mon Sep 17 00:00:00 2001 From: xbgmsharp Date: Wed, 12 Jul 2023 00:15:22 +0200 Subject: [PATCH] Update and improve github workflows, add db and grafan tests --- .github/workflows/commit-test.yml | 73 ------------------- .../{postgsail-db-tests.yml => db-test.yml} | 4 +- .github/workflows/grafana-test.yml | 67 +++++++++++++++++ 3 files changed, 69 insertions(+), 75 deletions(-) delete mode 100644 .github/workflows/commit-test.yml rename .github/workflows/{postgsail-db-tests.yml => db-test.yml} (94%) create mode 100644 .github/workflows/grafana-test.yml diff --git a/.github/workflows/commit-test.yml b/.github/workflows/commit-test.yml deleted file mode 100644 index 28a8c67..0000000 --- a/.github/workflows/commit-test.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: Test initdb commit && PR - -on: - pull_request: - paths: - - 'initdb/**' - branches: - - 'main' - push: - branches: - - 'main' - workflow_dispatch: - -jobs: - ci-test: - runs-on: ubuntu-latest - outputs: - output1: ${{ steps.filter.outputs.workflows }} - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - # https://github.com/docker/setup-buildx-action - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - # https://github.com/marketplace/actions/build-and-push-docker-images - - - name: Build and push - uses: docker/build-push-action@v3 - with: - context: . - platforms: linux/amd64,linux/arm64 - push: false - tags: xbgmsharp/timescaledb-postgis-gh:latest - - - name: Run smoke test - run: | - set -eu - export PGHOST=localhost - export PGUSER=postgres - export PGPASSWORD=test1234 - docker container stop smoketest-image || true - docker container rm smoketest-image || true - docker run -d -p 5432:5432 -e POSTGRES_PASSWORD=${PGPASSWORD} --name smoketest-image xbgmsharp/timescaledb-postgis-gh - for _ in {1..120} - do - if [ -z "$(docker container ls -q --filter name=smoketest-image)" ] - then - echo "Smoketest container is not running" - exit 1 - fi - if psql -c "select 1" - then - echo "Test PostgreSQL" - psql -c "SELECT version();" - bash tests/extensions_test/test*.sh - break - fi - 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 logs smoketest-image \ No newline at end of file diff --git a/.github/workflows/postgsail-db-tests.yml b/.github/workflows/db-test.yml similarity index 94% rename from .github/workflows/postgsail-db-tests.yml rename to .github/workflows/db-test.yml index f19e6f6..5e70e5a 100644 --- a/.github/workflows/postgsail-db-tests.yml +++ b/.github/workflows/db-test.yml @@ -1,4 +1,4 @@ -name: PostgSail DB Tests docker & schema +name: PostgSail DB Tests docker & sql schema on: push: @@ -26,7 +26,7 @@ jobs: - name: Set env run: cp .env.example .env - - name: Run PostgSail + - name: Run PostgSail Database & API tests # Environment variables env: # The hostname used to communicate with the PostgreSQL service container diff --git a/.github/workflows/grafana-test.yml b/.github/workflows/grafana-test.yml new file mode 100644 index 0000000..045b5d1 --- /dev/null +++ b/.github/workflows/grafana-test.yml @@ -0,0 +1,67 @@ +name: Test grafana commit && PR + +on: + pull_request: + paths: + - 'grafana/**' + branches: + - 'main' + push: + branches: + - 'main' + paths: + - 'initgrafanadb/**' + workflow_dispatch: + +jobs: + ci-test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + # https://github.com/docker/setup-buildx-action + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + # https://github.com/marketplace/actions/build-and-push-docker-images + - + name: Build and push + uses: docker/build-push-action@v3 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: false + tags: xbgmsharp/timescaledb-postgis:latest + + - name: Set env + run: cp .env.example .env + + - name: Run PostgSail Grafana test + # Environment variables + env: + # The hostname used to communicate with the PostgreSQL service container + PGHOST: localhost + PGPORT: 5432 + PGDATABASE: signalk + PGUSER: username + PGPASSWORD: password + run: | + set -eu + source .env + docker-compose stop || true + docker-compose rm || true + docker-compose up -d db && sleep 15 + docker-compose ps -a + echo ${PGSAIL_API_URL} + curl ${PGSAIL_API_URL} + echo "Test PostgSail Grafana Unit Test" + docker-compose -d up app && sleep 5 + docker-compose ps -a + curl http://localhost:3001/ + - name: Show the logs + if: always() + run: | + docker-compose logs \ No newline at end of file