Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
strategy:
fail-fast: false # We want all of them to run, even if one fails
matrix:
os: [ "buildjet-4vcpu-ubuntu-2204" ]
pg: [ "13", "14", "15", "16", "17" ]
os: ["buildjet-4vcpu-ubuntu-2204"]
pg: ["13", "14", "15", "16", "17", "18"]

runs-on: ${{ matrix.os }}
env:
RUSTC_WRAPPER: sccache
Expand Down Expand Up @@ -54,11 +54,10 @@ jobs:
brew install postgresql@${{ matrix.pg_version }}
echo "/usr/local/opt/postgresql@${{ matrix.pg_version }}/bin" >> $GITHUB_PATH


- name: Set up prerequisites and environment
run: |
sudo apt-get update -y -qq --fix-missing

echo ""
echo "----- Install sccache -----"
mkdir -p $HOME/.local/bin
Expand All @@ -68,11 +67,11 @@ jobs:
echo "$HOME/.local/bin" >> $GITHUB_PATH
mkdir -p /home/runner/.cache/sccache
echo ""

echo "----- Set up dynamic variables -----"
cat $GITHUB_ENV
echo ""

echo "----- Install system dependencies -----"
sudo apt-get install -y \
build-essential \
Expand All @@ -88,7 +87,7 @@ jobs:
echo "----- Print env -----"
env
echo ""

- name: Cache cargo registry
uses: actions/cache@v4
continue-on-error: false
Expand Down Expand Up @@ -118,7 +117,7 @@ jobs:
cargo pgrx init --pg${{ matrix.pg }} /usr/lib/postgresql/${{ matrix.pg }}/bin/pg_config
- name: Run tests
run: echo "\q" | cargo pgrx run pg${{ matrix.pg }} && cargo test --no-default-features --features pg${{ matrix.pg }}

- name: Build
run: cargo pgrx package --features pg${{ matrix.pg }} --pg-config /usr/lib/postgresql/${{ matrix.pg }}/bin/pg_config

Expand Down Expand Up @@ -148,8 +147,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ "buildjet-4vcpu-ubuntu-2204" ]
pg: [ "16" ]
os: ["buildjet-4vcpu-ubuntu-2204"]
pg: ["16"]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -201,4 +200,4 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- name: Run rustfmt
run: cargo fmt -- --check
run: cargo fmt -- --check
46 changes: 23 additions & 23 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build • Publish • Release
# We still build + release when a tag like v1.2.3 is pushed
on:
push:
tags: ['v*']
tags: ["v*"]

permissions:
contents: write
Expand All @@ -12,21 +12,23 @@ permissions:

env:
EXTENSION_NAME: typeid
DOCKER_IMAGE: ghcr.io/blitss/typeid-pg
DOCKER_IMAGE: ghcr.io/blitss/typeid-pg

jobs:

# -------------------------------------------------------------
# 1. Build binaries for every PG version / OS / arch
# -------------------------------------------------------------
build-and-publish:
strategy:
fail-fast: false
matrix:
pg_version: [13, 14, 15, 16, 17]
os: [buildjet-4vcpu-ubuntu-2204,
buildjet-4vcpu-ubuntu-2204-arm,
macos-latest]
pg_version: [13, 14, 15, 16, 17, 18]
os:
[
buildjet-4vcpu-ubuntu-2204,
buildjet-4vcpu-ubuntu-2204-arm,
macos-latest,
]

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

Expand All @@ -38,7 +40,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
override: true

# --- PostgreSQL (Linux) ------------------------------------------
- name: Install PostgreSQL (Linux)
Expand Down Expand Up @@ -114,7 +116,6 @@ jobs:
path: release/*.tar.gz
retention-days: 29


# -------------------------------------------------------------
# 2. Build & push the multi-arch Docker image
# -------------------------------------------------------------
Expand All @@ -124,7 +125,7 @@ jobs:
strategy:
fail-fast: false
matrix:
pg_version: [13, 14, 15, 16, 17]
pg_version: [13, 14, 15, 16, 17, 18]
steps:
- uses: actions/checkout@v4

Expand All @@ -149,30 +150,29 @@ jobs:
images: ${{ env.DOCKER_IMAGE }}
tags: |
type=raw,value=${{ matrix.pg_version }}
type=raw,value=latest,enable=${{ matrix.pg_version == 17 }}
type=raw,value=${{ github.ref_name }},enable=${{ matrix.pg_version == 17 }}
type=raw,value=latest,enable=${{ matrix.pg_version == 18 }}
type=raw,value=${{ github.ref_name }},enable=${{ matrix.pg_version == 18 }}

- name: Build & push
uses: docker/build-push-action@v4
with:
context: .
push: true
push: true
platforms: linux/amd64,linux/arm64
build-args: |
PG_VERSION=${{ matrix.pg_version }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}


# -------------------------------------------------------------
# 3. Draft / publish the GitHub Release
# -------------------------------------------------------------
release:
needs: [build-and-publish]
runs-on: ubuntu-latest
permissions:
contents: write # create / update the release
packages: write # attach artifacts
contents: write # create / update the release
packages: write # attach artifacts
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -193,9 +193,9 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: ${{ github.ref_name }} # the tag we just pushed
publish: false # keep as draft for now
prerelease: false # we'll flip below
tag: ${{ github.ref_name }} # the tag we just pushed
publish: false # keep as draft for now
prerelease: false # we'll flip below
config-name: release-drafter.yml

# --- 3-c. Flip logic: ONLY "main" ⇒ final ------------------------
Expand All @@ -213,11 +213,11 @@ jobs:
- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
with:
name: ${{ steps.notes.outputs.name }}
tag_name: ${{ steps.notes.outputs.tag_name }}
body: ${{ steps.notes.outputs.body }}
name: ${{ steps.notes.outputs.name }}
tag_name: ${{ steps.notes.outputs.tag_name }}
body: ${{ steps.notes.outputs.body }}
prerelease: ${{ steps.prerelease.outputs.is_pre }}
draft: false
draft: false
files: |
release/*.tar.gz
env:
Expand Down
25 changes: 12 additions & 13 deletions .github/workflows/test-migrations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install PostgreSQL
run: |
sudo apt-get update
Expand All @@ -24,19 +24,19 @@ jobs:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update -y -qq --fix-missing
sudo apt-get install postgresql-16 postgresql-server-dev-16
- name: Install v0.1.0

- name: Install previous latest version
run: |
# Install.sh will by default install the latest stable release that we'll need to test against.
sudo bash install.sh

- name: Start PostgreSQL and create test database
run: |
sudo systemctl start postgresql.service
sudo -u postgres createuser -s -d -r -w runner
createdb -U runner test_extension
- name: Install v0.1.0 and create test data

- name: Create test data
run: |
psql -U runner -d test_extension -c "CREATE EXTENSION typeid;"
psql -U runner -d test_extension -c "
Expand All @@ -48,31 +48,30 @@ jobs:
# Verify v0.1.0 works
psql -U runner -d test_extension -c "SELECT COUNT(*) FROM migration_test;"
psql -U runner -d test_extension -c "SELECT typeid_generate('user') FROM migration_test;"



- name: Install cargo-pgrx
run: |
PGRX_VERSION=$(cargo metadata --format-version 1 | jq -r '.packages[]|select(.name=="pgrx")|.version')
cargo install --locked --version=$PGRX_VERSION cargo-pgrx --debug --force
cargo pgrx init --pg16 $(which pg_config)

- name: Install latest version and test migration
run: |
# Build the new version and install
cargo pgrx package --features pg16 --pg-config $(which pg_config)
cargo pgrx install --features pg16 --release --sudo

# Perform the migration
psql -U runner -d test_extension -c "ALTER EXTENSION typeid UPDATE;"
psql -U runner -d test_extension -c "SELECT extversion FROM pg_extension WHERE extname = 'typeid';"

# Verify old data still works
psql -U runner -d test_extension -c "SELECT COUNT(*) FROM migration_test;"
psql -U runner -d test_extension -c "SELECT typeid_prefix(id) FROM migration_test;"

# Test new functions
# todo: should extract that to a test sql file
psql -U runner -d test_extension -c "SELECT typeid_generate_nil();"
psql -U runner -d test_extension -c "SELECT typeid_is_valid('user_01h455vb4pex5vsknk084sn02q');"
psql -U runner -d test_extension -c "SELECT COUNT(*) FROM migration_test WHERE id @> 'user';"
psql -U runner -d test_extension -c "SELECT typeid_has_prefix(typeid_generate('test'), 'test');"
psql -U runner -d test_extension -c "SELECT typeid_has_prefix(typeid_generate('test'), 'test');"
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"rust-analyzer.cargo.features": [
"pg17"
],
"rust-analyzer.cargo.noDefaultFeatures": true
}
15 changes: 8 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "typeid"
version = "0.2.0"
version = "0.3.0"
edition = "2021"

[lib]
Expand All @@ -11,23 +11,24 @@ name = "pgrx_embed_typeid"
path = "./src/bin/pgrx_embed.rs"

[features]
default = ["pg17"]
default = ["pg18"]
pg13 = ["pgrx/pg13", "pgrx-tests/pg13" ]
pg14 = ["pgrx/pg14", "pgrx-tests/pg14" ]
pg15 = ["pgrx/pg15", "pgrx-tests/pg15" ]
pg16 = ["pgrx/pg16", "pgrx-tests/pg16" ]
pg17 = ["pgrx/pg17", "pgrx-tests/pg17" ]
pg18 = ["pgrx/pg18", "pgrx-tests/pg18" ]
pg_test = []

[dependencies]
gxhash = { version = "3.5.0" }
pgrx = "=0.15.0"
serde = "1.0.219"
thiserror = "2.0.12"
uuid = { version = "1.17", features = ["v7", "fast-rng", "serde"] }
pgrx = "=0.16.1"
serde = "1.0.228"
thiserror = "2.0.17"
uuid = { version = "1.18", features = ["v7", "fast-rng", "serde"] }

[dev-dependencies]
pgrx-tests = "=0.15.0"
pgrx-tests = "=0.16.1"
serde_yaml = "0.9"
libtest-mimic = "0.8"

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG PG_VERSION=16
ARG PG_VERSION=18
FROM postgres:${PG_VERSION}

RUN apt update && apt install -y curl
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 Andrew Vasilyev
Copyright (c) 2025 Andrew Vasilyev

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
8 changes: 4 additions & 4 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,30 +60,30 @@ curl -sSL https://raw.githubusercontent.com/blitss/typeid-postgres/refs/heads/ma
Or you can specify the pg_config directly:

```bash
curl -sSL https://raw.githubusercontent.com/blitss/typeid-postgres/refs/heads/main/install.sh | sudo bash -s -- /usr/pgsql-16/bin/pg_config
curl -sSL https://raw.githubusercontent.com/blitss/typeid-postgres/refs/heads/main/install.sh | sudo bash -s -- /usr/pgsql-18/bin/pg_config
```

You can upgrade the same way and then run `ALTER EXTENSION typeid UPDATE;` in your Postgres database to run migration scripts.

3) By building extension manually

Prerequisites:
* Postgres 13.x-17.x installed (probably from your package manager), including the "-server" package
* Postgres 13.x-18.x installed (probably from your package manager), including the "-server" package

* The Rust toolchain

* A 64bit Intel Architecture

Windows is not supported due to pgrx limitations.

Run these commands (replace pg13 with your pg version and `which pg_config` part with your pg path if necessary):
Run these commands (replace pg18 with your pg version and `which pg_config` part with your pg path if necessary):

```bash
git clone https://github.com/blitss/typeid-postgres-extension.git
cd typeid-postgres-extension
cargo install cargo-pgx

cargo pgx init --pg13=`which pg_config`
cargo pgx init --pg18=`which pg_config`
cargo pgx install --release --sudo
```

Expand Down
3 changes: 3 additions & 0 deletions sql/typeid--0.2.0--0.3.0.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/*
nothing changed in terms of schema
*/
Loading
Loading