Skip to content

Commit

Permalink
Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
ikalnytskyi committed Aug 11, 2024
1 parent 6bb2488 commit 686f201
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 65 deletions.
96 changes: 48 additions & 48 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:
branches: [ master ]
schedule:
- cron: "0 8 * * *"
- cron: "@weekly"

defaults:
run:
Expand All @@ -18,13 +18,13 @@ jobs:
strategy:
matrix:
os:
- ubuntu-20.04
- ubuntu-22.04
- ubuntu-24.04
- macos-12
- macos-13
- macos-14 # M1 CPU
- windows-2019
# - ubuntu-20.04
# - ubuntu-22.04
# - ubuntu-24.04
# - macos-12
# - macos-13
# - macos-14
# - windows-2019
- windows-2022
steps:
- uses: actions/checkout@v4
Expand All @@ -49,43 +49,43 @@ jobs:
EXPECTED_SERVICE_NAME: postgres
EXPECTED_SERVER_VERSION: "16"

parametrized:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
postgres-version:
- "13"
- "14"
- "15"
steps:
- uses: actions/checkout@v4

- name: Run setup-postgres
uses: ./
with:
username: yoda
password: GrandMaster
database: jedi_order
port: 34837
postgres-version: ${{ matrix.postgres-version }}
id: postgres

- name: Run setup-python
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Run tests
run: |
python3 -m pip install --upgrade pip pytest psycopg furl
python3 -m pytest -vv test_action.py
env:
CONNECTION_URI: ${{ steps.postgres.outputs.connection-uri }}
SERVICE_NAME: ${{ steps.postgres.outputs.service-name }}
EXPECTED_CONNECTION_URI: postgresql://yoda:GrandMaster@localhost:34837/jedi_order
EXPECTED_SERVICE_NAME: yoda
EXPECTED_SERVER_VERSION: ${{ matrix.postgres-version }}
# parametrized:
# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# os:
# - ubuntu-latest
# - macos-latest
# - windows-latest
# postgres-version:
# - "13"
# - "14"
# - "15"
# steps:
# - uses: actions/checkout@v4
#
# - name: Run setup-postgres
# uses: ./
# with:
# username: yoda
# password: GrandMaster
# database: jedi_order
# port: 34837
# postgres-version: ${{ matrix.postgres-version }}
# id: postgres
#
# - name: Run setup-python
# uses: actions/setup-python@v5
# with:
# python-version: "3.10"
#
# - name: Run tests
# run: |
# python3 -m pip install --upgrade pip pytest psycopg furl
# python3 -m pytest -vv test_action.py
# env:
# CONNECTION_URI: ${{ steps.postgres.outputs.connection-uri }}
# SERVICE_NAME: ${{ steps.postgres.outputs.service-name }}
# EXPECTED_CONNECTION_URI: postgresql://yoda:GrandMaster@localhost:34837/jedi_order
# EXPECTED_SERVICE_NAME: yoda
# EXPECTED_SERVER_VERSION: ${{ matrix.postgres-version }}
47 changes: 30 additions & 17 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,40 +35,50 @@ outputs:
runs:
using: composite
steps:
- name: Cache PostgreSQL installation packages
uses: actions/cache@v3
# - name: Cache PostgreSQL installation packages
# uses: actions/cache@v3
# with:
# key: ${{ runner.os }}-postgres-${{ inputs.postgres-version }}
# path: |
# /var/cache/apt/archives
# C:\Users\<username>\AppData\Local\Temp\chocolatey

- uses: mxschmitt/action-tmate@v3
with:
key: ${{ runner.os }}-postgres-${{ inputs.postgres-version }}
path: |
/var/cache/apt/archives
C:\Users\<username>\AppData\Local\Temp\chocolatey
limit-access-to-actor: false

- name: Install PostgreSQL
run: |
if [[ ! "${{ inputs.postgres-version }}" =~ ^(13|14|15|16)$ ]]; then
echo "::error::postgres-version must be one of: 13, 14, 15, 16."
exit 1
fi
if [ "$RUNNER_OS" == "Linux" ]; then
echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" \
| sudo tee /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
APT_ENTRY="deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main"
APT_KEY="https://www.postgresql.org/media/keys/ACCC4CF8.asc"
echo "$APT_ENTRY" | sudo tee /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - "$APT_KEY" | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install postgresql-${{ inputs.postgres-version }}
# Add PostgreSQL binaries to PATH, so they become globally available.
/usr/lib/postgresql/${{ inputs.postgres-version }}/bin/pg_config --bindir >> $GITHUB_PATH
elif [ "$RUNNER_OS" == "Windows" ]; then
echo "$PGBIN" >> $GITHUB_PATH
echo "PQ_LIB_DIR=$PGROOT\lib" >> $GITHUB_ENV
elif [ "$RUNNER_OS" == "Windows" ]; then
# The Windows runner has some PostgreSQL environment variables set
# that may confuse users since they may be irrelevant to the
# PostgreSQL server we're using.
# PostgreSQL server we're using. Since GitHub actions does not
# support unsetting environment variables, the best we can do is to
# clear their values in order to indicate they must not be used.
for name in "PGROOT" "PGDATA" "PGBIN" "PGUSER" "PGPASSWORD"; do
echo "$name=" >> $GITHUB_ENV
done
# FIXME: Aargh! For reasons unknown the '--servicename' option is
# ignored when installing a PostgreSQL version that is already
# preinstalled on GitHub runners. In order to bypass the issue I'm
# using default naming convention to overwrite the service name.
# ignored when installing a PostgreSQL version that come preinstalled
# on the GitHub runners. In order to bypass the issue I'm using
# default naming convention to overwrite the service name.
choco install postgresql${{ inputs.postgres-version }} \
--ia "--servicename postgresql-${{ runner.arch }}-${{ inputs.postgres-version }}"
Expand All @@ -83,6 +93,9 @@ runs:
export PGROOT="$PROGRAMFILES/PostgreSQL/${{ inputs.postgres-version }}"
"$PGROOT"/bin/pg_config.exe --bindir >> $GITHUB_PATH
echo "PQ_LIB_DIR=$("$PGROOT"/bin/pg_config.exe --libdir)" >> $GITHUB_ENV
# echo "$PGBIN" >> $GITHUB_PATH
# echo "PQ_LIB_DIR=$PGROOT\lib" >> $GITHUB_ENV
elif [ "$RUNNER_OS" == "macOS" ]; then
case "$(sw_vers -productVersion)" in
13.*|14.*)
Expand Down

0 comments on commit 686f201

Please sign in to comment.