Skip to content

Commit

Permalink
test empty script
Browse files Browse the repository at this point in the history
  • Loading branch information
mikealfare committed Jan 27, 2024
1 parent cbbda05 commit 0289ea6
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
6 changes: 5 additions & 1 deletion .github/actions/setup-postgres-linux/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ runs:
run: sudo systemctl start postgresql.service
shell: bash

# - name: Configure the database
# run: sudo -u postgres psql -f ./scripts/setup_test_database.sql
# shell: bash

- name: Configure the database
run: sudo -u postgres psql -f ./scripts/setup_test_database.sql
run: sudo -u postgres bash ${{ github.action_path }}/setup_db.sh
shell: bash
37 changes: 37 additions & 0 deletions .github/actions/setup-postgres-linux/setup_db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
set -x
env | grep '^PG'

# If you want to run this script for your own postgresql (run with
# docker-compose) it will look like this:
# PGHOST=127.0.0.1 PGUSER=root PGPASSWORD=password PGDATABASE=postgres \
PGUSER="${PGUSER:-postgres}"
export PGUSER
PGPORT="${PGPORT:-5432}"
export PGPORT
PGHOST="${PGHOST:-localhost}"

for i in {1..10}; do
if pg_isready -h "${PGHOST}" -p "${PGPORT}" -U "${PGUSER}" ; then
break
fi
echo "Waiting for postgres to be ready..."
sleep 2;
done;

createdb dbt
psql -c "CREATE ROLE root WITH PASSWORD 'password';"
psql -c "ALTER ROLE root WITH LOGIN;"
psql -c "GRANT CREATE, CONNECT ON DATABASE dbt TO root WITH GRANT OPTION;"

psql -c "CREATE ROLE noaccess WITH PASSWORD 'password' NOSUPERUSER;"
psql -c "ALTER ROLE noaccess WITH LOGIN;"
psql -c "GRANT CONNECT ON DATABASE dbt TO noaccess;"
psql -c "CREATE ROLE dbt_test_user_1;"
psql -c "CREATE ROLE dbt_test_user_2;"
psql -c "CREATE ROLE dbt_test_user_3;"

psql -c 'CREATE DATABASE "dbtMixedCase";'
psql -c 'GRANT CREATE, CONNECT ON DATABASE "dbtMixedCase" TO root WITH GRANT OPTION;'

set +x
7 changes: 2 additions & 5 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,8 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Run empty script
run: bash ./scripts/my-script.sh

# - name: Setup postgres
# uses: ./.github/actions/setup-postgres-linux
- name: Setup postgres
uses: ./.github/actions/setup-postgres-linux

- name: Run integration tests
run: hatch run integration-tests:all
Expand Down

0 comments on commit 0289ea6

Please sign in to comment.