Skip to content

Commit 448f4a0

Browse files
committed
fix: drop support for 11 and 12 and add migration test
1 parent 75600c5 commit 448f4a0

File tree

3 files changed

+131
-29
lines changed

3 files changed

+131
-29
lines changed

.github/workflows/ci.yaml

Lines changed: 129 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ jobs:
1818
strategy:
1919
fail-fast: false # We want all of them to run, even if one fails
2020
matrix:
21-
os: [ "ubuntu-latest" ]
22-
pg: [ "12", "13", "14", "15", "16" ]
21+
os: [ "buildjet-4vcpu-ubuntu-2204" ]
22+
pg: [ "13", "14", "15", "16", "17" ]
2323

2424
runs-on: ${{ matrix.os }}
2525
env:
@@ -28,6 +28,30 @@ jobs:
2828
RUST_TOOLCHAIN: ${{ matrix.rust || 'stable' }}
2929
steps:
3030
- uses: actions/checkout@v4
31+
- name: Set up Rust
32+
uses: actions-rs/toolchain@v1
33+
with:
34+
toolchain: stable
35+
override: true
36+
37+
- name: Install PostgreSQL (Linux)
38+
if: runner.os == 'Linux'
39+
run: |
40+
sudo apt-get install -y wget gnupg
41+
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
42+
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
43+
sudo apt-get update -y -qq --fix-missing
44+
sudo apt-get install -y postgresql-${{ matrix.pg }} postgresql-server-dev-${{ matrix.pg }}
45+
46+
sudo chmod a+rwx `/usr/lib/postgresql/${{ matrix.pg }}/bin/pg_config --pkglibdir` `/usr/lib/postgresql/${{ matrix.pg }}/bin/pg_config --sharedir`/extension /var/run/postgresql/
47+
48+
- name: Install PostgreSQL (macOS)
49+
if: runner.os == 'macOS'
50+
run: |
51+
brew install postgresql@${{ matrix.pg_version }}
52+
echo "/usr/local/opt/postgresql@${{ matrix.pg_version }}/bin" >> $GITHUB_PATH
53+
54+
3155
- name: Set up prerequisites and environment
3256
run: |
3357
sudo apt-get update -y -qq --fix-missing
@@ -62,26 +86,6 @@ jobs:
6286
env
6387
echo ""
6488
65-
- name: Install release version of PostgreSQL
66-
run: |
67-
echo "----- Set up PostgreSQL Apt repository -----"
68-
sudo apt-get install -y wget gnupg
69-
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
70-
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
71-
sudo apt-get update -y -qq --fix-missing
72-
echo ""
73-
74-
sudo apt-get install -y \
75-
postgresql-${{ matrix.pg }} \
76-
postgresql-server-dev-${{ matrix.pg }}
77-
78-
echo ""
79-
echo "----- pg_config -----"
80-
pg_config
81-
echo ""
82-
- name: Set up PostgreSQL permissions
83-
run: sudo chmod a+rwx `/usr/lib/postgresql/${{ matrix.pg }}/bin/pg_config --pkglibdir` `/usr/lib/postgresql/${{ matrix.pg }}/bin/pg_config --sharedir`/extension /var/run/postgresql/
84-
8589
- name: Cache cargo registry
8690
uses: actions/cache@v4
8791
continue-on-error: false
@@ -139,17 +143,41 @@ jobs:
139143
run: sccache --stop-server || true
140144
Install:
141145
runs-on: ubuntu-latest
146+
strategy:
147+
matrix:
148+
os: [ "buildjet-4vcpu-ubuntu-2204" ]
149+
pg: [ "16" ]
142150
steps:
143151
- uses: actions/checkout@v4
144-
- name: Install PostgreSQL headers
152+
153+
- name: Set up Rust
154+
uses: actions-rs/toolchain@v1
155+
with:
156+
toolchain: stable
157+
override: true
158+
159+
- name: Install PostgreSQL (Linux)
160+
if: runner.os == 'Linux'
145161
run: |
146-
sudo apt-get update
147-
sudo apt-get install postgresql-server-dev-14
162+
sudo apt-get install -y wget gnupg
163+
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
164+
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
165+
sudo apt-get update -y -qq --fix-missing
166+
sudo apt-get install -y postgresql-${{ matrix.pg }} postgresql-server-dev-${{ matrix.pg }}
167+
168+
sudo chmod a+rwx `/usr/lib/postgresql/${{ matrix.pg }}/bin/pg_config --pkglibdir` `/usr/lib/postgresql/${{ matrix.pg }}/bin/pg_config --sharedir`/extension /var/run/postgresql/
169+
170+
- name: Install PostgreSQL (macOS)
171+
if: runner.os == 'macOS'
172+
run: |
173+
brew install postgresql@${{ matrix.pg }}
174+
echo "/usr/local/opt/postgresql@${{ matrix.pg }}/bin" >> $GITHUB_PATH
175+
148176
- name: Install cargo-pgrx
149177
run: |
150178
PGRX_VERSION=$(cargo metadata --format-version 1 | jq -r '.packages[]|select(.name=="pgrx")|.version')
151179
cargo install --locked --version=$PGRX_VERSION cargo-pgrx --debug --force
152-
cargo pgrx init --pg14 $(which pg_config)
180+
cargo pgrx init --pg${{ matrix.pg }} $(which pg_config)
153181
- name: Install TypeID/pgrx
154182
run: |
155183
cargo pgrx install --no-default-features --release --sudo
@@ -170,4 +198,78 @@ jobs:
170198
- name: Checkout code
171199
uses: actions/checkout@v4
172200
- name: Run rustfmt
173-
run: cargo fmt -- --check
201+
run: cargo fmt -- --check
202+
Migration:
203+
runs-on: ubuntu-latest
204+
steps:
205+
- uses: actions/checkout@v4
206+
207+
- name: Install PostgreSQL
208+
run: |
209+
sudo apt-get update
210+
sudo apt-get install -y wget gnupg
211+
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
212+
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
213+
sudo apt-get update -y -qq --fix-missing
214+
sudo apt-get install postgresql-16 postgresql-server-dev-16
215+
216+
- name: Install cargo-pgrx
217+
run: |
218+
PGRX_VERSION=$(cargo metadata --format-version 1 | jq -r '.packages[]|select(.name=="pgrx")|.version')
219+
cargo install --locked --version=$PGRX_VERSION cargo-pgrx --debug --force
220+
cargo pgrx init --pg16 $(which pg_config)
221+
222+
- name: Build and install current version
223+
run: |
224+
# Build and install the current version which supports both v0.1.0 and v0.2.0
225+
cargo pgrx package --features pg16 --pg-config $(which pg_config)
226+
sudo cp target/release/typeid-pg16/usr/share/postgresql/16/extension/* /usr/share/postgresql/16/extension/
227+
sudo cp target/release/typeid-pg16/usr/lib/postgresql/16/lib/* /usr/lib/postgresql/16/lib/
228+
229+
- name: Start PostgreSQL and create test database
230+
run: |
231+
sudo systemctl start postgresql.service
232+
sudo -u postgres createuser -s -d -r -w runner
233+
createdb -U runner test_migration
234+
235+
- name: Install v0.1.0 and create test data
236+
run: |
237+
psql -U runner -d test_migration -c "CREATE EXTENSION typeid VERSION '0.1.0';"
238+
psql -U runner -d test_migration -c "
239+
CREATE TABLE migration_test (id typeid, name text);
240+
INSERT INTO migration_test VALUES
241+
(typeid_generate('user'), 'Alice'),
242+
(typeid_generate('admin'), 'Bob'),
243+
(typeid_generate(''), 'Anonymous');
244+
"
245+
# Verify v0.1.0 works
246+
psql -U runner -d test_migration -c "SELECT COUNT(*) FROM migration_test;"
247+
248+
- name: Verify v0.2.0 files are installed
249+
run: |
250+
# Check that all extension files are properly installed
251+
ls -la /usr/share/postgresql/16/extension/typeid*
252+
ls -la /usr/lib/postgresql/16/lib/typeid*
253+
254+
- name: Run migration to v0.2.0
255+
run: |
256+
psql -U runner -d test_migration -c "ALTER EXTENSION typeid UPDATE TO '0.2.0';"
257+
psql -U runner -d test_migration -c "SELECT extversion FROM pg_extension WHERE extname = 'typeid';"
258+
259+
- name: Verify migration worked
260+
run: |
261+
# Test old data still works
262+
psql -U runner -d test_migration -c "SELECT COUNT(*) FROM migration_test;"
263+
psql -U runner -d test_migration -c "SELECT typeid_prefix(id) FROM migration_test;"
264+
265+
# Test new v0.2.0 functions work
266+
psql -U runner -d test_migration -c "SELECT typeid_generate_nil();"
267+
psql -U runner -d test_migration -c "SELECT typeid_is_valid('user_01h455vb4pex5vsknk084sn02q');"
268+
psql -U runner -d test_migration -c "SELECT COUNT(*) FROM migration_test WHERE id @> 'user';"
269+
psql -U runner -d test_migration -c "SELECT typeid_has_prefix(typeid_generate('test'), 'test');"
270+
271+
# Test that old and new work together
272+
psql -U runner -d test_migration -c "
273+
INSERT INTO migration_test VALUES (typeid_generate_nil(), 'NewUser');
274+
SELECT COUNT(*) FROM migration_test WHERE typeid_is_nil_prefix(id);
275+
"

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
strategy:
2020
fail-fast: false # We want all of them to run, even if one fails
2121
matrix:
22-
pg_version: [12, 13, 14, 15, 16]
22+
pg_version: [13, 14, 15, 16, 17]
2323
os: [buildjet-4vcpu-ubuntu-2204, buildjet-4vcpu-ubuntu-2204-arm, macos-latest]
2424

2525
runs-on: ${{ matrix.os }}

src/bin/pgrx_embed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
::pgrx::pgrx_embed!();
1+
::pgrx::pgrx_embed!();

0 commit comments

Comments
 (0)