Compare commits

..

6 Commits

Author SHA1 Message Date
Quigley Malcolm
2e876d2c70 Update setup_db.sh to use CONNECTION_URI 2024-09-10 15:37:37 -05:00
Michelle Ark
5f357187ca pass CONNECTION_STR to downstream postgres steps 2024-09-10 15:47:44 -04:00
Michelle Ark
afd1bf2771 pass CONNECTION_STR to downstream postgres steps 2024-09-10 15:47:40 -04:00
Michelle Ark
715386ad3a windows PG_LIB_DIR; macos do not install postgres@14 2024-09-10 15:38:52 -04:00
Michelle Ark
9554d1c926 use default port/username/password 2024-09-10 15:30:05 -04:00
Michelle Ark
d6ad6a5477 use ikalnytskyi/action-setup-postgres@v6 2024-09-10 15:25:58 -04:00
5 changed files with 21 additions and 47 deletions

View File

@@ -5,15 +5,6 @@ runs:
steps:
- shell: bash
run: |
sudo apt-get --purge remove postgresql postgresql-*
sudo apt update -y
sudo apt install gnupg2 wget vim -y
sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg
sudo apt update -y
sudo apt install postgresql-16
sudo apt-get -y install postgresql postgresql-contrib
sudo systemctl start postgresql
sudo systemctl enable postgresql
sudo systemctl start postgresql.service
pg_isready
sudo -u postgres bash ${{ github.action_path }}/setup_db.sh

View File

@@ -5,8 +5,6 @@ runs:
steps:
- shell: bash
run: |
brew install postgresql@16
brew services start postgresql@16
echo "Check PostgreSQL service is running"
i=10
COMMAND='pg_isready'

View File

@@ -2,40 +2,11 @@ name: "Set up postgres (windows)"
description: "Set up postgres service on windows vm for dbt integration tests"
runs:
using: "composite"
env:
PQ_LIB_DIR: 'C:\Program Files\PostgreSQL\16\lib'
steps:
- shell: pwsh
run: |
# Download postgres16
$url = "https://get.enterprisedb.com/postgresql/postgresql-16.1-1-windows-x64.exe"
$checkAccess = [System.Net.WebRequest]::Create($url)
$response = $checkAccess.GetResponse()
$installerUrl = $response.ResponseUri.OriginalString
# Invoke Install-Binary function
$installerArgs = @("--install_runtimes 0", "--superpassword root", "--enable_acledit 1", "--unattendedmodeui none", "--mode unattended")
Install-Binary `
-Url $url `
-InstallArgs $installerArgs `
-ExpectedSignature (Get-ToolsetContent).postgresql.signature
# Get Path to pg_ctl.exe
$pgPath = (Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName
# Parse output of command above to obtain pure path
$pgBin = Split-Path -Path $pgPath.split('"')[1]
$pgRoot = Split-Path -Path $pgPath.split('"')[5]
$pgData = Join-Path $pgRoot "data"
# Validate PostgreSQL installation
$pgReadyPath = Join-Path $pgBin "pg_isready.exe"
$pgReady = Start-Process -FilePath $pgReadyPath -Wait -PassThru
$exitCode = $pgReady.ExitCode
if ($exitCode -ne 0) {
Write-Host -Object "PostgreSQL is not ready. Exitcode: $exitCode"
exit $exitCode
}
$pgService = Get-Service -Name postgresql*
Set-Service -InputObject $pgService -Status running -StartupType automatic
Start-Process -FilePath "$env:PGBIN\pg_isready" -Wait -PassThru

View File

@@ -186,17 +186,29 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Install postgres 16
uses: ikalnytskyi/action-setup-postgres@v6
with:
postgres-version: "16"
id: postgres
- name: Set up postgres (linux)
if: runner.os == 'Linux'
uses: ./.github/actions/setup-postgres-linux
env:
CONNECTION_STR: ${{ steps.postgres.outputs.connection-uri }}
- name: Set up postgres (macos)
if: runner.os == 'macOS'
uses: ./.github/actions/setup-postgres-macos
env:
CONNECTION_STR: ${{ steps.postgres.outputs.connection-uri }}
- name: Set up postgres (windows)
if: runner.os == 'Windows'
uses: ./.github/actions/setup-postgres-windows
env:
CONNECTION_STR: ${{ steps.postgres.outputs.connection-uri }}
- name: Install python tools
run: |
@@ -213,6 +225,7 @@ jobs:
command: tox -- --ddtrace
env:
PYTEST_ADDOPTS: ${{ format('--splits {0} --group {1}', env.PYTHON_INTEGRATION_TEST_WORKERS, matrix.split-group) }}
CONNECTION_STR: ${{ steps.postgres.outputs.connection-uri }}
- name: Get current date
if: always()

View File

@@ -5,6 +5,8 @@ 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 \
PG_CONNECTION_URI="${CONNECTION_URI}"
export PG_CONNECTION_URI
PGUSER="${PGUSER:-postgres}"
export PGUSER
PGPORT="${PGPORT:-5432}"
@@ -15,11 +17,11 @@ function connect_circle() {
# try to handle circleci/docker oddness
let rc=1
while [[ $rc -eq 1 ]]; do
nc -z ${PGHOST} ${PGPORT}
nc -z ${PG_CONNECTION_URI}
let rc=$?
done
if [[ $rc -ne 0 ]]; then
echo "Fatal: Could not connect to $PGHOST"
echo "Fatal: Could not connect to $PG_CONNECTION_URI"
exit 1
fi
}
@@ -30,7 +32,7 @@ if [[ -n $CIRCLECI ]]; then
fi
for i in {1..10}; do
if pg_isready -h "${PGHOST}" -p "${PGPORT}" -U "${PGUSER}" ; then
if pg_isready --d "${PG_CONNECTION_URI}"; then
break
fi
@@ -39,7 +41,6 @@ for i in {1..10}; do
done;
createdb dbt
psql -c "SELECT version();"
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;"