In case we fail to decrypt auth info is omitted #535
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test SQL Queries | |
on: | |
workflow_dispatch: | |
pull_request: | |
env: | |
PGPASSWORD: postgres | |
DATABASE_NAME: testdb | |
jobs: | |
test: | |
name: Test SQL Queries | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:latest | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd="pg_isready -U postgres" | |
--health-interval=10s | |
--health-timeout=5s | |
--health-retries=5 | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: ${{ env.PGPASSWORD }} | |
POSTGRES_DB: ${{ env.DATABASE_NAME }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Wait for PostgreSQL to be ready | |
run: | | |
until pg_isready -h localhost -p 5432; do | |
sleep 1 | |
done | |
- name: Run create-tables.sql | |
run: psql -v ON_ERROR_STOP=1 -h localhost -U postgres -d ${{ env.DATABASE_NAME }} -f create-tables.sql | |
- name: Ensure tables were created | |
run: | | |
COUNT=$(psql -v ON_ERROR_STOP=1 -h localhost -U postgres -d ${{ env.DATABASE_NAME }} -t -A -c "SELECT count(*) FROM information_schema.tables WHERE table_schema = 'public';") | |
if [ "$COUNT" -eq 0 ]; then | |
echo "No tables found. Exiting with error." | |
exit 1 | |
fi | |
- name: Run drop-tables.sql | |
run: psql -v ON_ERROR_STOP=1 -h localhost -U postgres -d ${{ env.DATABASE_NAME }} -f drop-tables.sql | |
- name: Ensure all tables were dropped | |
run: | | |
COUNT=$(psql -v ON_ERROR_STOP=1 -h localhost -U postgres -d ${{ env.DATABASE_NAME }} -t -A -c "SELECT count(*) FROM information_schema.tables WHERE table_schema = 'public';") | |
if [ "$COUNT" -gt 0 ]; then | |
echo "Tables found: $count. Exiting with error." | |
exit 1 | |
fi |