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 :
2828 RUST_TOOLCHAIN : ${{ matrix.rust || 'stable' }}
2929 steps :
3030 - uses : actions/checkout@v4
31+
32+
33+ - name : Set up Rust
34+ uses : actions-rs/toolchain@v1
35+ with :
36+ toolchain : stable
37+ override : true
38+
39+ - name : Install PostgreSQL (Linux)
40+ if : runner.os == 'Linux'
41+ run : |
42+ sudo apt-get install -y wget gnupg
43+ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
44+ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
45+ sudo apt-get update -y -qq --fix-missing
46+ sudo apt-get install -y postgresql-${{ matrix.pg }} postgresql-server-dev-${{ matrix.pg }}
47+
48+ 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/
49+
50+ - name : Install PostgreSQL (macOS)
51+ if : runner.os == 'macOS'
52+ run : |
53+ brew install postgresql@${{ matrix.pg_version }}
54+ echo "/usr/local/opt/postgresql@${{ matrix.pg_version }}/bin" >> $GITHUB_PATH
55+
56+
3157 - name : Set up prerequisites and environment
3258 run : |
3359 sudo apt-get update -y -qq --fix-missing
6288 env
6389 echo ""
6490
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-
8591 - name : Cache cargo registry
8692 uses : actions/cache@v4
8793 continue-on-error : false
@@ -139,17 +145,41 @@ jobs:
139145 run : sccache --stop-server || true
140146 Install :
141147 runs-on : ubuntu-latest
148+ strategy :
149+ matrix :
150+ os : [ "buildjet-4vcpu-ubuntu-2204" ]
151+ pg : [ "16" ]
142152 steps :
143153 - uses : actions/checkout@v4
144- - name : Install PostgreSQL headers
154+
155+ - name : Set up Rust
156+ uses : actions-rs/toolchain@v1
157+ with :
158+ toolchain : stable
159+ override : true
160+
161+ - name : Install PostgreSQL (Linux)
162+ if : runner.os == 'Linux'
145163 run : |
146- sudo apt-get update
147- sudo apt-get install postgresql-server-dev-14
164+ sudo apt-get install -y wget gnupg
165+ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
166+ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
167+ sudo apt-get update -y -qq --fix-missing
168+ sudo apt-get install -y postgresql-${{ matrix.pg }} postgresql-server-dev-${{ matrix.pg }}
169+
170+ 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/
171+
172+ - name : Install PostgreSQL (macOS)
173+ if : runner.os == 'macOS'
174+ run : |
175+ brew install postgresql@${{ matrix.pg }}
176+ echo "/usr/local/opt/postgresql@${{ matrix.pg }}/bin" >> $GITHUB_PATH
177+
148178 - name : Install cargo-pgrx
149179 run : |
150180 PGRX_VERSION=$(cargo metadata --format-version 1 | jq -r '.packages[]|select(.name=="pgrx")|.version')
151181 cargo install --locked --version=$PGRX_VERSION cargo-pgrx --debug --force
152- cargo pgrx init --pg14 $(which pg_config)
182+ cargo pgrx init --pg${{ matrix.pg }} $(which pg_config)
153183 - name : Install TypeID/pgrx
154184 run : |
155185 cargo pgrx install --no-default-features --release --sudo
@@ -170,4 +200,78 @@ jobs:
170200 - name : Checkout code
171201 uses : actions/checkout@v4
172202 - name : Run rustfmt
173- run : cargo fmt -- --check
203+ run : cargo fmt -- --check
204+ Migration :
205+ runs-on : ubuntu-latest
206+ steps :
207+ - uses : actions/checkout@v4
208+
209+ - name : Install PostgreSQL
210+ run : |
211+ sudo apt-get update
212+ sudo apt-get install -y wget gnupg
213+ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
214+ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
215+ sudo apt-get update -y -qq --fix-missing
216+ sudo apt-get install postgresql-16 postgresql-server-dev-16
217+
218+ - name : Install cargo-pgrx
219+ run : |
220+ PGRX_VERSION=$(cargo metadata --format-version 1 | jq -r '.packages[]|select(.name=="pgrx")|.version')
221+ cargo install --locked --version=$PGRX_VERSION cargo-pgrx --debug --force
222+ cargo pgrx init --pg16 $(which pg_config)
223+
224+ - name : Build and install current version
225+ run : |
226+ # Build and install the current version which supports both v0.1.0 and v0.2.0
227+ cargo pgrx package --release --pg-config $(which pg_config)
228+ sudo cp target/release/typeid-pg16/usr/share/postgresql/16/extension/* /usr/share/postgresql/16/extension/
229+ sudo cp target/release/typeid-pg16/usr/lib/postgresql/16/lib/* /usr/lib/postgresql/16/lib/
230+
231+ - name : Start PostgreSQL and create test database
232+ run : |
233+ sudo systemctl start postgresql.service
234+ sudo -u postgres createuser -s -d -r -w runner
235+ createdb -U runner test_migration
236+
237+ - name : Install v0.1.0 and create test data
238+ run : |
239+ psql -U runner -d test_migration -c "CREATE EXTENSION typeid VERSION '0.1.0';"
240+ psql -U runner -d test_migration -c "
241+ CREATE TABLE migration_test (id typeid, name text);
242+ INSERT INTO migration_test VALUES
243+ (typeid_generate('user'), 'Alice'),
244+ (typeid_generate('admin'), 'Bob'),
245+ (typeid_generate(''), 'Anonymous');
246+ "
247+ # Verify v0.1.0 works
248+ psql -U runner -d test_migration -c "SELECT COUNT(*) FROM migration_test;"
249+
250+ - name : Verify v0.2.0 files are installed
251+ run : |
252+ # Check that all extension files are properly installed
253+ ls -la /usr/share/postgresql/16/extension/typeid*
254+ ls -la /usr/lib/postgresql/16/lib/typeid*
255+
256+ - name : Run migration to v0.2.0
257+ run : |
258+ psql -U runner -d test_migration -c "ALTER EXTENSION typeid UPDATE TO '0.2.0';"
259+ psql -U runner -d test_migration -c "SELECT extversion FROM pg_extension WHERE extname = 'typeid';"
260+
261+ - name : Verify migration worked
262+ run : |
263+ # Test old data still works
264+ psql -U runner -d test_migration -c "SELECT COUNT(*) FROM migration_test;"
265+ psql -U runner -d test_migration -c "SELECT typeid_prefix(id) FROM migration_test;"
266+
267+ # Test new v0.2.0 functions work
268+ psql -U runner -d test_migration -c "SELECT typeid_generate_nil();"
269+ psql -U runner -d test_migration -c "SELECT typeid_is_valid('user_01h455vb4pex5vsknk084sn02q');"
270+ psql -U runner -d test_migration -c "SELECT COUNT(*) FROM migration_test WHERE id @> 'user';"
271+ psql -U runner -d test_migration -c "SELECT typeid_has_prefix(typeid_generate('test'), 'test');"
272+
273+ # Test that old and new work together
274+ psql -U runner -d test_migration -c "
275+ INSERT INTO migration_test VALUES (typeid_generate_nil(), 'NewUser');
276+ SELECT COUNT(*) FROM migration_test WHERE typeid_is_nil_prefix(id);
277+ "
0 commit comments