Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
python3 -m pytest -vv test_action.py
env:
CONNECTION_URI: ${{ steps.postgres.outputs.connection-uri }}
EXPECTED_CONNECTION_URI: postgresql://postgres:postgres@localhost/postgres
EXPECTED_CONNECTION_URI: postgresql://postgres:postgres@localhost:5432/postgres
shell: bash

parametrized:
Expand All @@ -50,13 +50,15 @@ jobs:
username: yoda
password: GrandMaster
database: jedi_order
port: 34837
id: postgres

- name: Run tests
run: |
python3 -m pip install --upgrade pip pytest psycopg
python3 -m pytest -vv test_action.py
env:
PGPORT: 34837
CONNECTION_URI: ${{ steps.postgres.outputs.connection-uri }}
EXPECTED_CONNECTION_URI: postgresql://yoda:GrandMaster@localhost/jedi_order
EXPECTED_CONNECTION_URI: postgresql://yoda:GrandMaster@localhost:34837/jedi_order
shell: bash
9 changes: 8 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ inputs:
description: The database name to setup and grant permissions to created user.
default: postgres
required: false
port:
description: The server port.
default: 5432
required: false
outputs:
connection-uri:
description: The connection URI to connect to PostgreSQL.
Expand All @@ -43,6 +47,7 @@ runs:
# Forbid creating unix sockets since they are created by default in the
# directory we don't have permissions to.
echo "unix_socket_directories = ''" >> "$PGDATA/postgresql.conf"
echo "port = ${{ inputs.port }}" >> "$PGDATA/postgresql.conf"
pg_ctl start

# Both PGHOST and PGUSER are used by PostgreSQL tooling such as 'psql'
Expand All @@ -60,6 +65,8 @@ runs:
shell: bash

- name: Setup PostgreSQL user and database
env:
PGPORT: ${{ inputs.port }}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't persist, and thus users' steps won't be able to use psql or createuser directly. We should persist it together with PGUSER and PGHOST in the step above. Can you please move it there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm writing a database driver and I wanted to test that it also work on a non default port. That's why I added this option.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't persist, and thus users' steps won't be able to use psql or createuser directly. We should persist it together with PGUSER and PGHOST in the step above. Can you please move it there?

Fixed in my last commit.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm writing a database driver and I wanted to test that it also work on a non default port. That's why I added this option.

Makes sense. 👍

Fixed in my last commit.

Great! Thank you!

run: |
createuser --createdb ${{ inputs.username }}

Expand All @@ -72,7 +79,7 @@ runs:

- name: Expose connection URI
run: |
CONNECTION_URI="postgresql://${{ inputs.username }}:${{ inputs.password }}@localhost/${{ inputs.database }}"
CONNECTION_URI="postgresql://${{ inputs.username }}:${{ inputs.password }}@localhost:${{inputs.port}}/${{ inputs.database }}"
echo ::set-output name=value::$CONNECTION_URI
shell: bash
id: connection-uri