Skip to content

Conversation

thampton
Copy link

@thampton thampton commented Sep 17, 2025

Make the CI for the action work.

@thampton thampton changed the title Fix: use alternate port on ARM runners to avoid conflict Fix: use alternate port on ARM runners to avoid conflict and Postgres 14 on macos Sep 17, 2025
@thampton
Copy link
Author

thampton commented Sep 17, 2025

I had this check in CI to make it pass. Then I changed the action to this instead
https://github.com/OpenGov/action-setup-postgis/blob/main/action.yml#L72-L91

Not sure what the better solution is. I currently don't have any plans to make any version besides 14 work for mac. Not sure when homebrew will update postgis to a newer version.

   - name: Preflight checks
      shell: bash
      id: preflight
      env:
        INPUT_PORT: ${{ inputs.port }}
        INPUT_POSTGRES_VERSION: ${{ inputs.postgres-version }}
      run: |
        PORT="$INPUT_PORT"
        if [[ "$(uname -s)" == "Linux" && "$(uname -m)" == "aarch64" && "$PORT" == '5432' ]]; then
          echo "::notice::Detected Linux ARM64 runner — default PostgreSQL port 5432 may conflict with system service. Using a custom port (34837)."
          PORT=34837
        fi
        echo "port=$PORT" >> "$GITHUB_OUTPUT"
    
        PG_VERSION="$INPUT_POSTGRES_VERSION"
        if [[ "$RUNNER_OS" == "macOS" && "$PG_VERSION" != "14" ]]; then
          echo "::notice::On macOS, only postgres-version '14' is supported due to PostGIS Homebrew limitations. Auto-assigning version 14"
          PG_VERSION=14
        fi
        echo "postgres-version=$PG_VERSION" >> "$GITHUB_OUTPUT"  
        
    - name: Setup PostgreSQL for Linux/macOS/Windows
      id: pg
      uses: ikalnytskyi/action-setup-postgres@v7
      with:
        username: "${{ inputs.username }}"
        password: "${{ inputs.password }}"
        database: "${{ inputs.database }}"
        port: "${{ steps.preflight.outputs.port }}"
        postgres-version: "${{ steps.preflight.outputs.postgres-version }}"

id: resolve-port-and-version
run: |
# fix arm64 port collision
if [[ "$(uname -s)" == "Linux" && "$(uname -m)" == "aarch64" ]]; then
Copy link
Owner

@nyurik nyurik Sep 17, 2025

Choose a reason for hiding this comment

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

you never want to do this in the bash - much easier to use https://docs.github.com/en/actions/reference/workflows-and-actions/variables#runner-context e.g.

if: runner.os == 'Linux' && runner.arch == 'ARM64' outside of the run: block. See example.

- name: Run setup-postgis
uses: ./
id: postgres
uses: ./
Copy link
Owner

Choose a reason for hiding this comment

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

this is not a good test -- the idea of this action is so that it works with default parameters - otherwise you are expecting all users to do the above logic

@nyurik
Copy link
Owner

nyurik commented Sep 17, 2025

sorry, i misread your comment that you were testing it with this pr. So i think a much better approach would be to modify the upstream action for this -- as you can see, it also fails to pass: ikalnytskyi/action-setup-postgres#55

@thampton
Copy link
Author

thampton commented Sep 17, 2025

sorry, i misread your comment that you were testing it with this pr. So i think a much better approach would be to modify the upstream action for this -- as you can see, it also fails to pass: ikalnytskyi/action-setup-postgres#55

Created an issue ikalnytskyi/action-setup-postgres#56 with upstream.
Closed this and made an issue in this project, to track homebrew dependency issue: #19

@thampton thampton closed this Sep 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants