Skip to content

fix(scada_graph_check): fix bugs after introducing temporal non-real … #879

fix(scada_graph_check): fix bugs after introducing temporal non-real …

fix(scada_graph_check): fix bugs after introducing temporal non-real … #879

Workflow file for this run

name: 🐘 PostgreSQL Tests
on:
push:
branches: [main, release/**, feature/**, refactor/**]
tags: [v*]
paths:
- 'dbmodel/**'
- 'giswater_admin/**'
- 'scripts/gw_e2e*.sh'
- 'scripts/gw_bootstrap_network.sh'
- '.github/workflows/test-db.yml'
pull_request:
branches: [main, release/**, feature/**, refactor/**]
paths:
- 'dbmodel/**'
- 'giswater_admin/**'
- 'scripts/gw_e2e*.sh'
- 'scripts/gw_bootstrap_network.sh'
- '.github/workflows/test-db.yml'
workflow_dispatch:
inputs:
lane:
description: "all | pgtap-main | profiles-smoke | update-isolated | pgtap-satellites | pgtap-network"
required: false
default: "all"
pg_version:
description: "PostgreSQL major (all | 16 | 17 | 18)"
required: false
default: "all"
build_image:
description: "Build/push DB image"
required: false
default: "false"
permissions:
contents: read
packages: write
jobs:
pgtap-main:
if: >-
github.event_name != 'workflow_dispatch' ||
inputs.lane == 'all' || inputs.lane == 'pgtap-main'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
project: [ws, ud]
pg_version: [16, 17, 18]
name: pgTAP ${{ matrix.project }} (PG ${{ matrix.pg_version }})
env:
PG_MAJOR: ${{ matrix.pg_version }}
POSTGIS_VERSION: ${{ matrix.pg_version == '18' && '3.6' || '3.5' }}
TEST_GROUPS: all
GW_VERBOSE: "1"
GW_TIMING: "1"
GW_SCHEMA_DUMP: /workspace/dbmodel/gw-schema-pg${{ matrix.pg_version }}-${{ matrix.project }}.dump
steps:
- name: Skip matrix cell (workflow_dispatch filter)
id: filter
run: |
active=true
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
req="${{ github.event.inputs.pg_version }}"
if [[ "${req}" != "all" && "${req}" != "${{ matrix.pg_version }}" ]]; then
active=false
fi
fi
echo "active=${active}" >> "${GITHUB_OUTPUT}"
- name: Checkout repository
if: steps.filter.outputs.active == 'true'
uses: actions/checkout@v6
- name: Build Docker images
if: steps.filter.outputs.active == 'true'
working-directory: dbmodel
run: docker compose -f docker-compose.test.yml build postgres runner
- name: Start Postgres
if: steps.filter.outputs.active == 'true'
working-directory: dbmodel
run: docker compose -f docker-compose.test.yml up -d postgres --wait
- name: Bootstrap, dump, and pgTAP
if: steps.filter.outputs.active == 'true'
working-directory: dbmodel
run: |
chmod +x test/*.sh ../scripts/gw_*.sh ../scripts/gw_bootstrap_network.sh ../scripts/verify_dbmodel_ci_checks.sh 2>/dev/null || chmod +x test/*.sh
docker compose -f docker-compose.test.yml run --rm -T runner \
bash /workspace/dbmodel/test/pgtap_main_inner.sh ${{ matrix.project }}
- name: Upload schema dump artifact
if: steps.filter.outputs.active == 'true' && success()
uses: actions/upload-artifact@v7
with:
name: gw-schema-pg${{ matrix.pg_version }}-${{ matrix.project }}
path: dbmodel/gw-schema-pg${{ matrix.pg_version }}-${{ matrix.project }}.dump
retention-days: 2
- name: Stop Postgres
if: always() && steps.filter.outputs.active == 'true'
working-directory: dbmodel
run: docker compose -f docker-compose.test.yml down
profiles-smoke:
if: >-
github.event_name != 'workflow_dispatch' ||
inputs.lane == 'all' || inputs.lane == 'profiles-smoke'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
pg_version: [16, 17, 18]
name: profiles empty+inventory (PG ${{ matrix.pg_version }})
env:
PG_MAJOR: ${{ matrix.pg_version }}
POSTGIS_VERSION: ${{ matrix.pg_version == '18' && '3.6' || '3.5' }}
GW_VERBOSE: "1"
GW_TIMING: "1"
steps:
- name: Skip matrix cell (workflow_dispatch filter)
id: filter
run: |
active=true
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
req="${{ github.event.inputs.pg_version }}"
if [[ "${req}" != "all" && "${req}" != "${{ matrix.pg_version }}" ]]; then
active=false
fi
fi
echo "active=${active}" >> "${GITHUB_OUTPUT}"
- uses: actions/checkout@v6
if: steps.filter.outputs.active == 'true'
- name: Run profiles smoke
if: steps.filter.outputs.active == 'true'
working-directory: dbmodel
run: |
chmod +x test/*.sh ../scripts/gw_*.sh ../scripts/gw_bootstrap_network.sh ../scripts/verify_dbmodel_ci_checks.sh 2>/dev/null || chmod +x test/*.sh
docker compose -f docker-compose.test.yml build postgres runner
docker compose -f docker-compose.test.yml up -d postgres --wait
docker compose -f docker-compose.test.yml run --rm -T runner \
bash /workspace/dbmodel/test/ci_lifecycle_inner.sh profiles-smoke
docker compose -f docker-compose.test.yml down
update-isolated:
if: >-
github.event_name != 'workflow_dispatch' ||
inputs.lane == 'all' || inputs.lane == 'update-isolated'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
pg_version: [16, 17, 18]
name: update isolated (PG ${{ matrix.pg_version }})
env:
PG_MAJOR: ${{ matrix.pg_version }}
POSTGIS_VERSION: ${{ matrix.pg_version == '18' && '3.6' || '3.5' }}
GW_VERBOSE: "1"
GW_TIMING: "1"
steps:
- name: Skip matrix cell (workflow_dispatch filter)
id: filter
run: |
active=true
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
req="${{ github.event.inputs.pg_version }}"
if [[ "${req}" != "all" && "${req}" != "${{ matrix.pg_version }}" ]]; then
active=false
fi
fi
echo "active=${active}" >> "${GITHUB_OUTPUT}"
- uses: actions/checkout@v6
if: steps.filter.outputs.active == 'true'
- name: Run update isolated
if: steps.filter.outputs.active == 'true'
working-directory: dbmodel
run: |
chmod +x test/*.sh ../scripts/gw_*.sh ../scripts/gw_bootstrap_network.sh ../scripts/verify_dbmodel_ci_checks.sh 2>/dev/null || chmod +x test/*.sh
docker compose -f docker-compose.test.yml build postgres runner
docker compose -f docker-compose.test.yml up -d postgres --wait
docker compose -f docker-compose.test.yml run --rm -T runner \
bash /workspace/dbmodel/test/ci_lifecycle_inner.sh update-isolated
docker compose -f docker-compose.test.yml down
pgtap-satellites:
needs: [pgtap-main, profiles-smoke, update-isolated]
if: >-
github.event_name != 'workflow_dispatch' ||
inputs.lane == 'all' || inputs.lane == 'pgtap-satellites'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
pg_version: [16, 17, 18]
name: pgTAP satellites (PG ${{ matrix.pg_version }})
env:
PG_MAJOR: ${{ matrix.pg_version }}
POSTGIS_VERSION: ${{ matrix.pg_version == '18' && '3.6' || '3.5' }}
TEST_GROUPS: all
GW_VERBOSE: "1"
GW_TIMING: "1"
steps:
- name: Skip matrix cell (workflow_dispatch filter)
id: filter
run: |
active=true
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
req="${{ github.event.inputs.pg_version }}"
if [[ "${req}" != "all" && "${req}" != "${{ matrix.pg_version }}" ]]; then
active=false
fi
fi
echo "active=${active}" >> "${GITHUB_OUTPUT}"
- uses: actions/checkout@v6
if: steps.filter.outputs.active == 'true'
- name: Run pgTAP satellites
if: steps.filter.outputs.active == 'true'
working-directory: dbmodel
run: |
chmod +x test/*.sh ../scripts/gw_*.sh ../scripts/gw_bootstrap_network.sh ../scripts/verify_dbmodel_ci_checks.sh 2>/dev/null || chmod +x test/*.sh
docker compose -f docker-compose.test.yml build postgres runner
docker compose -f docker-compose.test.yml up -d postgres --wait
docker compose -f docker-compose.test.yml run --rm -T runner \
bash /workspace/dbmodel/test/ci_lifecycle_inner.sh pgtap-satellites
docker compose -f docker-compose.test.yml down
pgtap-network:
needs: [pgtap-satellites]
if: >-
github.event_name != 'workflow_dispatch' ||
inputs.lane == 'all' || inputs.lane == 'pgtap-network'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
pg_version: [16, 17, 18]
name: pgTAP network (PG ${{ matrix.pg_version }})
env:
PG_MAJOR: ${{ matrix.pg_version }}
POSTGIS_VERSION: ${{ matrix.pg_version == '18' && '3.6' || '3.5' }}
TEST_GROUPS: all
GW_VERBOSE: "1"
GW_TIMING: "1"
steps:
- name: Skip matrix cell (workflow_dispatch filter)
id: filter
run: |
active=true
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
req="${{ github.event.inputs.pg_version }}"
if [[ "${req}" != "all" && "${req}" != "${{ matrix.pg_version }}" ]]; then
active=false
fi
fi
echo "active=${active}" >> "${GITHUB_OUTPUT}"
- uses: actions/checkout@v6
if: steps.filter.outputs.active == 'true'
- name: Run pgTAP network
if: steps.filter.outputs.active == 'true'
working-directory: dbmodel
run: |
chmod +x test/*.sh ../scripts/gw_*.sh ../scripts/gw_bootstrap_network.sh ../scripts/verify_dbmodel_ci_checks.sh 2>/dev/null || chmod +x test/*.sh
docker compose -f docker-compose.test.yml build postgres runner
docker compose -f docker-compose.test.yml up -d postgres --wait
docker compose -f docker-compose.test.yml run --rm -T runner \
bash /workspace/dbmodel/test/ci_lifecycle_inner.sh pgtap-network
docker compose -f docker-compose.test.yml down
publish-gw-db:
needs: [pgtap-main]
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') || github.event.inputs.build_image == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
project: [ud, ws]
pg_version: [16, 17, 18]
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Download schema dump
uses: actions/download-artifact@v8
with:
name: gw-schema-pg${{ matrix.pg_version }}-${{ matrix.project }}
path: dbmodel
- name: Prepare dump for gw-db image
working-directory: dbmodel
run: cp "gw-schema-pg${{ matrix.pg_version }}-${{ matrix.project }}.dump" "gw_${{ matrix.project }}.dump"
- name: Set image tag
run: |
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
echo "IMAGE_TAG=main" >> $GITHUB_ENV
else
echo "IMAGE_TAG=${GITHUB_REF_NAME//\//-}" >> $GITHUB_ENV
fi
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Resolve PostGIS version
run: |
if [ "${{ matrix.pg_version }}" = "18" ]; then
echo "POSTGIS_VERSION=3.6" >> "$GITHUB_ENV"
else
echo "POSTGIS_VERSION=3.5" >> "$GITHUB_ENV"
fi
- name: Build and push DB image
uses: docker/build-push-action@v6
with:
context: dbmodel
file: dbmodel/docker/gw-db/Dockerfile
push: true
tags: ghcr.io/giswater/gw-db:${{ env.IMAGE_TAG }}-pg${{ matrix.pg_version }}-${{ matrix.project }}
build-args: |
GW_DUMP=gw_${{ matrix.project }}.dump
PG_MAJOR=${{ matrix.pg_version }}
POSTGIS_VERSION=${{ env.POSTGIS_VERSION }}