From da180d5340d149a9a443374cea7217fe2a33cc03 Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 14:46:30 +0800 Subject: [PATCH 01/32] finish action --- .github/workflows/ci.yml | 66 ++++++++++++++++++++++++++++++++++++++++ action.yml | 44 +++++++++++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 action.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..1b637bc --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,66 @@ +name: CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, ubuntu-24.04, windows-latest, windows-2019, macos-latest, macos-13] + include: + - os: ubuntu-latest + postgres-version: '17' + - os: ubuntu-24.04 + postgres-version: '17' + - os: windows-latest + postgres-version: '17' + - os: windows-2019 + postgres-version: '17' + - os: macos-latest + postgres-version: '17' + - os: macos-13 + postgres-version: '17' + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + + - name: Setup pgvector + uses: ./ + with: + postgres-version: ${{ matrix.postgres-version }} + + - name: Start PostgreSQL (Ubuntu) + if: startsWith(matrix.os, 'ubuntu-') + run: | + sudo systemctl start postgresql.service + + - name: Start PostgreSQL (macOS) + if: startsWith(matrix.os, 'macos-') + run: | + brew services start postgresql@${{ matrix.postgres-version }} + + - name: Test Extension (Ubuntu) + if: startsWith(matrix.os, 'ubuntu-') + run: | + sudo -u postgres psql -c 'CREATE EXTENSION vector;' + sudo -u postgres psql -c 'SELECT vector_version();' + + - name: Test Extension (macOS) + if: startsWith(matrix.os, 'macos-') + run: | + psql postgres -c 'CREATE EXTENSION vector;' + psql postgres -c 'SELECT vector_version();' + + - name: Test Extension (Windows) + if: startsWith(matrix.os, 'windows-') + shell: cmd + run: | + psql -U postgres -c "CREATE EXTENSION vector;" + psql -U postgres -c "SELECT vector_version();" diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..69da276 --- /dev/null +++ b/action.yml @@ -0,0 +1,44 @@ +name: 'Setup pgvector' +description: 'Setup pgvector extension for PostgreSQL' +inputs: + postgres-version: + description: 'PostgreSQL version to use' + required: false + default: '17' +runs: + using: "composite" + steps: + - name: Install pgvector on Ubuntu + if: runner.os == 'Linux' + shell: bash + run: | + sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y + sudo apt-get install postgresql-${{ inputs.postgres-version }}-pgvector + + - name: Install pgvector on macOS + if: runner.os == 'macOS' + shell: bash + run: | + brew install pgvector + + - name: Install pgvector on Windows 2022 + if: runner.os == 'Windows' && matrix.os != 'windows-2019' + shell: cmd + run: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" + cd %TEMP% + git clone --branch v0.8.0 https://github.com/pgvector/pgvector.git + cd pgvector + nmake /NOLOGO /F Makefile.win + nmake /NOLOGO /F Makefile.win install + + - name: Install pgvector on Windows 2019 + if: runner.os == 'Windows' && matrix.os == 'windows-2019' + shell: cmd + run: | + call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" + cd %TEMP% + git clone --branch v0.8.0 https://github.com/pgvector/pgvector.git + cd pgvector + nmake /NOLOGO /F Makefile.win + nmake /NOLOGO /F Makefile.win install From 1a1573d3383119baddbb438c71362ebe4baca00a Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 14:49:09 +0800 Subject: [PATCH 02/32] update macos installation --- .github/workflows/ci.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b637bc..5dfbe1b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,7 @@ on: jobs: test: + continue-on-error: true strategy: fail-fast: false matrix: @@ -30,6 +31,13 @@ jobs: steps: - uses: actions/checkout@v4 + + - name: Install PostgreSQL (macOS) + if: startsWith(matrix.os, 'macos-') + run: | + brew install postgresql@${{ matrix.postgres-version }} + brew link postgresql@${{ matrix.postgres-version }} + echo "/usr/local/opt/postgresql@${{ matrix.postgres-version }}/bin" >> $GITHUB_PATH - name: Setup pgvector uses: ./ @@ -45,6 +53,7 @@ jobs: if: startsWith(matrix.os, 'macos-') run: | brew services start postgresql@${{ matrix.postgres-version }} + sleep 3 # wait for PostgreSQL to start - name: Test Extension (Ubuntu) if: startsWith(matrix.os, 'ubuntu-') @@ -55,6 +64,7 @@ jobs: - name: Test Extension (macOS) if: startsWith(matrix.os, 'macos-') run: | + createdb $USER psql postgres -c 'CREATE EXTENSION vector;' psql postgres -c 'SELECT vector_version();' From 5259dc93511437686c819fb2d4090d094715da81 Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 14:55:57 +0800 Subject: [PATCH 03/32] try fix --- .github/workflows/ci.yml | 8 ++++++-- README.md | 9 ++++++++- action.yml | 21 ++++++++++++++++++--- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5dfbe1b..842cdf9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,8 +65,12 @@ jobs: if: startsWith(matrix.os, 'macos-') run: | createdb $USER - psql postgres -c 'CREATE EXTENSION vector;' - psql postgres -c 'SELECT vector_version();' + psql $USER -c 'CREATE EXTENSION vector;' + psql $USER -c '\dx' + psql $USER -c 'SELECT * FROM pg_available_extensions WHERE name = '\''vector'\'';' + psql $USER -c 'CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3));' + psql $USER -c 'INSERT INTO items (embedding) VALUES ('\''[1,2,3]'\'');' + psql $USER -c 'SELECT * FROM items;' - name: Test Extension (Windows) if: startsWith(matrix.os, 'windows-') diff --git a/README.md b/README.md index 8470640..31bdbec 100644 --- a/README.md +++ b/README.md @@ -10,16 +10,18 @@ steps: - uses: cpunion/setup-pgvector@v1 with: postgres-version: '17' # optional, defaults to 17. Use 14 for ubuntu-22.04 and ubuntu-20.04 + pgvector-version: '0.8.0' # optional, defaults to 0.8.0 ``` ## Inputs - `postgres-version`: PostgreSQL version to use (default: '17'). Note: Use '14' for ubuntu-22.04 and ubuntu-20.04. +- `pgvector-version`: pgvector version to install (default: '0.8.0') ## Platform Support This action supports all major GitHub Actions platforms: -- Ubuntu (using postgresql-xx-pgvector package) +- Ubuntu (using postgresql-xx-pgvector package or building from source) - macOS (using Homebrew) - Windows (building from source using Visual Studio Build Tools) @@ -47,6 +49,7 @@ jobs: uses: cpunion/setup-pgvector@v1 with: postgres-version: '17' # Use '14' for ubuntu-22.04 and ubuntu-20.04 + pgvector-version: '0.8.0' - name: Create extension run: | sudo -u postgres psql -c 'CREATE EXTENSION vector;' @@ -65,6 +68,8 @@ jobs: - uses: actions/checkout@v4 - name: Setup pgvector uses: cpunion/setup-pgvector@v1 + with: + pgvector-version: '0.8.0' - name: Create extension run: | psql postgres -c 'CREATE EXTENSION vector;' @@ -86,6 +91,8 @@ jobs: - uses: actions/checkout@v4 - name: Setup pgvector uses: cpunion/setup-pgvector@v1 + with: + pgvector-version: '0.8.0' - name: Create extension shell: cmd run: | diff --git a/action.yml b/action.yml index 69da276..f753a8d 100644 --- a/action.yml +++ b/action.yml @@ -5,6 +5,10 @@ inputs: description: 'PostgreSQL version to use' required: false default: '17' + pgvector-version: + description: 'pgvector version to install' + required: false + default: '0.8.0' runs: using: "composite" steps: @@ -13,7 +17,18 @@ runs: shell: bash run: | sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y - sudo apt-get install postgresql-${{ inputs.postgres-version }}-pgvector + sudo apt-get update + sudo apt-get install -y postgresql-${{ inputs.postgres-version }}-pgvector + # If package not available, build from source + if [ $? -ne 0 ]; then + sudo apt-get install -y postgresql-server-dev-${{ inputs.postgres-version }} build-essential git + git clone --branch v${{ inputs.pgvector-version }} https://github.com/pgvector/pgvector.git + cd pgvector + make + sudo make install + cd .. + rm -rf pgvector + fi - name: Install pgvector on macOS if: runner.os == 'macOS' @@ -27,7 +42,7 @@ runs: run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" cd %TEMP% - git clone --branch v0.8.0 https://github.com/pgvector/pgvector.git + git clone --branch v${{ inputs.pgvector-version }} https://github.com/pgvector/pgvector.git cd pgvector nmake /NOLOGO /F Makefile.win nmake /NOLOGO /F Makefile.win install @@ -38,7 +53,7 @@ runs: run: | call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" cd %TEMP% - git clone --branch v0.8.0 https://github.com/pgvector/pgvector.git + git clone --branch v${{ inputs.pgvector-version }} https://github.com/pgvector/pgvector.git cd pgvector nmake /NOLOGO /F Makefile.win nmake /NOLOGO /F Makefile.win install From 09a458d5c9f30b347ea8452d35c0ff41ebdf3090 Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 14:59:26 +0800 Subject: [PATCH 04/32] try fix --- action.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/action.yml b/action.yml index f753a8d..384e83a 100644 --- a/action.yml +++ b/action.yml @@ -16,11 +16,22 @@ runs: if: runner.os == 'Linux' shell: bash run: | + echo "Checking PostgreSQL installation..." + ls -la /usr/share/postgresql/ + pg_version=$(psql --version | awk '{print $3}' | cut -d. -f1) + echo "PostgreSQL version: $pg_version" + echo "Expected version: ${{ inputs.postgres-version }}" + sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y sudo apt-get update + + echo "Available PostgreSQL packages:" + apt-cache search postgresql | grep postgresql-[0-9] + sudo apt-get install -y postgresql-${{ inputs.postgres-version }}-pgvector # If package not available, build from source if [ $? -ne 0 ]; then + echo "Package postgresql-${{ inputs.postgres-version }}-pgvector not available, building from source..." sudo apt-get install -y postgresql-server-dev-${{ inputs.postgres-version }} build-essential git git clone --branch v${{ inputs.pgvector-version }} https://github.com/pgvector/pgvector.git cd pgvector @@ -29,6 +40,11 @@ runs: cd .. rm -rf pgvector fi + + echo "Checking installed PostgreSQL extensions directory:" + ls -la /usr/share/postgresql/*/extension/ + echo "Checking pgvector installation:" + find /usr -name "vector.control" 2>/dev/null - name: Install pgvector on macOS if: runner.os == 'macOS' @@ -36,6 +52,16 @@ runs: run: | brew install pgvector + - name: Install PostgreSQL on Windows + if: runner.os == 'Windows' + shell: pwsh + run: | + choco install postgresql${{ inputs.postgres-version }} --params '/Password:postgres' + $pgPath = "C:\Program Files\PostgreSQL\${{ inputs.postgres-version }}" + echo "$pgPath\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + echo "$pgPath\lib" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + refreshenv + - name: Install pgvector on Windows 2022 if: runner.os == 'Windows' && matrix.os != 'windows-2019' shell: cmd @@ -44,6 +70,7 @@ runs: cd %TEMP% git clone --branch v${{ inputs.pgvector-version }} https://github.com/pgvector/pgvector.git cd pgvector + set PATH=C:\Program Files\PostgreSQL\${{ inputs.postgres-version }}\bin;C:\Program Files\PostgreSQL\${{ inputs.postgres-version }}\lib;%PATH% nmake /NOLOGO /F Makefile.win nmake /NOLOGO /F Makefile.win install @@ -55,5 +82,13 @@ runs: cd %TEMP% git clone --branch v${{ inputs.pgvector-version }} https://github.com/pgvector/pgvector.git cd pgvector + set PATH=C:\Program Files\PostgreSQL\${{ inputs.postgres-version }}\bin;C:\Program Files\PostgreSQL\${{ inputs.postgres-version }}\lib;%PATH% nmake /NOLOGO /F Makefile.win nmake /NOLOGO /F Makefile.win install + + - name: Start PostgreSQL Service on Windows + if: runner.os == 'Windows' + shell: pwsh + run: | + Start-Service postgresql-x64-${{ inputs.postgres-version }} + Start-Sleep -s 3 # Wait for PostgreSQL to start From 75514813c077c816abb04690aef916b7596dc869 Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 15:02:48 +0800 Subject: [PATCH 05/32] try fix --- action.yml | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/action.yml b/action.yml index 384e83a..1fb8fc9 100644 --- a/action.yml +++ b/action.yml @@ -18,16 +18,31 @@ runs: run: | echo "Checking PostgreSQL installation..." ls -la /usr/share/postgresql/ + + # Get the actual PostgreSQL version pg_version=$(psql --version | awk '{print $3}' | cut -d. -f1) - echo "PostgreSQL version: $pg_version" - echo "Expected version: ${{ inputs.postgres-version }}" + echo "Current PostgreSQL version: $pg_version" + echo "Target version: ${{ inputs.postgres-version }}" + # Install PostgreSQL of the specified version sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y sudo apt-get update + sudo apt-get install -y postgresql-${{ inputs.postgres-version }} + + # Stop PostgreSQL service to switch version + sudo systemctl stop postgresql + + # Update alternatives to use the correct version + sudo update-alternatives --set postgresql /usr/lib/postgresql/${{ inputs.postgres-version }}/bin/postgres - echo "Available PostgreSQL packages:" - apt-cache search postgresql | grep postgresql-[0-9] + # Start PostgreSQL with the new version + sudo systemctl start postgresql + # Verify the running version + pg_version=$(psql --version | awk '{print $3}' | cut -d. -f1) + echo "PostgreSQL version after update: $pg_version" + + echo "Installing pgvector..." sudo apt-get install -y postgresql-${{ inputs.postgres-version }}-pgvector # If package not available, build from source if [ $? -ne 0 ]; then @@ -36,15 +51,18 @@ runs: git clone --branch v${{ inputs.pgvector-version }} https://github.com/pgvector/pgvector.git cd pgvector make - sudo make install + sudo make install PG_CONFIG=/usr/lib/postgresql/${{ inputs.postgres-version }}/bin/pg_config cd .. rm -rf pgvector fi echo "Checking installed PostgreSQL extensions directory:" - ls -la /usr/share/postgresql/*/extension/ + ls -la /usr/share/postgresql/${{ inputs.postgres-version }}/extension/ echo "Checking pgvector installation:" find /usr -name "vector.control" 2>/dev/null + + # Restart PostgreSQL to ensure it picks up the new extension + sudo systemctl restart postgresql - name: Install pgvector on macOS if: runner.os == 'macOS' From 787744aad4287d9754906457f36213b987cf0541 Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 15:08:37 +0800 Subject: [PATCH 06/32] try fix --- .github/workflows/ci.yml | 45 ++---------------- action.yml | 99 ++++++---------------------------------- 2 files changed, 20 insertions(+), 124 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 842cdf9..e5751f3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,50 +31,15 @@ jobs: steps: - uses: actions/checkout@v4 - - - name: Install PostgreSQL (macOS) - if: startsWith(matrix.os, 'macos-') - run: | - brew install postgresql@${{ matrix.postgres-version }} - brew link postgresql@${{ matrix.postgres-version }} - echo "/usr/local/opt/postgresql@${{ matrix.postgres-version }}/bin" >> $GITHUB_PATH - name: Setup pgvector uses: ./ with: postgres-version: ${{ matrix.postgres-version }} - - - name: Start PostgreSQL (Ubuntu) - if: startsWith(matrix.os, 'ubuntu-') - run: | - sudo systemctl start postgresql.service - - - name: Start PostgreSQL (macOS) - if: startsWith(matrix.os, 'macos-') - run: | - brew services start postgresql@${{ matrix.postgres-version }} - sleep 3 # wait for PostgreSQL to start - - - name: Test Extension (Ubuntu) - if: startsWith(matrix.os, 'ubuntu-') - run: | - sudo -u postgres psql -c 'CREATE EXTENSION vector;' - sudo -u postgres psql -c 'SELECT vector_version();' - - - name: Test Extension (macOS) - if: startsWith(matrix.os, 'macos-') - run: | - createdb $USER - psql $USER -c 'CREATE EXTENSION vector;' - psql $USER -c '\dx' - psql $USER -c 'SELECT * FROM pg_available_extensions WHERE name = '\''vector'\'';' - psql $USER -c 'CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3));' - psql $USER -c 'INSERT INTO items (embedding) VALUES ('\''[1,2,3]'\'');' - psql $USER -c 'SELECT * FROM items;' - - name: Test Extension (Windows) - if: startsWith(matrix.os, 'windows-') - shell: cmd + - name: Test Extension run: | - psql -U postgres -c "CREATE EXTENSION vector;" - psql -U postgres -c "SELECT vector_version();" + psql -d postgres -c 'CREATE EXTENSION vector;' + psql -d postgres -c 'CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3));' + psql -d postgres -c 'INSERT INTO items (embedding) VALUES ('\''[1,2,3]'\'');' + psql -d postgres -c 'SELECT * FROM items;' diff --git a/action.yml b/action.yml index 1fb8fc9..2607e3c 100644 --- a/action.yml +++ b/action.yml @@ -12,101 +12,32 @@ inputs: runs: using: "composite" steps: - - name: Install pgvector on Ubuntu + - name: Install and Configure PostgreSQL on Ubuntu if: runner.os == 'Linux' shell: bash run: | - echo "Checking PostgreSQL installation..." - ls -la /usr/share/postgresql/ - - # Get the actual PostgreSQL version - pg_version=$(psql --version | awk '{print $3}' | cut -d. -f1) - echo "Current PostgreSQL version: $pg_version" - echo "Target version: ${{ inputs.postgres-version }}" - - # Install PostgreSQL of the specified version - sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y - sudo apt-get update - sudo apt-get install -y postgresql-${{ inputs.postgres-version }} - - # Stop PostgreSQL service to switch version - sudo systemctl stop postgresql - - # Update alternatives to use the correct version - sudo update-alternatives --set postgresql /usr/lib/postgresql/${{ inputs.postgres-version }}/bin/postgres - - # Start PostgreSQL with the new version - sudo systemctl start postgresql - - # Verify the running version - pg_version=$(psql --version | awk '{print $3}' | cut -d. -f1) - echo "PostgreSQL version after update: $pg_version" - - echo "Installing pgvector..." - sudo apt-get install -y postgresql-${{ inputs.postgres-version }}-pgvector - # If package not available, build from source - if [ $? -ne 0 ]; then - echo "Package postgresql-${{ inputs.postgres-version }}-pgvector not available, building from source..." - sudo apt-get install -y postgresql-server-dev-${{ inputs.postgres-version }} build-essential git - git clone --branch v${{ inputs.pgvector-version }} https://github.com/pgvector/pgvector.git - cd pgvector - make - sudo make install PG_CONFIG=/usr/lib/postgresql/${{ inputs.postgres-version }}/bin/pg_config - cd .. - rm -rf pgvector - fi - - echo "Checking installed PostgreSQL extensions directory:" - ls -la /usr/share/postgresql/${{ inputs.postgres-version }}/extension/ - echo "Checking pgvector installation:" - find /usr -name "vector.control" 2>/dev/null - - # Restart PostgreSQL to ensure it picks up the new extension - sudo systemctl restart postgresql + chmod +x ${{ github.action_path }}/scripts/install-ubuntu.sh + ${{ github.action_path }}/scripts/install-ubuntu.sh ${{ inputs.postgres-version }} ${{ inputs.pgvector-version }} - - name: Install pgvector on macOS + - name: Install and Configure PostgreSQL on macOS if: runner.os == 'macOS' shell: bash run: | - brew install pgvector + chmod +x ${{ github.action_path }}/scripts/install-macos.sh + ${{ github.action_path }}/scripts/install-macos.sh ${{ inputs.postgres-version }} - - name: Install PostgreSQL on Windows + - name: Install and Configure PostgreSQL on Windows if: runner.os == 'Windows' shell: pwsh run: | - choco install postgresql${{ inputs.postgres-version }} --params '/Password:postgres' - $pgPath = "C:\Program Files\PostgreSQL\${{ inputs.postgres-version }}" - echo "$pgPath\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - echo "$pgPath\lib" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - refreshenv + ${{ github.action_path }}/scripts/install-windows.ps1 -PostgresVersion ${{ inputs.postgres-version }} -PgVectorVersion ${{ inputs.pgvector-version }} - - name: Install pgvector on Windows 2022 - if: runner.os == 'Windows' && matrix.os != 'windows-2019' - shell: cmd - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" - cd %TEMP% - git clone --branch v${{ inputs.pgvector-version }} https://github.com/pgvector/pgvector.git - cd pgvector - set PATH=C:\Program Files\PostgreSQL\${{ inputs.postgres-version }}\bin;C:\Program Files\PostgreSQL\${{ inputs.postgres-version }}\lib;%PATH% - nmake /NOLOGO /F Makefile.win - nmake /NOLOGO /F Makefile.win install - - - name: Install pgvector on Windows 2019 - if: runner.os == 'Windows' && matrix.os == 'windows-2019' - shell: cmd - run: | - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" - cd %TEMP% - git clone --branch v${{ inputs.pgvector-version }} https://github.com/pgvector/pgvector.git - cd pgvector - set PATH=C:\Program Files\PostgreSQL\${{ inputs.postgres-version }}\bin;C:\Program Files\PostgreSQL\${{ inputs.postgres-version }}\lib;%PATH% - nmake /NOLOGO /F Makefile.win - nmake /NOLOGO /F Makefile.win install - - - name: Start PostgreSQL Service on Windows + - name: Install pgvector on Windows if: runner.os == 'Windows' - shell: pwsh + shell: cmd run: | - Start-Service postgresql-x64-${{ inputs.postgres-version }} - Start-Sleep -s 3 # Wait for PostgreSQL to start + if "${{ matrix.os }}" == "windows-2019" ( + ${{ github.action_path }}/scripts/install-pgvector-windows.bat ${{ inputs.postgres-version }} ${{ inputs.pgvector-version }} 2019 + ) else ( + ${{ github.action_path }}/scripts/install-pgvector-windows.bat ${{ inputs.postgres-version }} ${{ inputs.pgvector-version }} 2022 + ) From f5ab09e52ba35bbffd435ab221eb5409cf13965e Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 15:08:50 +0800 Subject: [PATCH 07/32] try fix --- scripts/install-macos.sh | 14 +++++++++++ scripts/install-pgvector-windows.bat | 19 ++++++++++++++ scripts/install-ubuntu.sh | 37 ++++++++++++++++++++++++++++ scripts/install-windows.ps1 | 17 +++++++++++++ 4 files changed, 87 insertions(+) create mode 100644 scripts/install-macos.sh create mode 100644 scripts/install-pgvector-windows.bat create mode 100644 scripts/install-ubuntu.sh create mode 100644 scripts/install-windows.ps1 diff --git a/scripts/install-macos.sh b/scripts/install-macos.sh new file mode 100644 index 0000000..8ed67b2 --- /dev/null +++ b/scripts/install-macos.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -e + +PG_VERSION=$1 + +brew install postgresql@${PG_VERSION} +brew link postgresql@${PG_VERSION} +echo "/usr/local/opt/postgresql@${PG_VERSION}/bin" >> $GITHUB_PATH + +brew services start postgresql@${PG_VERSION} +sleep 3 # wait for PostgreSQL to start + +createdb $USER || true +brew install pgvector diff --git a/scripts/install-pgvector-windows.bat b/scripts/install-pgvector-windows.bat new file mode 100644 index 0000000..f862cf0 --- /dev/null +++ b/scripts/install-pgvector-windows.bat @@ -0,0 +1,19 @@ +@echo off +setlocal + +set PG_VERSION=%1 +set PGVECTOR_VERSION=%2 +set VS_VERSION=%3 + +if "%VS_VERSION%"=="2019" ( + call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" +) else ( + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" +) + +cd %TEMP% +git clone --branch v%PGVECTOR_VERSION% https://github.com/pgvector/pgvector.git +cd pgvector +set PATH=C:\Program Files\PostgreSQL\%PG_VERSION%\bin;C:\Program Files\PostgreSQL\%PG_VERSION%\lib;%PATH% +nmake /NOLOGO /F Makefile.win +nmake /NOLOGO /F Makefile.win install diff --git a/scripts/install-ubuntu.sh b/scripts/install-ubuntu.sh new file mode 100644 index 0000000..4941d59 --- /dev/null +++ b/scripts/install-ubuntu.sh @@ -0,0 +1,37 @@ +#!/bin/bash +set -e + +PG_VERSION=$1 +PGVECTOR_VERSION=$2 + +echo "Installing PostgreSQL ${PG_VERSION}..." +sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y +sudo apt-get update +sudo apt-get install -y postgresql-${PG_VERSION} + +# Configure PostgreSQL +sudo systemctl stop postgresql +sudo pg_dropcluster --stop ${PG_VERSION} main || true +sudo pg_createcluster ${PG_VERSION} main --start || true +sudo systemctl start postgresql + +# Verify PostgreSQL installation +sudo -u postgres psql -c "SELECT version();" + +echo "Installing pgvector..." +sudo apt-get install -y postgresql-${PG_VERSION}-pgvector +if [ $? -ne 0 ]; then + echo "Building pgvector from source..." + sudo apt-get install -y postgresql-server-dev-${PG_VERSION} build-essential git + git clone --branch v${PGVECTOR_VERSION} https://github.com/pgvector/pgvector.git + cd pgvector + make + sudo make install PG_CONFIG=/usr/lib/postgresql/${PG_VERSION}/bin/pg_config + cd .. + rm -rf pgvector +fi + +# Configure PostgreSQL authentication for CI +echo "local all postgres trust" | sudo tee /etc/postgresql/${PG_VERSION}/main/pg_hba.conf +echo "local all all trust" | sudo tee -a /etc/postgresql/${PG_VERSION}/main/pg_hba.conf +sudo systemctl restart postgresql diff --git a/scripts/install-windows.ps1 b/scripts/install-windows.ps1 new file mode 100644 index 0000000..67ad2ca --- /dev/null +++ b/scripts/install-windows.ps1 @@ -0,0 +1,17 @@ +param( + [string]$PostgresVersion, + [string]$PgVectorVersion +) + +# Install PostgreSQL +choco install postgresql$PostgresVersion --params '/Password:postgres' +$pgPath = "C:\Program Files\PostgreSQL\$PostgresVersion" +echo "$pgPath\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append +echo "$pgPath\lib" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append +refreshenv + +# Start PostgreSQL service +Start-Service postgresql-x64-$PostgresVersion +Start-Sleep -s 3 # Wait for PostgreSQL to start +$env:PGPASSWORD = 'postgres' +psql -U postgres -c "SELECT version();" From c78fcbcfcb243fc81f86ee561435d80a2ad37ca2 Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 15:13:06 +0800 Subject: [PATCH 08/32] try fix --- scripts/install-ubuntu.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/install-ubuntu.sh b/scripts/install-ubuntu.sh index 4941d59..c395764 100644 --- a/scripts/install-ubuntu.sh +++ b/scripts/install-ubuntu.sh @@ -15,6 +15,9 @@ sudo pg_dropcluster --stop ${PG_VERSION} main || true sudo pg_createcluster ${PG_VERSION} main --start || true sudo systemctl start postgresql +# Create runner user and grant permissions +sudo -u postgres psql -c "CREATE USER runner WITH SUPERUSER;" + # Verify PostgreSQL installation sudo -u postgres psql -c "SELECT version();" @@ -33,5 +36,6 @@ fi # Configure PostgreSQL authentication for CI echo "local all postgres trust" | sudo tee /etc/postgresql/${PG_VERSION}/main/pg_hba.conf +echo "local all runner trust" | sudo tee -a /etc/postgresql/${PG_VERSION}/main/pg_hba.conf echo "local all all trust" | sudo tee -a /etc/postgresql/${PG_VERSION}/main/pg_hba.conf sudo systemctl restart postgresql From 0fa2719e6617854438aa0790ba39bbdf0665437a Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 15:16:09 +0800 Subject: [PATCH 09/32] try fix --- scripts/install-ubuntu.sh | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/scripts/install-ubuntu.sh b/scripts/install-ubuntu.sh index c395764..fea9500 100644 --- a/scripts/install-ubuntu.sh +++ b/scripts/install-ubuntu.sh @@ -22,14 +22,19 @@ sudo -u postgres psql -c "CREATE USER runner WITH SUPERUSER;" sudo -u postgres psql -c "SELECT version();" echo "Installing pgvector..." +# First try installing from package sudo apt-get install -y postgresql-${PG_VERSION}-pgvector -if [ $? -ne 0 ]; then +PGVECTOR_INSTALLED=$? + +# If package installation fails, build from source +if [ $PGVECTOR_INSTALLED -ne 0 ]; then echo "Building pgvector from source..." sudo apt-get install -y postgresql-server-dev-${PG_VERSION} build-essential git git clone --branch v${PGVECTOR_VERSION} https://github.com/pgvector/pgvector.git cd pgvector + make clean make - sudo make install PG_CONFIG=/usr/lib/postgresql/${PG_VERSION}/bin/pg_config + sudo make install cd .. rm -rf pgvector fi @@ -38,4 +43,16 @@ fi echo "local all postgres trust" | sudo tee /etc/postgresql/${PG_VERSION}/main/pg_hba.conf echo "local all runner trust" | sudo tee -a /etc/postgresql/${PG_VERSION}/main/pg_hba.conf echo "local all all trust" | sudo tee -a /etc/postgresql/${PG_VERSION}/main/pg_hba.conf + +# Restart PostgreSQL to ensure pgvector is loaded sudo systemctl restart postgresql + +# Verify pgvector installation +echo "Verifying pgvector installation..." +sudo -u postgres psql -d postgres -c "SELECT * FROM pg_extension;" || true +sudo -u postgres psql -d postgres -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';" || true + +# List extension directory contents +echo "Checking extension files..." +ls -la /usr/share/postgresql/${PG_VERSION}/extension/ || true +ls -la /usr/lib/postgresql/${PG_VERSION}/lib/ || true From 82775cb7f339aa25dd8d351a42448ca8437f3483 Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 15:17:21 +0800 Subject: [PATCH 10/32] try fix --- action.yml | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/action.yml b/action.yml index 2607e3c..798cbfa 100644 --- a/action.yml +++ b/action.yml @@ -28,16 +28,7 @@ runs: - name: Install and Configure PostgreSQL on Windows if: runner.os == 'Windows' - shell: pwsh - run: | - ${{ github.action_path }}/scripts/install-windows.ps1 -PostgresVersion ${{ inputs.postgres-version }} -PgVectorVersion ${{ inputs.pgvector-version }} - - - name: Install pgvector on Windows - if: runner.os == 'Windows' - shell: cmd + shell: bash run: | - if "${{ matrix.os }}" == "windows-2019" ( - ${{ github.action_path }}/scripts/install-pgvector-windows.bat ${{ inputs.postgres-version }} ${{ inputs.pgvector-version }} 2019 - ) else ( - ${{ github.action_path }}/scripts/install-pgvector-windows.bat ${{ inputs.postgres-version }} ${{ inputs.pgvector-version }} 2022 - ) + chmod +x ${{ github.action_path }}/scripts/install-windows.sh + ${{ github.action_path }}/scripts/install-windows.sh ${{ inputs.postgres-version }} ${{ inputs.pgvector-version }} From 21ad25f921916abe34c3c6d81c77a88e9278af1d Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 15:20:17 +0800 Subject: [PATCH 11/32] try fix --- scripts/install-ubuntu.sh | 20 ++++++++++++++-- scripts/install-windows.sh | 47 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 scripts/install-windows.sh diff --git a/scripts/install-ubuntu.sh b/scripts/install-ubuntu.sh index fea9500..a0837c3 100644 --- a/scripts/install-ubuntu.sh +++ b/scripts/install-ubuntu.sh @@ -18,8 +18,12 @@ sudo systemctl start postgresql # Create runner user and grant permissions sudo -u postgres psql -c "CREATE USER runner WITH SUPERUSER;" -# Verify PostgreSQL installation -sudo -u postgres psql -c "SELECT version();" +# Verify PostgreSQL installation and version +echo "Checking PostgreSQL version..." +PG_ACTUAL_VERSION=$(sudo -u postgres psql -t -c "SHOW server_version;" | xargs) +echo "PostgreSQL actual version: ${PG_ACTUAL_VERSION}" +PG_MAJOR_VERSION=$(echo ${PG_ACTUAL_VERSION} | cut -d. -f1) +echo "PostgreSQL major version: ${PG_MAJOR_VERSION}" echo "Installing pgvector..." # First try installing from package @@ -47,12 +51,24 @@ echo "local all all trust" | sudo tee -a /etc/postgresql/${PG_VERSION}/main/pg_h # Restart PostgreSQL to ensure pgvector is loaded sudo systemctl restart postgresql +# Create symbolic link for extension files if needed +sudo ln -sf /usr/share/postgresql/${PG_VERSION}/extension/vector* /usr/share/postgresql/${PG_MAJOR_VERSION}/extension/ || true +sudo ln -sf /usr/lib/postgresql/${PG_VERSION}/lib/vector.so /usr/lib/postgresql/${PG_MAJOR_VERSION}/lib/ || true + # Verify pgvector installation echo "Verifying pgvector installation..." +echo "Installed extensions:" sudo -u postgres psql -d postgres -c "SELECT * FROM pg_extension;" || true +echo "Available extensions:" sudo -u postgres psql -d postgres -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';" || true # List extension directory contents echo "Checking extension files..." +echo "PostgreSQL ${PG_VERSION} extension directory:" ls -la /usr/share/postgresql/${PG_VERSION}/extension/ || true +echo "PostgreSQL ${PG_MAJOR_VERSION} extension directory:" +ls -la /usr/share/postgresql/${PG_MAJOR_VERSION}/extension/ || true +echo "PostgreSQL ${PG_VERSION} lib directory:" ls -la /usr/lib/postgresql/${PG_VERSION}/lib/ || true +echo "PostgreSQL ${PG_MAJOR_VERSION} lib directory:" +ls -la /usr/lib/postgresql/${PG_MAJOR_VERSION}/lib/ || true diff --git a/scripts/install-windows.sh b/scripts/install-windows.sh new file mode 100644 index 0000000..86bb323 --- /dev/null +++ b/scripts/install-windows.sh @@ -0,0 +1,47 @@ +#!/bin/bash +set -e + +PG_VERSION=$1 +PGVECTOR_VERSION=$2 + +# Install PostgreSQL and build tools via MSYS2 +pacman -Syu --noconfirm +pacman -S --noconfirm \ + mingw-w64-x86_64-postgresql${PG_VERSION} \ + mingw-w64-x86_64-gcc \ + mingw-w64-x86_64-make \ + git + +# Add PostgreSQL binaries to PATH +MSYS2_PATH="/c/msys64/mingw64" +echo "${MSYS2_PATH}/bin" >> $GITHUB_PATH +echo "${MSYS2_PATH}/lib" >> $GITHUB_PATH + +# Initialize PostgreSQL database +export PGDATA=/c/msys64/home/$USER/pgdata +export PGHOST=/tmp +mkdir -p $PGDATA +initdb -U postgres --encoding=UTF8 --locale=C + +# Configure PostgreSQL +echo "local all postgres trust" > $PGDATA/pg_hba.conf +echo "local all all trust" >> $PGDATA/pg_hba.conf + +# Start PostgreSQL +pg_ctl -D $PGDATA -l logfile start + +# Build and install pgvector +git clone --branch v${PGVECTOR_VERSION} https://github.com/pgvector/pgvector.git +cd pgvector +make clean +make +make install +cd .. +rm -rf pgvector + +# Create test database +createdb -U postgres postgres + +# Verify installation +psql -U postgres -d postgres -c "SELECT version();" +psql -U postgres -d postgres -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';" From 9672c534669f57a679181088e19c47c7b4b6fe8d Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 15:23:16 +0800 Subject: [PATCH 12/32] try fix --- action.yml | 5 +++-- scripts/install-macos.sh | 25 +++++++++++++++++++++-- scripts/install-ubuntu.sh | 41 +++++++++++++++----------------------- scripts/install-windows.sh | 14 ++++++++++--- 4 files changed, 53 insertions(+), 32 deletions(-) diff --git a/action.yml b/action.yml index 798cbfa..ef31272 100644 --- a/action.yml +++ b/action.yml @@ -30,5 +30,6 @@ runs: if: runner.os == 'Windows' shell: bash run: | - chmod +x ${{ github.action_path }}/scripts/install-windows.sh - ${{ github.action_path }}/scripts/install-windows.sh ${{ inputs.postgres-version }} ${{ inputs.pgvector-version }} + SCRIPT_PATH=$(echo "${{ github.action_path }}/scripts/install-windows.sh" | sed 's/\\/\//g') + chmod +x "$SCRIPT_PATH" + "$SCRIPT_PATH" ${{ inputs.postgres-version }} ${{ inputs.pgvector-version }} diff --git a/scripts/install-macos.sh b/scripts/install-macos.sh index 8ed67b2..13c84e6 100644 --- a/scripts/install-macos.sh +++ b/scripts/install-macos.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -e +set -ex PG_VERSION=$1 @@ -10,5 +10,26 @@ echo "/usr/local/opt/postgresql@${PG_VERSION}/bin" >> $GITHUB_PATH brew services start postgresql@${PG_VERSION} sleep 3 # wait for PostgreSQL to start +# Get PostgreSQL version +PG_ACTUAL_VERSION=$(psql postgres -t -c "SHOW server_version;" | xargs) +echo "PostgreSQL actual version: ${PG_ACTUAL_VERSION}" +PG_MAJOR_VERSION=$(echo ${PG_ACTUAL_VERSION} | cut -d. -f1) +echo "PostgreSQL major version: ${PG_MAJOR_VERSION}" + createdb $USER || true -brew install pgvector + +# Build and install pgvector from source +brew install gcc make +git clone --branch v${PGVECTOR_VERSION} https://github.com/pgvector/pgvector.git +cd pgvector +make clean +PG_CONFIG=/usr/local/opt/postgresql@${PG_VERSION}/bin/pg_config make +sudo PG_CONFIG=/usr/local/opt/postgresql@${PG_VERSION}/bin/pg_config make install +cd .. +rm -rf pgvector + +# Verify installation +echo "Checking PostgreSQL installation..." +psql postgres -c "SELECT version();" +echo "Checking available extensions..." +psql postgres -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';" diff --git a/scripts/install-ubuntu.sh b/scripts/install-ubuntu.sh index a0837c3..984b4ef 100644 --- a/scripts/install-ubuntu.sh +++ b/scripts/install-ubuntu.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -e +set -ex PG_VERSION=$1 PGVECTOR_VERSION=$2 @@ -25,23 +25,22 @@ echo "PostgreSQL actual version: ${PG_ACTUAL_VERSION}" PG_MAJOR_VERSION=$(echo ${PG_ACTUAL_VERSION} | cut -d. -f1) echo "PostgreSQL major version: ${PG_MAJOR_VERSION}" -echo "Installing pgvector..." -# First try installing from package -sudo apt-get install -y postgresql-${PG_VERSION}-pgvector -PGVECTOR_INSTALLED=$? +# Remove any existing pgvector installations +sudo apt-get remove -y postgresql-*-pgvector || true +sudo rm -f /usr/lib/postgresql/*/lib/vector.so +sudo rm -f /usr/share/postgresql/*/extension/vector* -# If package installation fails, build from source -if [ $PGVECTOR_INSTALLED -ne 0 ]; then - echo "Building pgvector from source..." - sudo apt-get install -y postgresql-server-dev-${PG_VERSION} build-essential git - git clone --branch v${PGVECTOR_VERSION} https://github.com/pgvector/pgvector.git - cd pgvector - make clean - make - sudo make install - cd .. - rm -rf pgvector -fi +echo "Installing pgvector..." +# Always build from source to match PostgreSQL version +echo "Building pgvector from source..." +sudo apt-get install -y postgresql-server-dev-${PG_MAJOR_VERSION} build-essential git +git clone --branch v${PGVECTOR_VERSION} https://github.com/pgvector/pgvector.git +cd pgvector +make clean +PG_CONFIG=/usr/lib/postgresql/${PG_MAJOR_VERSION}/bin/pg_config make +sudo PG_CONFIG=/usr/lib/postgresql/${PG_MAJOR_VERSION}/bin/pg_config make install +cd .. +rm -rf pgvector # Configure PostgreSQL authentication for CI echo "local all postgres trust" | sudo tee /etc/postgresql/${PG_VERSION}/main/pg_hba.conf @@ -51,10 +50,6 @@ echo "local all all trust" | sudo tee -a /etc/postgresql/${PG_VERSION}/main/pg_h # Restart PostgreSQL to ensure pgvector is loaded sudo systemctl restart postgresql -# Create symbolic link for extension files if needed -sudo ln -sf /usr/share/postgresql/${PG_VERSION}/extension/vector* /usr/share/postgresql/${PG_MAJOR_VERSION}/extension/ || true -sudo ln -sf /usr/lib/postgresql/${PG_VERSION}/lib/vector.so /usr/lib/postgresql/${PG_MAJOR_VERSION}/lib/ || true - # Verify pgvector installation echo "Verifying pgvector installation..." echo "Installed extensions:" @@ -64,11 +59,7 @@ sudo -u postgres psql -d postgres -c "SELECT * FROM pg_available_extensions WHER # List extension directory contents echo "Checking extension files..." -echo "PostgreSQL ${PG_VERSION} extension directory:" -ls -la /usr/share/postgresql/${PG_VERSION}/extension/ || true echo "PostgreSQL ${PG_MAJOR_VERSION} extension directory:" ls -la /usr/share/postgresql/${PG_MAJOR_VERSION}/extension/ || true -echo "PostgreSQL ${PG_VERSION} lib directory:" -ls -la /usr/lib/postgresql/${PG_VERSION}/lib/ || true echo "PostgreSQL ${PG_MAJOR_VERSION} lib directory:" ls -la /usr/lib/postgresql/${PG_MAJOR_VERSION}/lib/ || true diff --git a/scripts/install-windows.sh b/scripts/install-windows.sh index 86bb323..bac0b14 100644 --- a/scripts/install-windows.sh +++ b/scripts/install-windows.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -e +set -ex PG_VERSION=$1 PGVECTOR_VERSION=$2 @@ -30,12 +30,18 @@ echo "local all all trust" >> $PGDATA/pg_hba.conf # Start PostgreSQL pg_ctl -D $PGDATA -l logfile start +# Get PostgreSQL version +PG_ACTUAL_VERSION=$(psql -U postgres -t -c "SHOW server_version;" | xargs) +echo "PostgreSQL actual version: ${PG_ACTUAL_VERSION}" +PG_MAJOR_VERSION=$(echo ${PG_ACTUAL_VERSION} | cut -d. -f1) +echo "PostgreSQL major version: ${PG_MAJOR_VERSION}" + # Build and install pgvector git clone --branch v${PGVECTOR_VERSION} https://github.com/pgvector/pgvector.git cd pgvector make clean -make -make install +PATH="${MSYS2_PATH}/bin:$PATH" PG_CONFIG="${MSYS2_PATH}/bin/pg_config" make +PATH="${MSYS2_PATH}/bin:$PATH" PG_CONFIG="${MSYS2_PATH}/bin/pg_config" make install cd .. rm -rf pgvector @@ -43,5 +49,7 @@ rm -rf pgvector createdb -U postgres postgres # Verify installation +echo "Checking PostgreSQL installation..." psql -U postgres -d postgres -c "SELECT version();" +echo "Checking available extensions..." psql -U postgres -d postgres -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';" From 8e9cb4003718a30d01ea2f2676f0535fa5fe3eb2 Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 15:25:39 +0800 Subject: [PATCH 13/32] try fix --- action.yml | 14 +++++++++++++- scripts/install-windows.sh | 8 -------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/action.yml b/action.yml index ef31272..3c96e0d 100644 --- a/action.yml +++ b/action.yml @@ -26,9 +26,21 @@ runs: chmod +x ${{ github.action_path }}/scripts/install-macos.sh ${{ github.action_path }}/scripts/install-macos.sh ${{ inputs.postgres-version }} + - name: Setup MSYS2 + if: runner.os == 'Windows' + uses: msys2/setup-msys2@v2 + with: + msystem: MINGW64 + update: true + install: >- + mingw-w64-x86_64-postgresql + mingw-w64-x86_64-gcc + mingw-w64-x86_64-make + git + - name: Install and Configure PostgreSQL on Windows if: runner.os == 'Windows' - shell: bash + shell: msys2 {0} run: | SCRIPT_PATH=$(echo "${{ github.action_path }}/scripts/install-windows.sh" | sed 's/\\/\//g') chmod +x "$SCRIPT_PATH" diff --git a/scripts/install-windows.sh b/scripts/install-windows.sh index bac0b14..8a65545 100644 --- a/scripts/install-windows.sh +++ b/scripts/install-windows.sh @@ -4,14 +4,6 @@ set -ex PG_VERSION=$1 PGVECTOR_VERSION=$2 -# Install PostgreSQL and build tools via MSYS2 -pacman -Syu --noconfirm -pacman -S --noconfirm \ - mingw-w64-x86_64-postgresql${PG_VERSION} \ - mingw-w64-x86_64-gcc \ - mingw-w64-x86_64-make \ - git - # Add PostgreSQL binaries to PATH MSYS2_PATH="/c/msys64/mingw64" echo "${MSYS2_PATH}/bin" >> $GITHUB_PATH From aaedd5915197f25b115a8e1a6a5deeee13f497be Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 15:28:06 +0800 Subject: [PATCH 14/32] try fix --- action.yml | 6 ++++++ scripts/install-macos.sh | 23 +---------------------- scripts/install-windows.sh | 9 ++++----- 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/action.yml b/action.yml index 3c96e0d..d34611f 100644 --- a/action.yml +++ b/action.yml @@ -36,11 +36,17 @@ runs: mingw-w64-x86_64-postgresql mingw-w64-x86_64-gcc mingw-w64-x86_64-make + mingw-w64-x86_64-tools-git + make + diffutils git - name: Install and Configure PostgreSQL on Windows if: runner.os == 'Windows' shell: msys2 {0} + env: + MSYSTEM: MINGW64 + CHERE_INVOKING: 1 run: | SCRIPT_PATH=$(echo "${{ github.action_path }}/scripts/install-windows.sh" | sed 's/\\/\//g') chmod +x "$SCRIPT_PATH" diff --git a/scripts/install-macos.sh b/scripts/install-macos.sh index 13c84e6..0bf00f6 100644 --- a/scripts/install-macos.sh +++ b/scripts/install-macos.sh @@ -10,26 +10,5 @@ echo "/usr/local/opt/postgresql@${PG_VERSION}/bin" >> $GITHUB_PATH brew services start postgresql@${PG_VERSION} sleep 3 # wait for PostgreSQL to start -# Get PostgreSQL version -PG_ACTUAL_VERSION=$(psql postgres -t -c "SHOW server_version;" | xargs) -echo "PostgreSQL actual version: ${PG_ACTUAL_VERSION}" -PG_MAJOR_VERSION=$(echo ${PG_ACTUAL_VERSION} | cut -d. -f1) -echo "PostgreSQL major version: ${PG_MAJOR_VERSION}" - createdb $USER || true - -# Build and install pgvector from source -brew install gcc make -git clone --branch v${PGVECTOR_VERSION} https://github.com/pgvector/pgvector.git -cd pgvector -make clean -PG_CONFIG=/usr/local/opt/postgresql@${PG_VERSION}/bin/pg_config make -sudo PG_CONFIG=/usr/local/opt/postgresql@${PG_VERSION}/bin/pg_config make install -cd .. -rm -rf pgvector - -# Verify installation -echo "Checking PostgreSQL installation..." -psql postgres -c "SELECT version();" -echo "Checking available extensions..." -psql postgres -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';" +brew install pgvector diff --git a/scripts/install-windows.sh b/scripts/install-windows.sh index 8a65545..062867b 100644 --- a/scripts/install-windows.sh +++ b/scripts/install-windows.sh @@ -5,9 +5,8 @@ PG_VERSION=$1 PGVECTOR_VERSION=$2 # Add PostgreSQL binaries to PATH -MSYS2_PATH="/c/msys64/mingw64" -echo "${MSYS2_PATH}/bin" >> $GITHUB_PATH -echo "${MSYS2_PATH}/lib" >> $GITHUB_PATH +export PATH="/mingw64/bin:$PATH" +export PKG_CONFIG_PATH="/mingw64/lib/pkgconfig:$PKG_CONFIG_PATH" # Initialize PostgreSQL database export PGDATA=/c/msys64/home/$USER/pgdata @@ -32,8 +31,8 @@ echo "PostgreSQL major version: ${PG_MAJOR_VERSION}" git clone --branch v${PGVECTOR_VERSION} https://github.com/pgvector/pgvector.git cd pgvector make clean -PATH="${MSYS2_PATH}/bin:$PATH" PG_CONFIG="${MSYS2_PATH}/bin/pg_config" make -PATH="${MSYS2_PATH}/bin:$PATH" PG_CONFIG="${MSYS2_PATH}/bin/pg_config" make install +PG_CONFIG=/mingw64/bin/pg_config make +PG_CONFIG=/mingw64/bin/pg_config make install cd .. rm -rf pgvector From d9b834ed65f1ff0b2f8f3aab8c6a3943acf78fc4 Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 15:31:44 +0800 Subject: [PATCH 15/32] try fix --- scripts/install-windows.sh | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/scripts/install-windows.sh b/scripts/install-windows.sh index 062867b..279e7d3 100644 --- a/scripts/install-windows.sh +++ b/scripts/install-windows.sh @@ -9,25 +9,39 @@ export PATH="/mingw64/bin:$PATH" export PKG_CONFIG_PATH="/mingw64/lib/pkgconfig:$PKG_CONFIG_PATH" # Initialize PostgreSQL database -export PGDATA=/c/msys64/home/$USER/pgdata -export PGHOST=/tmp +export PGDATA=/c/data/postgres +export PGHOST=localhost +export PGUSER=postgres mkdir -p $PGDATA -initdb -U postgres --encoding=UTF8 --locale=C + +echo "Initializing PostgreSQL database..." +initdb -U postgres --encoding=UTF8 --locale=C --auth=trust # Configure PostgreSQL -echo "local all postgres trust" > $PGDATA/pg_hba.conf -echo "local all all trust" >> $PGDATA/pg_hba.conf +echo "host all all 127.0.0.1/32 trust" >> $PGDATA/pg_hba.conf +echo "host all all ::1/128 trust" >> $PGDATA/pg_hba.conf + +# Configure postgresql.conf +echo "unix_socket_directories = '$PGDATA'" >> $PGDATA/postgresql.conf +echo "listen_addresses = 'localhost'" >> $PGDATA/postgresql.conf # Start PostgreSQL -pg_ctl -D $PGDATA -l logfile start +echo "Starting PostgreSQL..." +pg_ctl -D $PGDATA -l $PGDATA/logfile start +sleep 3 # Wait for PostgreSQL to start + +# Verify PostgreSQL is running +echo "Verifying PostgreSQL connection..." +psql -h localhost -U postgres -c "SELECT version();" # Get PostgreSQL version -PG_ACTUAL_VERSION=$(psql -U postgres -t -c "SHOW server_version;" | xargs) +PG_ACTUAL_VERSION=$(psql -h localhost -U postgres -t -c "SHOW server_version;" | xargs) echo "PostgreSQL actual version: ${PG_ACTUAL_VERSION}" PG_MAJOR_VERSION=$(echo ${PG_ACTUAL_VERSION} | cut -d. -f1) echo "PostgreSQL major version: ${PG_MAJOR_VERSION}" # Build and install pgvector +echo "Building pgvector..." git clone --branch v${PGVECTOR_VERSION} https://github.com/pgvector/pgvector.git cd pgvector make clean @@ -37,10 +51,11 @@ cd .. rm -rf pgvector # Create test database -createdb -U postgres postgres +echo "Creating test database..." +createdb -h localhost -U postgres postgres # Verify installation echo "Checking PostgreSQL installation..." -psql -U postgres -d postgres -c "SELECT version();" +psql -h localhost -U postgres -d postgres -c "SELECT version();" echo "Checking available extensions..." -psql -U postgres -d postgres -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';" +psql -h localhost -U postgres -d postgres -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';" From 064a5f99bf3c5583f30850593d0c5a30579aece7 Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 15:34:17 +0800 Subject: [PATCH 16/32] try fix --- scripts/install-windows.sh | 61 +++++++++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 7 deletions(-) diff --git a/scripts/install-windows.sh b/scripts/install-windows.sh index 279e7d3..de2645e 100644 --- a/scripts/install-windows.sh +++ b/scripts/install-windows.sh @@ -12,27 +12,74 @@ export PKG_CONFIG_PATH="/mingw64/lib/pkgconfig:$PKG_CONFIG_PATH" export PGDATA=/c/data/postgres export PGHOST=localhost export PGUSER=postgres +rm -rf $PGDATA mkdir -p $PGDATA echo "Initializing PostgreSQL database..." initdb -U postgres --encoding=UTF8 --locale=C --auth=trust # Configure PostgreSQL -echo "host all all 127.0.0.1/32 trust" >> $PGDATA/pg_hba.conf -echo "host all all ::1/128 trust" >> $PGDATA/pg_hba.conf +cat > $PGDATA/pg_hba.conf << EOL +# TYPE DATABASE USER ADDRESS METHOD +local all all trust +host all all 127.0.0.1/32 trust +host all all ::1/128 trust +EOL # Configure postgresql.conf -echo "unix_socket_directories = '$PGDATA'" >> $PGDATA/postgresql.conf -echo "listen_addresses = 'localhost'" >> $PGDATA/postgresql.conf +cat > $PGDATA/postgresql.conf << EOL +listen_addresses = 'localhost' +port = 5432 +max_connections = 100 +shared_buffers = 128MB +dynamic_shared_memory_type = windows +max_wal_size = 1GB +min_wal_size = 80MB +log_destination = 'stderr' +logging_collector = on +log_directory = 'log' +log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' +log_rotation_age = 1d +log_rotation_size = 10MB +log_min_messages = warning +log_min_error_statement = error +log_min_duration_statement = 1000 +client_min_messages = notice +log_connections = on +log_disconnections = on +log_duration = on +log_line_prefix = '%m [%p] ' +log_timezone = 'UTC' +datestyle = 'iso, mdy' +timezone = 'UTC' +lc_messages = 'C' +lc_monetary = 'C' +lc_numeric = 'C' +lc_time = 'C' +default_text_search_config = 'pg_catalog.english' +EOL + +# Create log directory +mkdir -p $PGDATA/log # Start PostgreSQL echo "Starting PostgreSQL..." -pg_ctl -D $PGDATA -l $PGDATA/logfile start -sleep 3 # Wait for PostgreSQL to start +pg_ctl -D $PGDATA -w start + +# Wait and check the log +sleep 3 +echo "PostgreSQL log content:" +cat $PGDATA/log/postgresql-*.log || true # Verify PostgreSQL is running echo "Verifying PostgreSQL connection..." -psql -h localhost -U postgres -c "SELECT version();" +for i in {1..5}; do + if psql -h localhost -U postgres -c "SELECT version();" 2>/dev/null; then + break + fi + echo "Waiting for PostgreSQL to start (attempt $i)..." + sleep 2 +done # Get PostgreSQL version PG_ACTUAL_VERSION=$(psql -h localhost -U postgres -t -c "SHOW server_version;" | xargs) From 7a0530e02718dab9fe00132f99a11a24cc777b07 Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 15:36:59 +0800 Subject: [PATCH 17/32] try fix --- scripts/install-windows.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/install-windows.sh b/scripts/install-windows.sh index de2645e..4d6922c 100644 --- a/scripts/install-windows.sh +++ b/scripts/install-windows.sh @@ -97,12 +97,14 @@ PG_CONFIG=/mingw64/bin/pg_config make install cd .. rm -rf pgvector -# Create test database -echo "Creating test database..." -createdb -h localhost -U postgres postgres +# Create and configure pgvector extension +echo "Creating pgvector extension..." +psql -h localhost -U postgres -d postgres -c "CREATE EXTENSION IF NOT EXISTS vector;" # Verify installation echo "Checking PostgreSQL installation..." psql -h localhost -U postgres -d postgres -c "SELECT version();" echo "Checking available extensions..." psql -h localhost -U postgres -d postgres -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';" +echo "Checking installed extensions..." +psql -h localhost -U postgres -d postgres -c "SELECT * FROM pg_extension WHERE extname = 'vector';" From a07e936d7bdf8435872e3999c19329952b186c0f Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 15:45:50 +0800 Subject: [PATCH 18/32] try fix --- .github/workflows/ci.yml | 6 +++--- action.yml | 11 +++++++++-- scripts/install-windows.sh | 9 +++++++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e5751f3..9d84534 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,15 +28,15 @@ jobs: postgres-version: '17' runs-on: ${{ matrix.os }} - + steps: - uses: actions/checkout@v4 - + - name: Setup pgvector uses: ./ with: postgres-version: ${{ matrix.postgres-version }} - + - name: Test Extension run: | psql -d postgres -c 'CREATE EXTENSION vector;' diff --git a/action.yml b/action.yml index d34611f..f04320b 100644 --- a/action.yml +++ b/action.yml @@ -1,5 +1,5 @@ name: 'Setup pgvector' -description: 'Setup pgvector extension for PostgreSQL' +description: 'Setup pgvector in GitHub Actions' inputs: postgres-version: description: 'PostgreSQL version to use' @@ -24,7 +24,7 @@ runs: shell: bash run: | chmod +x ${{ github.action_path }}/scripts/install-macos.sh - ${{ github.action_path }}/scripts/install-macos.sh ${{ inputs.postgres-version }} + ${{ github.action_path }}/scripts/install-macos.sh ${{ inputs.postgres-version }} ${{ inputs.pgvector-version }} - name: Setup MSYS2 if: runner.os == 'Windows' @@ -41,6 +41,13 @@ runs: diffutils git + - name: Add MSYS2 to PATH + if: runner.os == 'Windows' + shell: pwsh + run: | + echo "D:\a\_temp\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + echo "D:\a\_temp\msys64\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + - name: Install and Configure PostgreSQL on Windows if: runner.os == 'Windows' shell: msys2 {0} diff --git a/scripts/install-windows.sh b/scripts/install-windows.sh index 4d6922c..b8b27a0 100644 --- a/scripts/install-windows.sh +++ b/scripts/install-windows.sh @@ -12,6 +12,8 @@ export PKG_CONFIG_PATH="/mingw64/lib/pkgconfig:$PKG_CONFIG_PATH" export PGDATA=/c/data/postgres export PGHOST=localhost export PGUSER=postgres + +# Ensure data directory exists and is empty rm -rf $PGDATA mkdir -p $PGDATA @@ -84,8 +86,6 @@ done # Get PostgreSQL version PG_ACTUAL_VERSION=$(psql -h localhost -U postgres -t -c "SHOW server_version;" | xargs) echo "PostgreSQL actual version: ${PG_ACTUAL_VERSION}" -PG_MAJOR_VERSION=$(echo ${PG_ACTUAL_VERSION} | cut -d. -f1) -echo "PostgreSQL major version: ${PG_MAJOR_VERSION}" # Build and install pgvector echo "Building pgvector..." @@ -101,6 +101,11 @@ rm -rf pgvector echo "Creating pgvector extension..." psql -h localhost -U postgres -d postgres -c "CREATE EXTENSION IF NOT EXISTS vector;" +# Export environment variables for PowerShell +echo "PGDATA=$PGDATA" >> $GITHUB_ENV +echo "PGHOST=$PGHOST" >> $GITHUB_ENV +echo "PGUSER=$PGUSER" >> $GITHUB_ENV + # Verify installation echo "Checking PostgreSQL installation..." psql -h localhost -U postgres -d postgres -c "SELECT version();" From 751a48be6d679efdd5c9adc0b969cc64edd8c59e Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 15:51:01 +0800 Subject: [PATCH 19/32] try fix --- .github/workflows/ci.yml | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9d84534..ced9df2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,18 +28,38 @@ jobs: postgres-version: '17' runs-on: ${{ matrix.os }} - + steps: - uses: actions/checkout@v4 - + - name: Setup pgvector uses: ./ with: postgres-version: ${{ matrix.postgres-version }} + + - name: Test Extension (Unix) + if: runner.os != 'Windows' + run: | + psql -d postgres -c 'CREATE EXTENSION IF NOT EXISTS vector;' + psql -d postgres -c 'CREATE TABLE IF NOT EXISTS items (id bigserial PRIMARY KEY, embedding vector(3));' + psql -d postgres -c "INSERT INTO items (embedding) VALUES ('[1,2,3]');" + psql -d postgres -c 'SELECT * FROM items;' - - name: Test Extension + - name: Setup Test Data (Windows) + if: runner.os == 'Windows' + shell: pwsh run: | - psql -d postgres -c 'CREATE EXTENSION vector;' - psql -d postgres -c 'CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3));' - psql -d postgres -c 'INSERT INTO items (embedding) VALUES ('\''[1,2,3]'\'');' + psql -d postgres -c 'CREATE EXTENSION IF NOT EXISTS vector;' + psql -d postgres -c 'CREATE TABLE IF NOT EXISTS items (id bigserial PRIMARY KEY, embedding vector(3));' + psql -d postgres -c "INSERT INTO items (embedding) VALUES ('[1,2,3]');" psql -d postgres -c 'SELECT * FROM items;' + + - name: Test Query (Windows CMD) + if: runner.os == 'Windows' + shell: cmd + run: psql -d postgres -c "SELECT * FROM items;" + + - name: Test Query (Windows MSYS2) + if: runner.os == 'Windows' + shell: msys2 {0} + run: psql -d postgres -c 'SELECT * FROM items;' From 65988e5001859f264a8877be4967317b4b88eb53 Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 15:56:04 +0800 Subject: [PATCH 20/32] try fix --- .github/workflows/ci.yml | 48 +++++++++++++++-------- README.md | 36 +++++++++++++++++ action.yml | 33 ++++++++++++++-- scripts/install-macos.sh | 58 ++++++++++++++++++++++++---- scripts/install-pgvector-windows.bat | 19 --------- scripts/install-ubuntu.sh | 40 ++++++++++++++++++- scripts/install-windows.ps1 | 17 -------- scripts/install-windows.sh | 47 +++++++++++----------- 8 files changed, 209 insertions(+), 89 deletions(-) delete mode 100644 scripts/install-pgvector-windows.bat delete mode 100644 scripts/install-windows.ps1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ced9df2..c0abdd7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,38 +28,54 @@ jobs: postgres-version: '17' runs-on: ${{ matrix.os }} - + steps: - uses: actions/checkout@v4 - + - name: Setup pgvector uses: ./ with: postgres-version: ${{ matrix.postgres-version }} - + postgres-user: testuser + postgres-password: testpass + postgres-db: testdb + - name: Test Extension (Unix) if: runner.os != 'Windows' + env: + PGUSER: testuser + PGPASSWORD: testpass + PGDATABASE: testdb run: | - psql -d postgres -c 'CREATE EXTENSION IF NOT EXISTS vector;' - psql -d postgres -c 'CREATE TABLE IF NOT EXISTS items (id bigserial PRIMARY KEY, embedding vector(3));' - psql -d postgres -c "INSERT INTO items (embedding) VALUES ('[1,2,3]');" - psql -d postgres -c 'SELECT * FROM items;' + psql -c 'CREATE EXTENSION IF NOT EXISTS vector;' + psql -c 'CREATE TABLE IF NOT EXISTS items (id bigserial PRIMARY KEY, embedding vector(3));' + psql -c "INSERT INTO items (embedding) VALUES ('[1,2,3]');" + psql -c 'SELECT * FROM items;' - - name: Setup Test Data (Windows) + - name: Test Extension (Windows PowerShell) if: runner.os == 'Windows' shell: pwsh + env: + PGUSER: testuser + PGPASSWORD: testpass + PGDATABASE: testdb run: | - psql -d postgres -c 'CREATE EXTENSION IF NOT EXISTS vector;' - psql -d postgres -c 'CREATE TABLE IF NOT EXISTS items (id bigserial PRIMARY KEY, embedding vector(3));' - psql -d postgres -c "INSERT INTO items (embedding) VALUES ('[1,2,3]');" - psql -d postgres -c 'SELECT * FROM items;' + psql -c 'SELECT * FROM items;' - - name: Test Query (Windows CMD) + - name: Test Extension (Windows CMD) if: runner.os == 'Windows' shell: cmd - run: psql -d postgres -c "SELECT * FROM items;" + env: + PGUSER: testuser + PGPASSWORD: testpass + PGDATABASE: testdb + run: psql -c "SELECT * FROM items;" - - name: Test Query (Windows MSYS2) + - name: Test Extension (Windows MSYS2) if: runner.os == 'Windows' shell: msys2 {0} - run: psql -d postgres -c 'SELECT * FROM items;' + env: + PGUSER: testuser + PGPASSWORD: testpass + PGDATABASE: testdb + run: psql -c 'SELECT * FROM items;' diff --git a/README.md b/README.md index 31bdbec..5674d2e 100644 --- a/README.md +++ b/README.md @@ -11,12 +11,18 @@ steps: with: postgres-version: '17' # optional, defaults to 17. Use 14 for ubuntu-22.04 and ubuntu-20.04 pgvector-version: '0.8.0' # optional, defaults to 0.8.0 + postgres-user: 'myuser' # optional, defaults to 'postgres' + postgres-password: 'mypassword' # optional, defaults to 'postgres' + postgres-db: 'mydb' # optional, defaults to 'postgres' ``` ## Inputs - `postgres-version`: PostgreSQL version to use (default: '17'). Note: Use '14' for ubuntu-22.04 and ubuntu-20.04. - `pgvector-version`: pgvector version to install (default: '0.8.0') +- `postgres-user`: PostgreSQL user to create (default: 'postgres') +- `postgres-password`: PostgreSQL user password (default: 'postgres') +- `postgres-db`: PostgreSQL database to create (default: 'postgres') ## Platform Support @@ -50,9 +56,19 @@ jobs: with: postgres-version: '17' # Use '14' for ubuntu-22.04 and ubuntu-20.04 pgvector-version: '0.8.0' + postgres-user: 'myuser' + postgres-password: 'mypassword' + postgres-db: 'mydb' - name: Create extension run: | sudo -u postgres psql -c 'CREATE EXTENSION vector;' + - name: Test Connection + env: + PGUSER: myuser + PGPASSWORD: mypassword + PGDATABASE: mydb + run: | + psql -c 'SELECT version();' ``` ### macOS @@ -70,9 +86,19 @@ jobs: uses: cpunion/setup-pgvector@v1 with: pgvector-version: '0.8.0' + postgres-user: 'myuser' + postgres-password: 'mypassword' + postgres-db: 'mydb' - name: Create extension run: | psql postgres -c 'CREATE EXTENSION vector;' + - name: Test Connection + env: + PGUSER: myuser + PGPASSWORD: mypassword + PGDATABASE: mydb + run: | + psql -c 'SELECT version();' ``` ### Windows @@ -93,10 +119,20 @@ jobs: uses: cpunion/setup-pgvector@v1 with: pgvector-version: '0.8.0' + postgres-user: 'myuser' + postgres-password: 'mypassword' + postgres-db: 'mydb' - name: Create extension shell: cmd run: | psql -U postgres -c "CREATE EXTENSION vector;" + - name: Test Connection + env: + PGUSER: myuser + PGPASSWORD: mypassword + PGDATABASE: mydb + run: | + psql -c "SELECT version();" ``` ## License diff --git a/action.yml b/action.yml index f04320b..bf39919 100644 --- a/action.yml +++ b/action.yml @@ -9,6 +9,18 @@ inputs: description: 'pgvector version to install' required: false default: '0.8.0' + postgres-user: + description: 'PostgreSQL user to create' + required: false + default: 'postgres' + postgres-password: + description: 'PostgreSQL user password' + required: false + default: 'postgres' + postgres-db: + description: 'PostgreSQL database to create' + required: false + default: 'postgres' runs: using: "composite" steps: @@ -17,14 +29,24 @@ runs: shell: bash run: | chmod +x ${{ github.action_path }}/scripts/install-ubuntu.sh - ${{ github.action_path }}/scripts/install-ubuntu.sh ${{ inputs.postgres-version }} ${{ inputs.pgvector-version }} + ${{ github.action_path }}/scripts/install-ubuntu.sh \ + ${{ inputs.postgres-version }} \ + ${{ inputs.pgvector-version }} \ + ${{ inputs.postgres-user }} \ + ${{ inputs.postgres-password }} \ + ${{ inputs.postgres-db }} - name: Install and Configure PostgreSQL on macOS if: runner.os == 'macOS' shell: bash run: | chmod +x ${{ github.action_path }}/scripts/install-macos.sh - ${{ github.action_path }}/scripts/install-macos.sh ${{ inputs.postgres-version }} ${{ inputs.pgvector-version }} + ${{ github.action_path }}/scripts/install-macos.sh \ + ${{ inputs.postgres-version }} \ + ${{ inputs.pgvector-version }} \ + ${{ inputs.postgres-user }} \ + ${{ inputs.postgres-password }} \ + ${{ inputs.postgres-db }} - name: Setup MSYS2 if: runner.os == 'Windows' @@ -57,4 +79,9 @@ runs: run: | SCRIPT_PATH=$(echo "${{ github.action_path }}/scripts/install-windows.sh" | sed 's/\\/\//g') chmod +x "$SCRIPT_PATH" - "$SCRIPT_PATH" ${{ inputs.postgres-version }} ${{ inputs.pgvector-version }} + "$SCRIPT_PATH" \ + ${{ inputs.postgres-version }} \ + ${{ inputs.pgvector-version }} \ + ${{ inputs.postgres-user }} \ + ${{ inputs.postgres-password }} \ + ${{ inputs.postgres-db }} diff --git a/scripts/install-macos.sh b/scripts/install-macos.sh index 0bf00f6..d68a37d 100644 --- a/scripts/install-macos.sh +++ b/scripts/install-macos.sh @@ -1,14 +1,56 @@ #!/bin/bash set -ex -PG_VERSION=$1 +# Default versions if not provided +PG_VERSION=${1:-17} +PGVECTOR_VERSION=${2:-0.8.0} +PGUSER=${3:-postgres} +PGPASSWORD=${4:-postgres} +PGDATABASE=${5:-postgres} -brew install postgresql@${PG_VERSION} -brew link postgresql@${PG_VERSION} -echo "/usr/local/opt/postgresql@${PG_VERSION}/bin" >> $GITHUB_PATH +# Install PostgreSQL +brew install "postgresql@$PG_VERSION" +brew services start "postgresql@$PG_VERSION" -brew services start postgresql@${PG_VERSION} -sleep 3 # wait for PostgreSQL to start +# Add PostgreSQL binaries to PATH +export PATH="/opt/homebrew/opt/postgresql@$PG_VERSION/bin:$PATH" -createdb $USER || true -brew install pgvector +# Wait for PostgreSQL to start +sleep 3 + +# Set password and create database/user +createuser -s $PGUSER || true +psql -d postgres -c "ALTER USER $PGUSER WITH PASSWORD '$PGPASSWORD';" +if [ "$PGDATABASE" != "postgres" ]; then + createdb -O $PGUSER $PGDATABASE +fi + +# Build and install pgvector +git clone --branch "v$PGVECTOR_VERSION" https://github.com/pgvector/pgvector.git +cd pgvector +make +make install +cd .. +rm -rf pgvector + +# Create and configure pgvector extension +psql -d $PGDATABASE -c 'CREATE EXTENSION IF NOT EXISTS vector;' + +# Export environment variables +export PGHOST=localhost +export PGUSER=$PGUSER +export PGPASSWORD=$PGPASSWORD +export PGDATABASE=$PGDATABASE + +echo "PGHOST=$PGHOST" >> $GITHUB_ENV +echo "PGUSER=$PGUSER" >> $GITHUB_ENV +echo "PGPASSWORD=$PGPASSWORD" >> $GITHUB_ENV +echo "PGDATABASE=$PGDATABASE" >> $GITHUB_ENV + +# Verify installation +echo "Checking PostgreSQL installation..." +psql -d $PGDATABASE -c "SELECT version();" +echo "Checking available extensions..." +psql -d $PGDATABASE -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';" +echo "Checking installed extensions..." +psql -d $PGDATABASE -c "SELECT * FROM pg_extension WHERE extname = 'vector';" diff --git a/scripts/install-pgvector-windows.bat b/scripts/install-pgvector-windows.bat deleted file mode 100644 index f862cf0..0000000 --- a/scripts/install-pgvector-windows.bat +++ /dev/null @@ -1,19 +0,0 @@ -@echo off -setlocal - -set PG_VERSION=%1 -set PGVECTOR_VERSION=%2 -set VS_VERSION=%3 - -if "%VS_VERSION%"=="2019" ( - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" -) else ( - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" -) - -cd %TEMP% -git clone --branch v%PGVECTOR_VERSION% https://github.com/pgvector/pgvector.git -cd pgvector -set PATH=C:\Program Files\PostgreSQL\%PG_VERSION%\bin;C:\Program Files\PostgreSQL\%PG_VERSION%\lib;%PATH% -nmake /NOLOGO /F Makefile.win -nmake /NOLOGO /F Makefile.win install diff --git a/scripts/install-ubuntu.sh b/scripts/install-ubuntu.sh index 984b4ef..08a23e5 100644 --- a/scripts/install-ubuntu.sh +++ b/scripts/install-ubuntu.sh @@ -1,8 +1,12 @@ #!/bin/bash set -ex -PG_VERSION=$1 -PGVECTOR_VERSION=$2 +# Default versions if not provided +PG_VERSION=${1:-17} +PGVECTOR_VERSION=${2:-0.8.0} +PGUSER=${3:-postgres} +PGPASSWORD=${4:-postgres} +PGDATABASE=${5:-postgres} echo "Installing PostgreSQL ${PG_VERSION}..." sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y @@ -63,3 +67,35 @@ echo "PostgreSQL ${PG_MAJOR_VERSION} extension directory:" ls -la /usr/share/postgresql/${PG_MAJOR_VERSION}/extension/ || true echo "PostgreSQL ${PG_MAJOR_VERSION} lib directory:" ls -la /usr/lib/postgresql/${PG_MAJOR_VERSION}/lib/ || true + +# Set password and create database +sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '$PGPASSWORD';" +if [ "$PGUSER" != "postgres" ]; then + sudo -u postgres createuser -s $PGUSER + sudo -u postgres psql -c "ALTER USER $PGUSER WITH PASSWORD '$PGPASSWORD';" +fi +if [ "$PGDATABASE" != "postgres" ]; then + sudo -u postgres createdb -O $PGUSER $PGDATABASE +fi + +# Create and configure pgvector extension +sudo -u postgres psql -d $PGDATABASE -c "CREATE EXTENSION IF NOT EXISTS vector;" + +# Export environment variables +export PGHOST=localhost +export PGUSER=$PGUSER +export PGPASSWORD=$PGPASSWORD +export PGDATABASE=$PGDATABASE + +echo "PGHOST=$PGHOST" >> $GITHUB_ENV +echo "PGUSER=$PGUSER" >> $GITHUB_ENV +echo "PGPASSWORD=$PGPASSWORD" >> $GITHUB_ENV +echo "PGDATABASE=$PGDATABASE" >> $GITHUB_ENV + +# Verify installation +echo "Checking PostgreSQL installation..." +psql -d $PGDATABASE -c "SELECT version();" +echo "Checking available extensions..." +psql -d $PGDATABASE -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';" +echo "Checking installed extensions..." +psql -d $PGDATABASE -c "SELECT * FROM pg_extension WHERE extname = 'vector';" diff --git a/scripts/install-windows.ps1 b/scripts/install-windows.ps1 deleted file mode 100644 index 67ad2ca..0000000 --- a/scripts/install-windows.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -param( - [string]$PostgresVersion, - [string]$PgVectorVersion -) - -# Install PostgreSQL -choco install postgresql$PostgresVersion --params '/Password:postgres' -$pgPath = "C:\Program Files\PostgreSQL\$PostgresVersion" -echo "$pgPath\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append -echo "$pgPath\lib" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append -refreshenv - -# Start PostgreSQL service -Start-Service postgresql-x64-$PostgresVersion -Start-Sleep -s 3 # Wait for PostgreSQL to start -$env:PGPASSWORD = 'postgres' -psql -U postgres -c "SELECT version();" diff --git a/scripts/install-windows.sh b/scripts/install-windows.sh index b8b27a0..c44a5bf 100644 --- a/scripts/install-windows.sh +++ b/scripts/install-windows.sh @@ -1,8 +1,12 @@ #!/bin/bash set -ex -PG_VERSION=$1 -PGVECTOR_VERSION=$2 +# Default versions if not provided +PG_VERSION=${1:-17} +PGVECTOR_VERSION=${2:-0.8.0} +PGUSER=${3:-postgres} +PGPASSWORD=${4:-postgres} +PGDATABASE=${5:-postgres} # Add PostgreSQL binaries to PATH export PATH="/mingw64/bin:$PATH" @@ -11,21 +15,22 @@ export PKG_CONFIG_PATH="/mingw64/lib/pkgconfig:$PKG_CONFIG_PATH" # Initialize PostgreSQL database export PGDATA=/c/data/postgres export PGHOST=localhost -export PGUSER=postgres +export PGUSER=$PGUSER +export PGPASSWORD=$PGPASSWORD # Ensure data directory exists and is empty rm -rf $PGDATA mkdir -p $PGDATA echo "Initializing PostgreSQL database..." -initdb -U postgres --encoding=UTF8 --locale=C --auth=trust +initdb -U $PGUSER --encoding=UTF8 --locale=C --auth=trust # Configure PostgreSQL cat > $PGDATA/pg_hba.conf << EOL # TYPE DATABASE USER ADDRESS METHOD -local all all trust -host all all 127.0.0.1/32 trust -host all all ::1/128 trust +local all all md5 +host all all 127.0.0.1/32 md5 +host all all ::1/128 md5 EOL # Configure postgresql.conf @@ -73,19 +78,11 @@ sleep 3 echo "PostgreSQL log content:" cat $PGDATA/log/postgresql-*.log || true -# Verify PostgreSQL is running -echo "Verifying PostgreSQL connection..." -for i in {1..5}; do - if psql -h localhost -U postgres -c "SELECT version();" 2>/dev/null; then - break - fi - echo "Waiting for PostgreSQL to start (attempt $i)..." - sleep 2 -done - -# Get PostgreSQL version -PG_ACTUAL_VERSION=$(psql -h localhost -U postgres -t -c "SHOW server_version;" | xargs) -echo "PostgreSQL actual version: ${PG_ACTUAL_VERSION}" +# Set password and create database +psql -h localhost -U $PGUSER -d postgres -c "ALTER USER $PGUSER WITH PASSWORD '$PGPASSWORD';" +if [ "$PGDATABASE" != "postgres" ]; then + createdb -h localhost -U $PGUSER $PGDATABASE +fi # Build and install pgvector echo "Building pgvector..." @@ -99,17 +96,19 @@ rm -rf pgvector # Create and configure pgvector extension echo "Creating pgvector extension..." -psql -h localhost -U postgres -d postgres -c "CREATE EXTENSION IF NOT EXISTS vector;" +psql -h localhost -U $PGUSER -d $PGDATABASE -c "CREATE EXTENSION IF NOT EXISTS vector;" # Export environment variables for PowerShell echo "PGDATA=$PGDATA" >> $GITHUB_ENV echo "PGHOST=$PGHOST" >> $GITHUB_ENV echo "PGUSER=$PGUSER" >> $GITHUB_ENV +echo "PGPASSWORD=$PGPASSWORD" >> $GITHUB_ENV +echo "PGDATABASE=$PGDATABASE" >> $GITHUB_ENV # Verify installation echo "Checking PostgreSQL installation..." -psql -h localhost -U postgres -d postgres -c "SELECT version();" +psql -h localhost -U $PGUSER -d $PGDATABASE -c "SELECT version();" echo "Checking available extensions..." -psql -h localhost -U postgres -d postgres -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';" +psql -h localhost -U $PGUSER -d $PGDATABASE -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';" echo "Checking installed extensions..." -psql -h localhost -U postgres -d postgres -c "SELECT * FROM pg_extension WHERE extname = 'vector';" +psql -h localhost -U $PGUSER -d $PGDATABASE -c "SELECT * FROM pg_extension WHERE extname = 'vector';" From 3e66fa00a6674d9f164a1d41dc6ba645e1e5924e Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 16:01:42 +0800 Subject: [PATCH 21/32] try fix --- scripts/install-macos.sh | 13 +++++- scripts/install-windows.sh | 94 ++++++++++---------------------------- 2 files changed, 35 insertions(+), 72 deletions(-) diff --git a/scripts/install-macos.sh b/scripts/install-macos.sh index d68a37d..572bf4a 100644 --- a/scripts/install-macos.sh +++ b/scripts/install-macos.sh @@ -10,10 +10,19 @@ PGDATABASE=${5:-postgres} # Install PostgreSQL brew install "postgresql@$PG_VERSION" -brew services start "postgresql@$PG_VERSION" +brew link --force "postgresql@$PG_VERSION" # Add PostgreSQL binaries to PATH -export PATH="/opt/homebrew/opt/postgresql@$PG_VERSION/bin:$PATH" +PG_PATH="/usr/local/opt/postgresql@$PG_VERSION/bin" +# For Apple Silicon Macs +if [ -d "/opt/homebrew/opt/postgresql@$PG_VERSION/bin" ]; then + PG_PATH="/opt/homebrew/opt/postgresql@$PG_VERSION/bin" +fi +export PATH="$PG_PATH:$PATH" +echo "$PG_PATH" >> $GITHUB_PATH + +# Start PostgreSQL +brew services start "postgresql@$PG_VERSION" # Wait for PostgreSQL to start sleep 3 diff --git a/scripts/install-windows.sh b/scripts/install-windows.sh index c44a5bf..1125582 100644 --- a/scripts/install-windows.sh +++ b/scripts/install-windows.sh @@ -8,95 +8,49 @@ PGUSER=${3:-postgres} PGPASSWORD=${4:-postgres} PGDATABASE=${5:-postgres} -# Add PostgreSQL binaries to PATH -export PATH="/mingw64/bin:$PATH" -export PKG_CONFIG_PATH="/mingw64/lib/pkgconfig:$PKG_CONFIG_PATH" - -# Initialize PostgreSQL database +# Set environment variables export PGDATA=/c/data/postgres export PGHOST=localhost export PGUSER=$PGUSER export PGPASSWORD=$PGPASSWORD +export PGDATABASE=$PGDATABASE -# Ensure data directory exists and is empty -rm -rf $PGDATA -mkdir -p $PGDATA - -echo "Initializing PostgreSQL database..." -initdb -U $PGUSER --encoding=UTF8 --locale=C --auth=trust - -# Configure PostgreSQL -cat > $PGDATA/pg_hba.conf << EOL -# TYPE DATABASE USER ADDRESS METHOD -local all all md5 -host all all 127.0.0.1/32 md5 -host all all ::1/128 md5 -EOL - -# Configure postgresql.conf -cat > $PGDATA/postgresql.conf << EOL -listen_addresses = 'localhost' -port = 5432 -max_connections = 100 -shared_buffers = 128MB -dynamic_shared_memory_type = windows -max_wal_size = 1GB -min_wal_size = 80MB -log_destination = 'stderr' -logging_collector = on -log_directory = 'log' -log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' -log_rotation_age = 1d -log_rotation_size = 10MB -log_min_messages = warning -log_min_error_statement = error -log_min_duration_statement = 1000 -client_min_messages = notice -log_connections = on -log_disconnections = on -log_duration = on -log_line_prefix = '%m [%p] ' -log_timezone = 'UTC' -datestyle = 'iso, mdy' -timezone = 'UTC' -lc_messages = 'C' -lc_monetary = 'C' -lc_numeric = 'C' -lc_time = 'C' -default_text_search_config = 'pg_catalog.english' -EOL - -# Create log directory -mkdir -p $PGDATA/log +# Initialize PostgreSQL if not already initialized +if [ ! -d "$PGDATA" ]; then + initdb -D "$PGDATA" -U $PGUSER --pwfile=<(echo "$PGPASSWORD") + + # Configure PostgreSQL for password authentication + echo "host all all 127.0.0.1/32 md5" >> "$PGDATA/pg_hba.conf" + echo "host all all ::1/128 md5" >> "$PGDATA/pg_hba.conf" +fi # Start PostgreSQL echo "Starting PostgreSQL..." -pg_ctl -D $PGDATA -w start +pg_ctl -D "$PGDATA" -w start -# Wait and check the log +# Wait for PostgreSQL to start sleep 3 + +# Show PostgreSQL logs echo "PostgreSQL log content:" -cat $PGDATA/log/postgresql-*.log || true +cat "$PGDATA/log/postgresql-"*".log" -# Set password and create database -psql -h localhost -U $PGUSER -d postgres -c "ALTER USER $PGUSER WITH PASSWORD '$PGPASSWORD';" +# Create database if it doesn't exist if [ "$PGDATABASE" != "postgres" ]; then - createdb -h localhost -U $PGUSER $PGDATABASE + PGPASSWORD=$PGPASSWORD createdb -h localhost -U $PGUSER $PGDATABASE || true fi # Build and install pgvector -echo "Building pgvector..." -git clone --branch v${PGVECTOR_VERSION} https://github.com/pgvector/pgvector.git +git clone --branch "v$PGVECTOR_VERSION" https://github.com/pgvector/pgvector.git cd pgvector -make clean -PG_CONFIG=/mingw64/bin/pg_config make -PG_CONFIG=/mingw64/bin/pg_config make install +make +make install cd .. rm -rf pgvector # Create and configure pgvector extension echo "Creating pgvector extension..." -psql -h localhost -U $PGUSER -d $PGDATABASE -c "CREATE EXTENSION IF NOT EXISTS vector;" +PGPASSWORD=$PGPASSWORD psql -h localhost -U $PGUSER -d $PGDATABASE -c "CREATE EXTENSION IF NOT EXISTS vector;" # Export environment variables for PowerShell echo "PGDATA=$PGDATA" >> $GITHUB_ENV @@ -107,8 +61,8 @@ echo "PGDATABASE=$PGDATABASE" >> $GITHUB_ENV # Verify installation echo "Checking PostgreSQL installation..." -psql -h localhost -U $PGUSER -d $PGDATABASE -c "SELECT version();" +PGPASSWORD=$PGPASSWORD psql -h localhost -U $PGUSER -d $PGDATABASE -c "SELECT version();" echo "Checking available extensions..." -psql -h localhost -U $PGUSER -d $PGDATABASE -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';" +PGPASSWORD=$PGPASSWORD psql -h localhost -U $PGUSER -d $PGDATABASE -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';" echo "Checking installed extensions..." -psql -h localhost -U $PGUSER -d $PGDATABASE -c "SELECT * FROM pg_extension WHERE extname = 'vector';" +PGPASSWORD=$PGPASSWORD psql -h localhost -U $PGUSER -d $PGDATABASE -c "SELECT * FROM pg_extension WHERE extname = 'vector';" From e7ec48301df77618ac0cf4a94837aaf0a5bfe756 Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 16:04:47 +0800 Subject: [PATCH 22/32] try fix --- scripts/install-windows.sh | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/scripts/install-windows.sh b/scripts/install-windows.sh index 1125582..819a16d 100644 --- a/scripts/install-windows.sh +++ b/scripts/install-windows.sh @@ -17,7 +17,12 @@ export PGDATABASE=$PGDATABASE # Initialize PostgreSQL if not already initialized if [ ! -d "$PGDATA" ]; then - initdb -D "$PGDATA" -U $PGUSER --pwfile=<(echo "$PGPASSWORD") + # Create a temporary password file + PWFILE=$(mktemp) + echo "$PGPASSWORD" > "$PWFILE" + + initdb -D "$PGDATA" -U $PGUSER --pwfile="$PWFILE" + rm -f "$PWFILE" # Configure PostgreSQL for password authentication echo "host all all 127.0.0.1/32 md5" >> "$PGDATA/pg_hba.conf" @@ -40,11 +45,22 @@ if [ "$PGDATABASE" != "postgres" ]; then PGPASSWORD=$PGPASSWORD createdb -h localhost -U $PGUSER $PGDATABASE || true fi +# Install build tools and dependencies +pacman -S --noconfirm \ + mingw-w64-x86_64-gcc \ + mingw-w64-x86_64-postgresql \ + make + +# Add PostgreSQL binaries to PATH +export PATH="/mingw64/bin:$PATH" +export PKG_CONFIG_PATH="/mingw64/lib/pkgconfig:$PKG_CONFIG_PATH" + # Build and install pgvector git clone --branch "v$PGVECTOR_VERSION" https://github.com/pgvector/pgvector.git cd pgvector -make -make install +make clean +PG_CONFIG=/mingw64/bin/pg_config make +PG_CONFIG=/mingw64/bin/pg_config make install cd .. rm -rf pgvector From a62b9ded480833d37f28f3f7f9e8dd9e19ca7e3e Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 16:08:49 +0800 Subject: [PATCH 23/32] try fix --- .github/workflows/ci.yml | 22 +++++++--------------- scripts/install-windows.sh | 17 ++++++++++++++++- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c0abdd7..ab44445 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,39 +43,31 @@ jobs: - name: Test Extension (Unix) if: runner.os != 'Windows' env: - PGUSER: testuser PGPASSWORD: testpass - PGDATABASE: testdb run: | - psql -c 'CREATE EXTENSION IF NOT EXISTS vector;' - psql -c 'CREATE TABLE IF NOT EXISTS items (id bigserial PRIMARY KEY, embedding vector(3));' - psql -c "INSERT INTO items (embedding) VALUES ('[1,2,3]');" - psql -c 'SELECT * FROM items;' + psql -h localhost -U testuser -d testdb -c 'CREATE EXTENSION IF NOT EXISTS vector;' + psql -h localhost -U testuser -d testdb -c 'CREATE TABLE IF NOT EXISTS items (id bigserial PRIMARY KEY, embedding vector(3));' + psql -h localhost -U testuser -d testdb -c "INSERT INTO items (embedding) VALUES ('[1,2,3]');" + psql -h localhost -U testuser -d testdb -c 'SELECT * FROM items;' - name: Test Extension (Windows PowerShell) if: runner.os == 'Windows' shell: pwsh env: - PGUSER: testuser PGPASSWORD: testpass - PGDATABASE: testdb run: | - psql -c 'SELECT * FROM items;' + psql -h localhost -U testuser -d testdb -c 'SELECT * FROM items;' - name: Test Extension (Windows CMD) if: runner.os == 'Windows' shell: cmd env: - PGUSER: testuser PGPASSWORD: testpass - PGDATABASE: testdb - run: psql -c "SELECT * FROM items;" + run: psql -h localhost -U testuser -d testdb -c "SELECT * FROM items;" - name: Test Extension (Windows MSYS2) if: runner.os == 'Windows' shell: msys2 {0} env: - PGUSER: testuser PGPASSWORD: testpass - PGDATABASE: testdb - run: psql -c 'SELECT * FROM items;' + run: psql -h localhost -U testuser -d testdb -c 'SELECT * FROM items;' diff --git a/scripts/install-windows.sh b/scripts/install-windows.sh index 819a16d..c3fd074 100644 --- a/scripts/install-windows.sh +++ b/scripts/install-windows.sh @@ -27,6 +27,17 @@ if [ ! -d "$PGDATA" ]; then # Configure PostgreSQL for password authentication echo "host all all 127.0.0.1/32 md5" >> "$PGDATA/pg_hba.conf" echo "host all all ::1/128 md5" >> "$PGDATA/pg_hba.conf" + + # Configure logging + cat >> "$PGDATA/postgresql.conf" << EOL +logging_collector = on +log_directory = 'log' +log_filename = 'postgresql-%Y-%m-%d.log' +log_rotation_age = 1d +EOL + + # Create log directory + mkdir -p "$PGDATA/log" fi # Start PostgreSQL @@ -38,7 +49,11 @@ sleep 3 # Show PostgreSQL logs echo "PostgreSQL log content:" -cat "$PGDATA/log/postgresql-"*".log" +if [ -f "$PGDATA/log/postgresql-$(date +%Y-%m-%d).log" ]; then + cat "$PGDATA/log/postgresql-$(date +%Y-%m-%d).log" +else + echo "Log file not found. PostgreSQL is still running, continuing..." +fi # Create database if it doesn't exist if [ "$PGDATABASE" != "postgres" ]; then From a5238bb1668d835678dd7b9552a8cb528b754168 Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 16:12:43 +0800 Subject: [PATCH 24/32] try fix --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab44445..c1ca176 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,6 +56,9 @@ jobs: env: PGPASSWORD: testpass run: | + psql -h localhost -U testuser -d testdb -c 'CREATE EXTENSION IF NOT EXISTS vector;' + psql -h localhost -U testuser -d testdb -c 'CREATE TABLE IF NOT EXISTS items (id bigserial PRIMARY KEY, embedding vector(3));' + psql -h localhost -U testuser -d testdb -c "INSERT INTO items (embedding) VALUES ('[1,2,3]');" psql -h localhost -U testuser -d testdb -c 'SELECT * FROM items;' - name: Test Extension (Windows CMD) From 67db428c9336ef71704c46c5633b9c603118bf04 Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 16:16:51 +0800 Subject: [PATCH 25/32] try fix --- README.md | 242 +++++++++++++++++++------------------ scripts/install-macos.sh | 37 ++++-- scripts/install-ubuntu.sh | 125 ++++++++----------- scripts/install-windows.sh | 49 +++++--- 4 files changed, 238 insertions(+), 215 deletions(-) diff --git a/README.md b/README.md index 5674d2e..bd23b8b 100644 --- a/README.md +++ b/README.md @@ -1,140 +1,152 @@ -# Setup pgvector Action +# Setup pgvector -This action sets up [pgvector](https://github.com/pgvector/pgvector) in your GitHub Actions workflow. It uses the preinstalled PostgreSQL on GitHub runners and installs pgvector using platform-specific methods. +GitHub Action and scripts to set up PostgreSQL with pgvector extension for vector similarity search. -## Usage +## Features + +- 🚀 Quick setup of PostgreSQL with pgvector extension +- 🔄 Supports both GitHub Actions and local installation +- 🛠️ Customizable PostgreSQL and pgvector versions +- 🔐 Secure password authentication +- 🌐 Cross-platform support: Ubuntu, Windows (MSYS2), and macOS +- 🏗️ Builds pgvector from source for maximum compatibility + +## Quick Start + +### GitHub Actions ```yaml steps: -- uses: actions/checkout@v4 -- uses: cpunion/setup-pgvector@v1 +- uses: cpunion/setup-pgvector@main with: - postgres-version: '17' # optional, defaults to 17. Use 14 for ubuntu-22.04 and ubuntu-20.04 - pgvector-version: '0.8.0' # optional, defaults to 0.8.0 - postgres-user: 'myuser' # optional, defaults to 'postgres' - postgres-password: 'mypassword' # optional, defaults to 'postgres' - postgres-db: 'mydb' # optional, defaults to 'postgres' + postgres-version: '17' + postgres-user: 'myuser' + postgres-password: 'mypassword' + postgres-db: 'mydb' + +- name: Test pgvector + env: + PGPASSWORD: mypassword + run: | + psql -h localhost -U myuser -d mydb -c 'CREATE EXTENSION vector;' ``` -## Inputs +### Local Installation -- `postgres-version`: PostgreSQL version to use (default: '17'). Note: Use '14' for ubuntu-22.04 and ubuntu-20.04. -- `pgvector-version`: pgvector version to install (default: '0.8.0') -- `postgres-user`: PostgreSQL user to create (default: 'postgres') -- `postgres-password`: PostgreSQL user password (default: 'postgres') -- `postgres-db`: PostgreSQL database to create (default: 'postgres') +```bash +# Ubuntu +./scripts/install-ubuntu.sh -## Platform Support +# macOS +./scripts/install-macos.sh -This action supports all major GitHub Actions platforms: -- Ubuntu (using postgresql-xx-pgvector package or building from source) -- macOS (using Homebrew) -- Windows (building from source using Visual Studio Build Tools) +# Windows (MSYS2) +./scripts/install-windows.sh +``` -## CI Status +## Requirements -The action is tested on the following platforms: -- Ubuntu: ubuntu-latest, ubuntu-24.04 -- Windows: windows-latest, windows-2019 -- macOS: macos-latest, macos-13 +- Ubuntu: No additional requirements +- Windows: MSYS2 environment +- macOS: Homebrew +- Git (for building pgvector) -## Example workflows +## Detailed Usage + +### GitHub Actions -### Ubuntu ```yaml -name: Test Ubuntu - -on: [push] - -jobs: - test: - runs-on: ubuntu-latest # or ubuntu-22.04, ubuntu-20.04 - steps: - - uses: actions/checkout@v4 - - name: Setup pgvector - uses: cpunion/setup-pgvector@v1 - with: - postgres-version: '17' # Use '14' for ubuntu-22.04 and ubuntu-20.04 - pgvector-version: '0.8.0' - postgres-user: 'myuser' - postgres-password: 'mypassword' - postgres-db: 'mydb' - - name: Create extension - run: | - sudo -u postgres psql -c 'CREATE EXTENSION vector;' - - name: Test Connection - env: - PGUSER: myuser - PGPASSWORD: mypassword - PGDATABASE: mydb - run: | - psql -c 'SELECT version();' +steps: +- uses: cpunion/setup-pgvector@main + with: + # PostgreSQL version to install (default: 17) + postgres-version: '17' + # pgvector version to install (default: 0.8.0) + pgvector-version: '0.8.0' + # PostgreSQL user to create (default: postgres) + postgres-user: 'myuser' + # Password for the PostgreSQL user (default: postgres) + postgres-password: 'mypassword' + # Database to create (default: postgres) + postgres-db: 'mydb' + +- name: Test pgvector + env: + PGPASSWORD: mypassword + run: | + psql -h localhost -U myuser -d mydb -c 'CREATE EXTENSION vector;' + psql -h localhost -U myuser -d mydb -c 'CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3));' + psql -h localhost -U myuser -d mydb -c "INSERT INTO items (embedding) VALUES ('[1,2,3]');" + psql -h localhost -U myuser -d mydb -c 'SELECT * FROM items;' ``` -### macOS -```yaml -name: Test macOS - -on: [push] - -jobs: - test: - runs-on: macos-latest # or macos-13 - steps: - - uses: actions/checkout@v4 - - name: Setup pgvector - uses: cpunion/setup-pgvector@v1 - with: - pgvector-version: '0.8.0' - postgres-user: 'myuser' - postgres-password: 'mypassword' - postgres-db: 'mydb' - - name: Create extension - run: | - psql postgres -c 'CREATE EXTENSION vector;' - - name: Test Connection - env: - PGUSER: myuser - PGPASSWORD: mypassword - PGDATABASE: mydb - run: | - psql -c 'SELECT version();' +### Local Installation + +The scripts can also be used locally on Ubuntu, macOS, and Windows (MSYS2). + +#### Ubuntu +```bash +# Install with default settings +./scripts/install-ubuntu.sh + +# Install with custom settings +./scripts/install-ubuntu.sh 17 0.8.0 myuser mypassword mydb ``` -### Windows -```yaml -name: Test Windows - -on: [push] - -jobs: - test: - strategy: - matrix: - os: [windows-latest, windows-2019] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - name: Setup pgvector - uses: cpunion/setup-pgvector@v1 - with: - pgvector-version: '0.8.0' - postgres-user: 'myuser' - postgres-password: 'mypassword' - postgres-db: 'mydb' - - name: Create extension - shell: cmd - run: | - psql -U postgres -c "CREATE EXTENSION vector;" - - name: Test Connection - env: - PGUSER: myuser - PGPASSWORD: mypassword - PGDATABASE: mydb - run: | - psql -c "SELECT version();" +#### macOS +```bash +# Install with default settings +./scripts/install-macos.sh + +# Install with custom settings +./scripts/install-macos.sh 17 0.8.0 myuser mypassword mydb +``` + +#### Windows (MSYS2) +```bash +# Install with default settings +./scripts/install-windows.sh + +# Install with custom settings +./scripts/install-windows.sh 17 0.8.0 myuser mypassword mydb +``` + +### Script Parameters + +All installation scripts accept the following parameters: + +1. `PG_VERSION` (default: 17) - PostgreSQL version to install +2. `PGVECTOR_VERSION` (default: 0.8.0) - pgvector version to install +3. `PGUSER` (default: postgres) - PostgreSQL user to create +4. `PGPASSWORD` (default: postgres) - Password for the PostgreSQL user +5. `PGDATABASE` (default: postgres) - Database to create + +### Connection Details + +After installation, you can connect to PostgreSQL using: + +```bash +# Using password from environment variable +export PGPASSWORD=mypassword +psql -h localhost -U myuser -d mydb + +# Or using password prompt +psql -h localhost -U myuser -d mydb ``` +## Supported Platforms + +- Ubuntu (latest, 24.04) +- Windows (latest, 2019) +- macOS (latest, 13) + +## Notes + +- The scripts will install PostgreSQL if not already installed +- The scripts will create the specified user and database if they don't exist +- The scripts will build and install pgvector from source +- All connections are configured to use password authentication + ## License MIT diff --git a/scripts/install-macos.sh b/scripts/install-macos.sh index 572bf4a..dcb9d16 100644 --- a/scripts/install-macos.sh +++ b/scripts/install-macos.sh @@ -8,6 +8,17 @@ PGUSER=${3:-postgres} PGPASSWORD=${4:-postgres} PGDATABASE=${5:-postgres} +# Function to export variables +export_var() { + local name=$1 + local value=$2 + export "$name=$value" + # Only export to GITHUB_ENV if running in GitHub Actions + if [ -n "$GITHUB_ENV" ]; then + echo "$name=$value" >> $GITHUB_ENV + fi +} + # Install PostgreSQL brew install "postgresql@$PG_VERSION" brew link --force "postgresql@$PG_VERSION" @@ -19,7 +30,10 @@ if [ -d "/opt/homebrew/opt/postgresql@$PG_VERSION/bin" ]; then PG_PATH="/opt/homebrew/opt/postgresql@$PG_VERSION/bin" fi export PATH="$PG_PATH:$PATH" -echo "$PG_PATH" >> $GITHUB_PATH +# Only add to GITHUB_PATH if running in GitHub Actions +if [ -n "$GITHUB_PATH" ]; then + echo "$PG_PATH" >> $GITHUB_PATH +fi # Start PostgreSQL brew services start "postgresql@$PG_VERSION" @@ -46,15 +60,10 @@ rm -rf pgvector psql -d $PGDATABASE -c 'CREATE EXTENSION IF NOT EXISTS vector;' # Export environment variables -export PGHOST=localhost -export PGUSER=$PGUSER -export PGPASSWORD=$PGPASSWORD -export PGDATABASE=$PGDATABASE - -echo "PGHOST=$PGHOST" >> $GITHUB_ENV -echo "PGUSER=$PGUSER" >> $GITHUB_ENV -echo "PGPASSWORD=$PGPASSWORD" >> $GITHUB_ENV -echo "PGDATABASE=$PGDATABASE" >> $GITHUB_ENV +export_var "PGHOST" "localhost" +export_var "PGUSER" "$PGUSER" +export_var "PGPASSWORD" "$PGPASSWORD" +export_var "PGDATABASE" "$PGDATABASE" # Verify installation echo "Checking PostgreSQL installation..." @@ -63,3 +72,11 @@ echo "Checking available extensions..." psql -d $PGDATABASE -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';" echo "Checking installed extensions..." psql -d $PGDATABASE -c "SELECT * FROM pg_extension WHERE extname = 'vector';" + +# Print success message +echo "PostgreSQL and pgvector have been successfully installed!" +echo "Connection details:" +echo " Host: localhost" +echo " User: $PGUSER" +echo " Database: $PGDATABASE" +echo " Password: [hidden]" diff --git a/scripts/install-ubuntu.sh b/scripts/install-ubuntu.sh index 08a23e5..1997b8e 100644 --- a/scripts/install-ubuntu.sh +++ b/scripts/install-ubuntu.sh @@ -8,94 +8,73 @@ PGUSER=${3:-postgres} PGPASSWORD=${4:-postgres} PGDATABASE=${5:-postgres} -echo "Installing PostgreSQL ${PG_VERSION}..." -sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y +# Function to export variables +export_var() { + local name=$1 + local value=$2 + export "$name=$value" + # Only export to GITHUB_ENV if running in GitHub Actions + if [ -n "$GITHUB_ENV" ]; then + echo "$name=$value" >> $GITHUB_ENV + fi +} + +# Add PostgreSQL repository +curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo gpg --dearmor -o /usr/share/keyrings/postgresql-keyring.gpg +echo "deb [signed-by=/usr/share/keyrings/postgresql-keyring.gpg] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list + +# Install PostgreSQL and build dependencies sudo apt-get update -sudo apt-get install -y postgresql-${PG_VERSION} +sudo apt-get install -y \ + "postgresql-$PG_VERSION" \ + "postgresql-server-dev-$PG_VERSION" \ + build-essential \ + git -# Configure PostgreSQL -sudo systemctl stop postgresql -sudo pg_dropcluster --stop ${PG_VERSION} main || true -sudo pg_createcluster ${PG_VERSION} main --start || true -sudo systemctl start postgresql +# Start PostgreSQL service +sudo systemctl start "postgresql@$PG_VERSION-main" -# Create runner user and grant permissions -sudo -u postgres psql -c "CREATE USER runner WITH SUPERUSER;" +# Wait for PostgreSQL to start +sleep 3 -# Verify PostgreSQL installation and version -echo "Checking PostgreSQL version..." -PG_ACTUAL_VERSION=$(sudo -u postgres psql -t -c "SHOW server_version;" | xargs) -echo "PostgreSQL actual version: ${PG_ACTUAL_VERSION}" -PG_MAJOR_VERSION=$(echo ${PG_ACTUAL_VERSION} | cut -d. -f1) -echo "PostgreSQL major version: ${PG_MAJOR_VERSION}" +# Create user and set password +sudo -u postgres psql -c "CREATE USER $PGUSER WITH SUPERUSER PASSWORD '$PGPASSWORD';" || true +sudo -u postgres psql -c "ALTER USER $PGUSER WITH PASSWORD '$PGPASSWORD';" -# Remove any existing pgvector installations -sudo apt-get remove -y postgresql-*-pgvector || true -sudo rm -f /usr/lib/postgresql/*/lib/vector.so -sudo rm -f /usr/share/postgresql/*/extension/vector* +# Create database if it doesn't exist +if [ "$PGDATABASE" != "postgres" ]; then + sudo -u postgres createdb -O $PGUSER $PGDATABASE || true +fi -echo "Installing pgvector..." -# Always build from source to match PostgreSQL version -echo "Building pgvector from source..." -sudo apt-get install -y postgresql-server-dev-${PG_MAJOR_VERSION} build-essential git -git clone --branch v${PGVECTOR_VERSION} https://github.com/pgvector/pgvector.git +# Build and install pgvector +git clone --branch "v$PGVECTOR_VERSION" https://github.com/pgvector/pgvector.git cd pgvector -make clean -PG_CONFIG=/usr/lib/postgresql/${PG_MAJOR_VERSION}/bin/pg_config make -sudo PG_CONFIG=/usr/lib/postgresql/${PG_MAJOR_VERSION}/bin/pg_config make install +make +sudo make install cd .. rm -rf pgvector -# Configure PostgreSQL authentication for CI -echo "local all postgres trust" | sudo tee /etc/postgresql/${PG_VERSION}/main/pg_hba.conf -echo "local all runner trust" | sudo tee -a /etc/postgresql/${PG_VERSION}/main/pg_hba.conf -echo "local all all trust" | sudo tee -a /etc/postgresql/${PG_VERSION}/main/pg_hba.conf - -# Restart PostgreSQL to ensure pgvector is loaded -sudo systemctl restart postgresql - -# Verify pgvector installation -echo "Verifying pgvector installation..." -echo "Installed extensions:" -sudo -u postgres psql -d postgres -c "SELECT * FROM pg_extension;" || true -echo "Available extensions:" -sudo -u postgres psql -d postgres -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';" || true - -# List extension directory contents -echo "Checking extension files..." -echo "PostgreSQL ${PG_MAJOR_VERSION} extension directory:" -ls -la /usr/share/postgresql/${PG_MAJOR_VERSION}/extension/ || true -echo "PostgreSQL ${PG_MAJOR_VERSION} lib directory:" -ls -la /usr/lib/postgresql/${PG_MAJOR_VERSION}/lib/ || true - -# Set password and create database -sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '$PGPASSWORD';" -if [ "$PGUSER" != "postgres" ]; then - sudo -u postgres createuser -s $PGUSER - sudo -u postgres psql -c "ALTER USER $PGUSER WITH PASSWORD '$PGPASSWORD';" -fi -if [ "$PGDATABASE" != "postgres" ]; then - sudo -u postgres createdb -O $PGUSER $PGDATABASE -fi - # Create and configure pgvector extension -sudo -u postgres psql -d $PGDATABASE -c "CREATE EXTENSION IF NOT EXISTS vector;" +PGPASSWORD=$PGPASSWORD psql -h localhost -U $PGUSER -d $PGDATABASE -c 'CREATE EXTENSION IF NOT EXISTS vector;' # Export environment variables -export PGHOST=localhost -export PGUSER=$PGUSER -export PGPASSWORD=$PGPASSWORD -export PGDATABASE=$PGDATABASE - -echo "PGHOST=$PGHOST" >> $GITHUB_ENV -echo "PGUSER=$PGUSER" >> $GITHUB_ENV -echo "PGPASSWORD=$PGPASSWORD" >> $GITHUB_ENV -echo "PGDATABASE=$PGDATABASE" >> $GITHUB_ENV +export_var "PGHOST" "localhost" +export_var "PGUSER" "$PGUSER" +export_var "PGPASSWORD" "$PGPASSWORD" +export_var "PGDATABASE" "$PGDATABASE" # Verify installation echo "Checking PostgreSQL installation..." -psql -d $PGDATABASE -c "SELECT version();" +PGPASSWORD=$PGPASSWORD psql -h localhost -U $PGUSER -d $PGDATABASE -c "SELECT version();" echo "Checking available extensions..." -psql -d $PGDATABASE -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';" +PGPASSWORD=$PGPASSWORD psql -h localhost -U $PGUSER -d $PGDATABASE -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';" echo "Checking installed extensions..." -psql -d $PGDATABASE -c "SELECT * FROM pg_extension WHERE extname = 'vector';" +PGPASSWORD=$PGPASSWORD psql -h localhost -U $PGUSER -d $PGDATABASE -c "SELECT * FROM pg_extension WHERE extname = 'vector';" + +# Print success message +echo "PostgreSQL and pgvector have been successfully installed!" +echo "Connection details:" +echo " Host: localhost" +echo " User: $PGUSER" +echo " Database: $PGDATABASE" +echo " Password: [hidden]" diff --git a/scripts/install-windows.sh b/scripts/install-windows.sh index c3fd074..1b66e30 100644 --- a/scripts/install-windows.sh +++ b/scripts/install-windows.sh @@ -8,12 +8,23 @@ PGUSER=${3:-postgres} PGPASSWORD=${4:-postgres} PGDATABASE=${5:-postgres} +# Function to export variables +export_var() { + local name=$1 + local value=$2 + export "$name=$value" + # Only export to GITHUB_ENV if running in GitHub Actions + if [ -n "$GITHUB_ENV" ]; then + echo "$name=$value" >> $GITHUB_ENV + fi +} + # Set environment variables -export PGDATA=/c/data/postgres -export PGHOST=localhost -export PGUSER=$PGUSER -export PGPASSWORD=$PGPASSWORD -export PGDATABASE=$PGDATABASE +export_var "PGDATA" "/c/data/postgres" +export_var "PGHOST" "localhost" +export_var "PGUSER" "$PGUSER" +export_var "PGPASSWORD" "$PGPASSWORD" +export_var "PGDATABASE" "$PGDATABASE" # Initialize PostgreSQL if not already initialized if [ ! -d "$PGDATA" ]; then @@ -60,11 +71,13 @@ if [ "$PGDATABASE" != "postgres" ]; then PGPASSWORD=$PGPASSWORD createdb -h localhost -U $PGUSER $PGDATABASE || true fi -# Install build tools and dependencies -pacman -S --noconfirm \ - mingw-w64-x86_64-gcc \ - mingw-w64-x86_64-postgresql \ - make +# Install build tools and dependencies if running in MSYS2 +if command -v pacman &> /dev/null; then + pacman -S --noconfirm \ + mingw-w64-x86_64-gcc \ + mingw-w64-x86_64-postgresql \ + make +fi # Add PostgreSQL binaries to PATH export PATH="/mingw64/bin:$PATH" @@ -83,13 +96,6 @@ rm -rf pgvector echo "Creating pgvector extension..." PGPASSWORD=$PGPASSWORD psql -h localhost -U $PGUSER -d $PGDATABASE -c "CREATE EXTENSION IF NOT EXISTS vector;" -# Export environment variables for PowerShell -echo "PGDATA=$PGDATA" >> $GITHUB_ENV -echo "PGHOST=$PGHOST" >> $GITHUB_ENV -echo "PGUSER=$PGUSER" >> $GITHUB_ENV -echo "PGPASSWORD=$PGPASSWORD" >> $GITHUB_ENV -echo "PGDATABASE=$PGDATABASE" >> $GITHUB_ENV - # Verify installation echo "Checking PostgreSQL installation..." PGPASSWORD=$PGPASSWORD psql -h localhost -U $PGUSER -d $PGDATABASE -c "SELECT version();" @@ -97,3 +103,12 @@ echo "Checking available extensions..." PGPASSWORD=$PGPASSWORD psql -h localhost -U $PGUSER -d $PGDATABASE -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';" echo "Checking installed extensions..." PGPASSWORD=$PGPASSWORD psql -h localhost -U $PGUSER -d $PGDATABASE -c "SELECT * FROM pg_extension WHERE extname = 'vector';" + +# Print success message +echo "PostgreSQL and pgvector have been successfully installed!" +echo "Connection details:" +echo " Host: localhost" +echo " User: $PGUSER" +echo " Database: $PGDATABASE" +echo " Password: [hidden]" +echo " Data directory: $PGDATA" From 35489201a31f817e2141b568dc981ac45cf46d52 Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 16:21:09 +0800 Subject: [PATCH 26/32] try fix --- README.md | 52 ++++++++++++++++----------------------- scripts/install-ubuntu.sh | 48 +++++++++++++++++++++++++++--------- 2 files changed, 58 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index bd23b8b..b5a34c5 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,27 @@ steps: ### Local Installation +#### Method 1: Direct Installation + +```bash +# Ubuntu +curl -fsSL https://raw.githubusercontent.com/cpunion/setup-pgvector/main/scripts/install-ubuntu.sh | bash + +# macOS +curl -fsSL https://raw.githubusercontent.com/cpunion/setup-pgvector/main/scripts/install-macos.sh | bash + +# Windows (MSYS2) +curl -fsSL https://raw.githubusercontent.com/cpunion/setup-pgvector/main/scripts/install-windows.sh | bash +``` + +With custom parameters: +```bash +# Format: curl ... | bash -s [PG_VERSION] [PGVECTOR_VERSION] [PGUSER] [PGPASSWORD] [PGDATABASE] +curl -fsSL https://raw.githubusercontent.com/cpunion/setup-pgvector/main/scripts/install-ubuntu.sh | bash -s 17 0.8.0 myuser mypassword mydb +``` + +#### Method 2: Clone and Run + ```bash # Ubuntu ./scripts/install-ubuntu.sh @@ -80,37 +101,6 @@ steps: psql -h localhost -U myuser -d mydb -c 'SELECT * FROM items;' ``` -### Local Installation - -The scripts can also be used locally on Ubuntu, macOS, and Windows (MSYS2). - -#### Ubuntu -```bash -# Install with default settings -./scripts/install-ubuntu.sh - -# Install with custom settings -./scripts/install-ubuntu.sh 17 0.8.0 myuser mypassword mydb -``` - -#### macOS -```bash -# Install with default settings -./scripts/install-macos.sh - -# Install with custom settings -./scripts/install-macos.sh 17 0.8.0 myuser mypassword mydb -``` - -#### Windows (MSYS2) -```bash -# Install with default settings -./scripts/install-windows.sh - -# Install with custom settings -./scripts/install-windows.sh 17 0.8.0 myuser mypassword mydb -``` - ### Script Parameters All installation scripts accept the following parameters: diff --git a/scripts/install-ubuntu.sh b/scripts/install-ubuntu.sh index 1997b8e..e63f5e1 100644 --- a/scripts/install-ubuntu.sh +++ b/scripts/install-ubuntu.sh @@ -1,7 +1,7 @@ #!/bin/bash -set -ex +set -e -# Default versions if not provided +# Get parameters PG_VERSION=${1:-17} PGVECTOR_VERSION=${2:-0.8.0} PGUSER=${3:-postgres} @@ -19,6 +19,21 @@ export_var() { fi } +# Function to wait for PostgreSQL to be ready +wait_for_postgres() { + echo "Waiting for PostgreSQL to start..." + for i in {1..30}; do + if sudo -u postgres psql -c '\l' >/dev/null 2>&1; then + echo "PostgreSQL is ready!" + return 0 + fi + echo "Waiting... ($i/30)" + sleep 1 + done + echo "PostgreSQL failed to start" + return 1 +} + # Add PostgreSQL repository curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo gpg --dearmor -o /usr/share/keyrings/postgresql-keyring.gpg echo "deb [signed-by=/usr/share/keyrings/postgresql-keyring.gpg] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list @@ -31,11 +46,22 @@ sudo apt-get install -y \ build-essential \ git -# Start PostgreSQL service +# Ensure PostgreSQL service is properly configured and started +sudo systemctl stop "postgresql@$PG_VERSION-main" || true +sudo pg_dropcluster --stop "$PG_VERSION" main || true +sudo pg_createcluster "$PG_VERSION" main --start || true sudo systemctl start "postgresql@$PG_VERSION-main" -# Wait for PostgreSQL to start -sleep 3 +# Wait for PostgreSQL to be ready +wait_for_postgres + +# Configure PostgreSQL authentication +sudo sed -i 's/peer/trust/g' "/etc/postgresql/$PG_VERSION/main/pg_hba.conf" +sudo sed -i 's/scram-sha-256/trust/g' "/etc/postgresql/$PG_VERSION/main/pg_hba.conf" +sudo systemctl restart "postgresql@$PG_VERSION-main" + +# Wait again after authentication changes +wait_for_postgres # Create user and set password sudo -u postgres psql -c "CREATE USER $PGUSER WITH SUPERUSER PASSWORD '$PGPASSWORD';" || true @@ -43,19 +69,19 @@ sudo -u postgres psql -c "ALTER USER $PGUSER WITH PASSWORD '$PGPASSWORD';" # Create database if it doesn't exist if [ "$PGDATABASE" != "postgres" ]; then - sudo -u postgres createdb -O $PGUSER $PGDATABASE || true + sudo -u postgres createdb -O "$PGUSER" "$PGDATABASE" || true fi # Build and install pgvector git clone --branch "v$PGVECTOR_VERSION" https://github.com/pgvector/pgvector.git cd pgvector -make +make clean sudo make install cd .. rm -rf pgvector # Create and configure pgvector extension -PGPASSWORD=$PGPASSWORD psql -h localhost -U $PGUSER -d $PGDATABASE -c 'CREATE EXTENSION IF NOT EXISTS vector;' +PGPASSWORD=$PGPASSWORD psql -h localhost -U "$PGUSER" -d "$PGDATABASE" -c 'CREATE EXTENSION IF NOT EXISTS vector;' # Export environment variables export_var "PGHOST" "localhost" @@ -65,11 +91,11 @@ export_var "PGDATABASE" "$PGDATABASE" # Verify installation echo "Checking PostgreSQL installation..." -PGPASSWORD=$PGPASSWORD psql -h localhost -U $PGUSER -d $PGDATABASE -c "SELECT version();" +PGPASSWORD=$PGPASSWORD psql -h localhost -U "$PGUSER" -d "$PGDATABASE" -c "SELECT version();" echo "Checking available extensions..." -PGPASSWORD=$PGPASSWORD psql -h localhost -U $PGUSER -d $PGDATABASE -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';" +PGPASSWORD=$PGPASSWORD psql -h localhost -U "$PGUSER" -d "$PGDATABASE" -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';" echo "Checking installed extensions..." -PGPASSWORD=$PGPASSWORD psql -h localhost -U $PGUSER -d $PGDATABASE -c "SELECT * FROM pg_extension WHERE extname = 'vector';" +PGPASSWORD=$PGPASSWORD psql -h localhost -U "$PGUSER" -d "$PGDATABASE" -c "SELECT * FROM pg_extension WHERE extname = 'vector';" # Print success message echo "PostgreSQL and pgvector have been successfully installed!" From f8315beaa52d841feebd7e79bab3754963ba8429 Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 16:25:23 +0800 Subject: [PATCH 27/32] try fix --- scripts/install-ubuntu.sh | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/scripts/install-ubuntu.sh b/scripts/install-ubuntu.sh index e63f5e1..33e9788 100644 --- a/scripts/install-ubuntu.sh +++ b/scripts/install-ubuntu.sh @@ -19,21 +19,6 @@ export_var() { fi } -# Function to wait for PostgreSQL to be ready -wait_for_postgres() { - echo "Waiting for PostgreSQL to start..." - for i in {1..30}; do - if sudo -u postgres psql -c '\l' >/dev/null 2>&1; then - echo "PostgreSQL is ready!" - return 0 - fi - echo "Waiting... ($i/30)" - sleep 1 - done - echo "PostgreSQL failed to start" - return 1 -} - # Add PostgreSQL repository curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo gpg --dearmor -o /usr/share/keyrings/postgresql-keyring.gpg echo "deb [signed-by=/usr/share/keyrings/postgresql-keyring.gpg] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list @@ -46,22 +31,13 @@ sudo apt-get install -y \ build-essential \ git -# Ensure PostgreSQL service is properly configured and started -sudo systemctl stop "postgresql@$PG_VERSION-main" || true -sudo pg_dropcluster --stop "$PG_VERSION" main || true -sudo pg_createcluster "$PG_VERSION" main --start || true -sudo systemctl start "postgresql@$PG_VERSION-main" - -# Wait for PostgreSQL to be ready -wait_for_postgres - # Configure PostgreSQL authentication sudo sed -i 's/peer/trust/g' "/etc/postgresql/$PG_VERSION/main/pg_hba.conf" sudo sed -i 's/scram-sha-256/trust/g' "/etc/postgresql/$PG_VERSION/main/pg_hba.conf" sudo systemctl restart "postgresql@$PG_VERSION-main" -# Wait again after authentication changes -wait_for_postgres +# Wait for PostgreSQL to start +sleep 3 # Create user and set password sudo -u postgres psql -c "CREATE USER $PGUSER WITH SUPERUSER PASSWORD '$PGPASSWORD';" || true @@ -89,14 +65,6 @@ export_var "PGUSER" "$PGUSER" export_var "PGPASSWORD" "$PGPASSWORD" export_var "PGDATABASE" "$PGDATABASE" -# Verify installation -echo "Checking PostgreSQL installation..." -PGPASSWORD=$PGPASSWORD psql -h localhost -U "$PGUSER" -d "$PGDATABASE" -c "SELECT version();" -echo "Checking available extensions..." -PGPASSWORD=$PGPASSWORD psql -h localhost -U "$PGUSER" -d "$PGDATABASE" -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';" -echo "Checking installed extensions..." -PGPASSWORD=$PGPASSWORD psql -h localhost -U "$PGUSER" -d "$PGDATABASE" -c "SELECT * FROM pg_extension WHERE extname = 'vector';" - # Print success message echo "PostgreSQL and pgvector have been successfully installed!" echo "Connection details:" From 1ba0c5299db61ccd976d32acdac6c860d902127c Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 16:27:18 +0800 Subject: [PATCH 28/32] try fix --- scripts/install-ubuntu.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/install-ubuntu.sh b/scripts/install-ubuntu.sh index 33e9788..0b2385a 100644 --- a/scripts/install-ubuntu.sh +++ b/scripts/install-ubuntu.sh @@ -31,13 +31,23 @@ sudo apt-get install -y \ build-essential \ git +# Ensure PostgreSQL is started +sudo systemctl enable "postgresql@$PG_VERSION-main" +sudo systemctl start "postgresql@$PG_VERSION-main" + # Configure PostgreSQL authentication sudo sed -i 's/peer/trust/g' "/etc/postgresql/$PG_VERSION/main/pg_hba.conf" sudo sed -i 's/scram-sha-256/trust/g' "/etc/postgresql/$PG_VERSION/main/pg_hba.conf" sudo systemctl restart "postgresql@$PG_VERSION-main" # Wait for PostgreSQL to start -sleep 3 +for i in {1..10}; do + if sudo -u postgres psql -c '\l' >/dev/null 2>&1; then + break + fi + echo "Waiting for PostgreSQL to start... ($i/10)" + sleep 1 +done # Create user and set password sudo -u postgres psql -c "CREATE USER $PGUSER WITH SUPERUSER PASSWORD '$PGPASSWORD';" || true From 2e083513f445e4dc40e6dfaee620d57a34796572 Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 16:30:22 +0800 Subject: [PATCH 29/32] try fix --- scripts/install-ubuntu.sh | 152 +++++++++++++++++++++----------------- 1 file changed, 86 insertions(+), 66 deletions(-) diff --git a/scripts/install-ubuntu.sh b/scripts/install-ubuntu.sh index 0b2385a..ccd820f 100644 --- a/scripts/install-ubuntu.sh +++ b/scripts/install-ubuntu.sh @@ -1,84 +1,104 @@ #!/bin/bash -set -e +set -ex -# Get parameters +# Default versions if not provided PG_VERSION=${1:-17} PGVECTOR_VERSION=${2:-0.8.0} PGUSER=${3:-postgres} PGPASSWORD=${4:-postgres} PGDATABASE=${5:-postgres} -# Function to export variables -export_var() { - local name=$1 - local value=$2 - export "$name=$value" - # Only export to GITHUB_ENV if running in GitHub Actions - if [ -n "$GITHUB_ENV" ]; then - echo "$name=$value" >> $GITHUB_ENV - fi -} - -# Add PostgreSQL repository -curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo gpg --dearmor -o /usr/share/keyrings/postgresql-keyring.gpg -echo "deb [signed-by=/usr/share/keyrings/postgresql-keyring.gpg] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list - -# Install PostgreSQL and build dependencies +echo "Installing PostgreSQL ${PG_VERSION}..." +sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y sudo apt-get update -sudo apt-get install -y \ - "postgresql-$PG_VERSION" \ - "postgresql-server-dev-$PG_VERSION" \ - build-essential \ - git - -# Ensure PostgreSQL is started -sudo systemctl enable "postgresql@$PG_VERSION-main" -sudo systemctl start "postgresql@$PG_VERSION-main" - -# Configure PostgreSQL authentication -sudo sed -i 's/peer/trust/g' "/etc/postgresql/$PG_VERSION/main/pg_hba.conf" -sudo sed -i 's/scram-sha-256/trust/g' "/etc/postgresql/$PG_VERSION/main/pg_hba.conf" -sudo systemctl restart "postgresql@$PG_VERSION-main" - -# Wait for PostgreSQL to start -for i in {1..10}; do - if sudo -u postgres psql -c '\l' >/dev/null 2>&1; then - break - fi - echo "Waiting for PostgreSQL to start... ($i/10)" - sleep 1 -done - -# Create user and set password -sudo -u postgres psql -c "CREATE USER $PGUSER WITH SUPERUSER PASSWORD '$PGPASSWORD';" || true -sudo -u postgres psql -c "ALTER USER $PGUSER WITH PASSWORD '$PGPASSWORD';" - -# Create database if it doesn't exist -if [ "$PGDATABASE" != "postgres" ]; then - sudo -u postgres createdb -O "$PGUSER" "$PGDATABASE" || true -fi +sudo apt-get install -y postgresql-${PG_VERSION} + +# Configure PostgreSQL +sudo systemctl stop postgresql +sudo pg_dropcluster --stop ${PG_VERSION} main || true +sudo pg_createcluster ${PG_VERSION} main --start || true +sudo systemctl start postgresql + +# Create runner user and grant permissions +sudo -u postgres psql -c "CREATE USER runner WITH SUPERUSER;" + +# Verify PostgreSQL installation and version +echo "Checking PostgreSQL version..." +PG_ACTUAL_VERSION=$(sudo -u postgres psql -t -c "SHOW server_version;" | xargs) +echo "PostgreSQL actual version: ${PG_ACTUAL_VERSION}" +PG_MAJOR_VERSION=$(echo ${PG_ACTUAL_VERSION} | cut -d. -f1) +echo "PostgreSQL major version: ${PG_MAJOR_VERSION}" -# Build and install pgvector -git clone --branch "v$PGVECTOR_VERSION" https://github.com/pgvector/pgvector.git +# Remove any existing pgvector installations +sudo apt-get remove -y postgresql-*-pgvector || true +sudo rm -f /usr/lib/postgresql/*/lib/vector.so +sudo rm -f /usr/share/postgresql/*/extension/vector* + +echo "Installing pgvector..." +# Always build from source to match PostgreSQL version +echo "Building pgvector from source..." +sudo apt-get install -y postgresql-server-dev-${PG_MAJOR_VERSION} build-essential git +git clone --branch v${PGVECTOR_VERSION} https://github.com/pgvector/pgvector.git cd pgvector make clean -sudo make install +PG_CONFIG=/usr/lib/postgresql/${PG_MAJOR_VERSION}/bin/pg_config make +sudo PG_CONFIG=/usr/lib/postgresql/${PG_MAJOR_VERSION}/bin/pg_config make install cd .. rm -rf pgvector +# Configure PostgreSQL authentication for CI +echo "local all postgres trust" | sudo tee /etc/postgresql/${PG_VERSION}/main/pg_hba.conf +echo "local all runner trust" | sudo tee -a /etc/postgresql/${PG_VERSION}/main/pg_hba.conf +echo "local all all trust" | sudo tee -a /etc/postgresql/${PG_VERSION}/main/pg_hba.conf + +# Restart PostgreSQL to ensure pgvector is loaded +sudo systemctl restart postgresql + +# Verify pgvector installation +echo "Verifying pgvector installation..." +echo "Installed extensions:" +sudo -u postgres psql -d postgres -c "SELECT * FROM pg_extension;" || true +echo "Available extensions:" +sudo -u postgres psql -d postgres -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';" || true + +# List extension directory contents +echo "Checking extension files..." +echo "PostgreSQL ${PG_MAJOR_VERSION} extension directory:" +ls -la /usr/share/postgresql/${PG_MAJOR_VERSION}/extension/ || true +echo "PostgreSQL ${PG_MAJOR_VERSION} lib directory:" +ls -la /usr/lib/postgresql/${PG_MAJOR_VERSION}/lib/ || true + +# Set password and create database +sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '$PGPASSWORD';" +if [ "$PGUSER" != "postgres" ]; then + sudo -u postgres createuser -s $PGUSER + sudo -u postgres psql -c "ALTER USER $PGUSER WITH PASSWORD '$PGPASSWORD';" +fi +if [ "$PGDATABASE" != "postgres" ]; then + sudo -u postgres createdb -O $PGUSER $PGDATABASE +fi + # Create and configure pgvector extension -PGPASSWORD=$PGPASSWORD psql -h localhost -U "$PGUSER" -d "$PGDATABASE" -c 'CREATE EXTENSION IF NOT EXISTS vector;' +sudo -u postgres psql -d $PGDATABASE -c "CREATE EXTENSION IF NOT EXISTS vector;" # Export environment variables -export_var "PGHOST" "localhost" -export_var "PGUSER" "$PGUSER" -export_var "PGPASSWORD" "$PGPASSWORD" -export_var "PGDATABASE" "$PGDATABASE" - -# Print success message -echo "PostgreSQL and pgvector have been successfully installed!" -echo "Connection details:" -echo " Host: localhost" -echo " User: $PGUSER" -echo " Database: $PGDATABASE" -echo " Password: [hidden]" +export PGHOST=localhost +export PGUSER=$PGUSER +export PGPASSWORD=$PGPASSWORD +export PGDATABASE=$PGDATABASE + +# Export to GITHUB_ENV only if running in GitHub Actions +if [ -n "$GITHUB_ENV" ]; then + echo "PGHOST=$PGHOST" >> $GITHUB_ENV + echo "PGUSER=$PGUSER" >> $GITHUB_ENV + echo "PGPASSWORD=$PGPASSWORD" >> $GITHUB_ENV + echo "PGDATABASE=$PGDATABASE" >> $GITHUB_ENV +fi + +# Verify installation +echo "Checking PostgreSQL installation..." +psql -d $PGDATABASE -c "SELECT version();" +echo "Checking available extensions..." +psql -d $PGDATABASE -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';" +echo "Checking installed extensions..." +psql -d $PGDATABASE -c "SELECT * FROM pg_extension WHERE extname = 'vector';" From 6a7ef3ed7bfce0fa20225283ece4fedc4403463a Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 16:45:56 +0800 Subject: [PATCH 30/32] try fix --- .github/workflows/ci.yml | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c1ca176..833d890 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,20 +12,8 @@ jobs: strategy: fail-fast: false matrix: + postgres-version: [14, 15, 16, 17] os: [ubuntu-latest, ubuntu-24.04, windows-latest, windows-2019, macos-latest, macos-13] - include: - - os: ubuntu-latest - postgres-version: '17' - - os: ubuntu-24.04 - postgres-version: '17' - - os: windows-latest - postgres-version: '17' - - os: windows-2019 - postgres-version: '17' - - os: macos-latest - postgres-version: '17' - - os: macos-13 - postgres-version: '17' runs-on: ${{ matrix.os }} From 136f1ca42b58ecbfdf9a11cc7bf13dbfe4274e9f Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 16:51:14 +0800 Subject: [PATCH 31/32] try fix --- scripts/install-ubuntu.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/install-ubuntu.sh b/scripts/install-ubuntu.sh index ccd820f..e0c6a4c 100644 --- a/scripts/install-ubuntu.sh +++ b/scripts/install-ubuntu.sh @@ -50,6 +50,8 @@ rm -rf pgvector echo "local all postgres trust" | sudo tee /etc/postgresql/${PG_VERSION}/main/pg_hba.conf echo "local all runner trust" | sudo tee -a /etc/postgresql/${PG_VERSION}/main/pg_hba.conf echo "local all all trust" | sudo tee -a /etc/postgresql/${PG_VERSION}/main/pg_hba.conf +echo "host all all 127.0.0.1/32 trust" | sudo tee -a /etc/postgresql/${PG_VERSION}/main/pg_hba.conf +echo "host all all ::1/128 trust" | sudo tee -a /etc/postgresql/${PG_VERSION}/main/pg_hba.conf # Restart PostgreSQL to ensure pgvector is loaded sudo systemctl restart postgresql From 20f0cdb3ae4c351d0e5f2e60a451f7457978f23d Mon Sep 17 00:00:00 2001 From: Li Jie Date: Mon, 9 Dec 2024 16:56:03 +0800 Subject: [PATCH 32/32] try fix --- README.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b5a34c5..b314c3f 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,19 @@ GitHub Action and scripts to set up PostgreSQL with pgvector extension for vecto - 🌐 Cross-platform support: Ubuntu, Windows (MSYS2), and macOS - 🏗️ Builds pgvector from source for maximum compatibility +## Supported Platforms + +The following table shows the compatibility matrix for different PostgreSQL versions and platforms: + +| Platform | Architecture | PostgreSQL 14 | PostgreSQL 15 | PostgreSQL 16 | PostgreSQL 17 | +|----------|-------------|:-------------:|:-------------:|:-------------:|:-------------:| +| Ubuntu Latest | x86_64 | ✅ | ✅ | ✅ | ✅ | +| Ubuntu 24.04 | x86_64 | ✅ | ✅ | ✅ | ✅ | +| Windows Latest | x86_64 | ✅ | ✅ | ✅ | ✅ | +| Windows 2019 | x86_64 | ✅ | ✅ | ✅ | ✅ | +| macOS Latest | arm64 | ✅ | ✅ | ✅ | ✅ | +| macOS 13 | x86_64 | ✅ | ✅ | ✅ | ✅ | + ## Quick Start ### GitHub Actions @@ -124,12 +137,6 @@ psql -h localhost -U myuser -d mydb psql -h localhost -U myuser -d mydb ``` -## Supported Platforms - -- Ubuntu (latest, 24.04) -- Windows (latest, 2019) -- macOS (latest, 13) - ## Notes - The scripts will install PostgreSQL if not already installed