Skip to content

Commit 58a9f46

Browse files
authored
Merge pull request #1 from matt-42/master
Add port option.
2 parents 88ff92d + bb74cac commit 58a9f46

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
python3 -m pytest -vv test_action.py
3131
env:
3232
CONNECTION_URI: ${{ steps.postgres.outputs.connection-uri }}
33-
EXPECTED_CONNECTION_URI: postgresql://postgres:postgres@localhost/postgres
33+
EXPECTED_CONNECTION_URI: postgresql://postgres:postgres@localhost:5432/postgres
3434
shell: bash
3535

3636
parametrized:
@@ -50,13 +50,15 @@ jobs:
5050
username: yoda
5151
password: GrandMaster
5252
database: jedi_order
53+
port: 34837
5354
id: postgres
5455

5556
- name: Run tests
5657
run: |
5758
python3 -m pip install --upgrade pip pytest psycopg
5859
python3 -m pytest -vv test_action.py
5960
env:
61+
PGPORT: 34837
6062
CONNECTION_URI: ${{ steps.postgres.outputs.connection-uri }}
61-
EXPECTED_CONNECTION_URI: postgresql://yoda:GrandMaster@localhost/jedi_order
63+
EXPECTED_CONNECTION_URI: postgresql://yoda:GrandMaster@localhost:34837/jedi_order
6264
shell: bash

action.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ inputs:
1717
description: The database name to setup and grant permissions to created user.
1818
default: postgres
1919
required: false
20+
port:
21+
description: The server port.
22+
default: 5432
23+
required: false
2024
outputs:
2125
connection-uri:
2226
description: The connection URI to connect to PostgreSQL.
@@ -43,6 +47,7 @@ runs:
4347
# Forbid creating unix sockets since they are created by default in the
4448
# directory we don't have permissions to.
4549
echo "unix_socket_directories = ''" >> "$PGDATA/postgresql.conf"
50+
echo "port = ${{ inputs.port }}" >> "$PGDATA/postgresql.conf"
4651
pg_ctl start
4752
4853
# Both PGHOST and PGUSER are used by PostgreSQL tooling such as 'psql'
@@ -57,6 +62,7 @@ runs:
5762
# the current user.
5863
echo "PGHOST=localhost" >> $GITHUB_ENV
5964
echo "PGUSER=${USER:-$USERNAME}" >> $GITHUB_ENV
65+
echo "PGPORT=${{ inputs.port }}" >> $GITHUB_ENV
6066
shell: bash
6167

6268
- name: Setup PostgreSQL user and database
@@ -72,7 +78,7 @@ runs:
7278

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

0 commit comments

Comments
 (0)