Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pgrx): support pg16, update pgrx #45

Merged
merged 1 commit into from
Dec 12, 2023
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
64 changes: 46 additions & 18 deletions .github/workflows/build-and-test/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,17 @@ runs:
${{ inputs.sccache-dir }}
key: pg_idkit-tests-sccache-${{ inputs.rust-container-version }}-cargo-${{ runner.os }}

###############
# Build/Tests #
###############
- name: Cache pgrx init
uses: actions/cache@v3
continue-on-error: false
with:
path: |
/home/${{ inputs.user }}/.pgrx
key: pg_idkit-tests-pgrx-init-${{ inputs.rust-container-version }}-cargo-${{ runner.os }}

#########
# Setup #
#########

- name: Add idkit to group
shell: bash
Expand All @@ -88,6 +96,41 @@ runs:
git config --global --add safe.directory /__w/pg_idkit/pg_idkit
su idkit -c "git config --global --add safe.directory /__w/pg_idkit/pg_idkit"


- name: Reinstall deps due to GLIBC issue
if: ${{ inputs.artifact-upload }}
shell: bash
env:
CARGO_HOME: ${{ inputs.cargo-home-dir }}
CARGO_TARGET_DIR: ${{ inputs.cargo-target-dir }}
SCCACHE_DIR: ${{ inputs.sccache-dir }}
CARGO_BUILD_RUSTC_WRAPPER: ${{ inputs.cargo-build-rustc-wrapper }}
CARGO_INCREMENTAL: ${{ inputs.cargo-env-incrmental }}
CARGO_PROFILE: ${{ inputs.cargo-profile }}
USER: ${{ inputs.user }}
PGRX_PKG_PATH_PREFIX: ${{ inputs.cargo-target-dir }}
run: |
su idkit -c "cargo install --force cargo-get cargo-edit"

###############
# Build/Tests #
###############

# Initialize cargo-pgrx if necessary
- name: Initialize cargo-pgrx
shell: bash
env:
CARGO_BUILD_RUSTC_WRAPPER: ${{ inputs.cargo-build-rustc-wrapper }}
CARGO_HOME: ${{ inputs.cargo-home-dir }}
CARGO_INCREMENTAL: ${{ inputs.cargo-env-incrmental }}
CARGO_PROFILE: ${{ inputs.cargo-profile }}
CARGO_TARGET_DIR: ${{ inputs.cargo-target-dir }}
PGRX_PKG_PATH_PREFIX: ${{ inputs.cargo-target-dir }}
SCCACHE_DIR: ${{ inputs.sccache-dir }}
USER: ${{ inputs.user }}
run: |
su idkit -c "just pgrx-init"

# Run cargo check
- name: Run cargo check
shell: bash
Expand Down Expand Up @@ -136,21 +179,6 @@ runs:
# Artifacts #
#############

- name: Reinstall deps due to GLIBC issue
if: ${{ inputs.artifact-upload }}
shell: bash
env:
CARGO_HOME: ${{ inputs.cargo-home-dir }}
CARGO_TARGET_DIR: ${{ inputs.cargo-target-dir }}
SCCACHE_DIR: ${{ inputs.sccache-dir }}
CARGO_BUILD_RUSTC_WRAPPER: ${{ inputs.cargo-build-rustc-wrapper }}
CARGO_INCREMENTAL: ${{ inputs.cargo-env-incrmental }}
CARGO_PROFILE: ${{ inputs.cargo-profile }}
USER: ${{ inputs.user }}
PGRX_PKG_PATH_PREFIX: ${{ inputs.cargo-target-dir }}
run: |
su idkit -c "cargo install --force cargo-get cargo-edit"

# Run cargo test
- name: Build a package
if: ${{ inputs.artifact-upload }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-rpm/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ inputs:
Architecture to use while building the RPM
pgrx-version:
type: string
default: pg15
default: pg16
decription: |
PGRX version (ex. 'pg15', 'pg16')
outputs: {}
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ jobs:
arch: x86_64
pgrx:
version: pg15
- rpm:
arch: x86_64
pgrx:
version: pg16
steps:
- uses: actions/checkout@v3

Expand Down
12 changes: 11 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ crate-type = ["cdylib"]
maintenance = { status = "actively-maintained" }

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

[dependencies]
Expand Down Expand Up @@ -105,3 +106,12 @@ assets = [
]
requires = { postgresql-server = "> 15", glibc = "*" }
release = "pg15"

[package.metadata.generate-rpm.variants.pg16]
assets = [
{ source = "/tmp/pg_idkit/rpm/scratch/pgrx-install/lib/postgresql/pg_idkit.so", dest = "/usr/lib64/pgsql/pg_idkit.so", mode = "755" },
{ source = "/tmp/pg_idkit/rpm/scratch/pgrx-install/share/postgresql/extension/pg_idkit--0.1.0.sql", dest = "/usr/share/pgsql/extension/pg_idkit--0.1.0.sql", mode = "755" },
{ source = "/tmp/pg_idkit/rpm/scratch/pgrx-install/share/postgresql/extension/pg_idkit.control", dest = "/usr/share/pgsql/extension/pg_idkit.control", mode = "755" },
]
requires = { postgresql-server = "> 15", glibc = "*" }
release = "pg16"
19 changes: 13 additions & 6 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ cargo_features_arg := if cargo_features != "" {

changelog_file_path := absolute_path(justfile_directory() / "CHANGELOG")

pkg_pg_version := env_var_or_default("PKG_PG_VERSION", "15.5")
pkg_pg_version := env_var_or_default("PKG_PG_VERSION", "16.1")
pkg_pg_config_path := env_var_or_default("PKG_PG_CONFIG_PATH", "~/.pgrx/" + pkg_pg_version + "/pgrx-install/bin/pg_config")

pgrx_pg_version := env_var_or_default("PGRX_PG_VERSION", "pg15")
pgrx_pg_version := env_var_or_default("PGRX_PG_VERSION", "pg16")
pgrx_pkg_path_prefix := env_var_or_default("PGRX_PKG_PATH_PREFIX", "target")
pgrx_pkg_output_dir := pgrx_pkg_path_prefix / "release" / "pg_idkit-" + pgrx_pg_version / "home" / user / ".pgrx" / pkg_pg_version / "pgrx-install"

Expand Down Expand Up @@ -82,6 +82,9 @@ print-revision:
#!/usr/bin/env -S bash -euo pipefail
echo -n `{{just}} get-revision`

print-pkg-output-dir:
echo -n {{pgrx_pkg_output_dir}}

changelog:
{{git}} cliff --unreleased --tag={{version}} --prepend={{changelog_file_path}}

Expand Down Expand Up @@ -110,20 +113,24 @@ package:
cp -r $({{just}} print-pkg-output-dir)/* pkg/pg_idkit-$({{just}} print-version)
{{tar}} -C pkg -cvf pg_idkit-$(just print-version).tar.gz pg_idkit-$({{just}} print-version)

print-pkg-output-dir:
echo -n {{pgrx_pkg_output_dir}}

test:
{{cargo}} test {{cargo_profile_arg}}
{{cargo}} pgrx test

pgrx-init:
#!/usr/bin/env -S bash -euo pipefail
if [ ! -d "{{pkg_pg_config_path}}" ]; then
echo "failed to find pgrx init dir [{{pkg_pg_config_path}}], running pgrx init...";
{{cargo}} pgrx init
fi

##########
# Docker #
##########

container_img_arch := env_var_or_default("CONTAINER_IMAGE_ARCH", "amd64")

pg_image_version := env_var_or_default("POSTGRES_IMAGE_VERSION", "15.5")
pg_image_version := env_var_or_default("POSTGRES_IMAGE_VERSION", "16.1")
pg_os_image_version := env_var_or_default("POSTGRES_OS_IMAGE_VERSION", "alpine3.18")

pgidkit_image_name := env_var_or_default("PGIDKIT_IMAGE_NAME", "ghcr.io/vadosware/pg_idkit")
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ docker run \
-e POSTGRES_PASSWORD=replace_this \
-p 5432 \
--name pg_idkit \
ghcr.io/vadosware/pg_idkit:0.1.0-pg15.5-alpine3.18-amd64
ghcr.io/vadosware/pg_idkit:0.1.0-pg16.1-alpine3.18-amd64
```

> [!WARNING]
Expand Down Expand Up @@ -103,10 +103,10 @@ cargo install cargo-get cargo-pgrx just
just package
```

After running these commands you should see the following directory structure in `target/release/pg_idkit-pg15`:
After running these commands you should see the following directory structure in `target/release/pg_idkit-pg16`:

```
target/release/pg_idkit-pg15
target/release/pg_idkit-pg16
├── home
│   └── <user>
│   └── .pgrx
Expand Down Expand Up @@ -184,7 +184,7 @@ docker run \
-e POSTGRES_PASSWORD=replace_this \
-p 5432 \
--name pg_idkit \
ghcr.io/vadosware/pg_idkit:0.1.0-pg15.5-alpine3.18-amd64
ghcr.io/vadosware/pg_idkit:0.1.0-pg16.1-alpine3.18-amd64
```

From another terminal, you can exec into the `pg_idkit` container and enable `pg_idkit`:
Expand Down Expand Up @@ -221,10 +221,10 @@ RPMs are produced upon [every official release](/releases) of `pg_idkit`.

Grab a released version of the RPM (or build one yourself by running `just build-rpm` after [setting up local development][guide-localdev]).

For example, with an RPM named `pg_idkit-0.1.0-pg15.x86_64.rpm`, you should be able to run:
For example, with an RPM named `pg_idkit-0.1.0-pg16.x86_64.rpm`, you should be able to run:

```
dnf install pg_idkit-0.1.0-pg15.x86_64.rpm
dnf install pg_idkit-0.1.0-pg16.x86_64.rpm
```

</details>
Expand Down