From b9d2f2a4c277ab18f3acae77dc5c8afa89cc9017 Mon Sep 17 00:00:00 2001 From: Matthieu Garrigues Date: Wed, 2 Feb 2022 13:30:16 +0100 Subject: [PATCH 1/2] Add port option. --- .github/workflows/ci.yml | 6 ++++-- action.yml | 9 ++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9145eac34..92a5df633 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: @@ -50,6 +50,7 @@ jobs: username: yoda password: GrandMaster database: jedi_order + port: 34837 id: postgres - name: Run tests @@ -57,6 +58,7 @@ jobs: 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 diff --git a/action.yml b/action.yml index eaf606ea7..7736f50e8 100644 --- a/action.yml +++ b/action.yml @@ -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. @@ -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' @@ -60,6 +65,8 @@ runs: shell: bash - name: Setup PostgreSQL user and database + env: + PGPORT: ${{ inputs.port }} run: | createuser --createdb ${{ inputs.username }} @@ -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 From bb74cacada2736db50636436fc93c51642401ae0 Mon Sep 17 00:00:00 2001 From: Matthieu Garrigues Date: Tue, 8 Feb 2022 01:30:59 +0100 Subject: [PATCH 2/2] Update action.yml --- action.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 7736f50e8..a1b467162 100644 --- a/action.yml +++ b/action.yml @@ -62,11 +62,10 @@ runs: # the current user. echo "PGHOST=localhost" >> $GITHUB_ENV echo "PGUSER=${USER:-$USERNAME}" >> $GITHUB_ENV + echo "PGPORT=${{ inputs.port }}" >> $GITHUB_ENV shell: bash - name: Setup PostgreSQL user and database - env: - PGPORT: ${{ inputs.port }} run: | createuser --createdb ${{ inputs.username }}