Skip to content

Commit

Permalink
Merge branch 'main' into add-extract-ts-function
Browse files Browse the repository at this point in the history
  • Loading branch information
craigpastro committed Dec 11, 2023
2 parents 9d5bb02 + 78c0ae3 commit f0b9cd7
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .ci/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ services:
context: ..
environment:
USER: postgres
command: [ "cargo", "pgrx", "test", "pg16" ]
command: [ "cargo", "pgrx", "test", "pg15" ]
15 changes: 11 additions & 4 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check out the repo
uses: actions/checkout@v4

- name: Build docker image
run: docker compose -f .ci/compose.yaml build
- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Install pgrx
run: cargo install cargo-pgrx --version 0.11.0 --locked

- name: Install Postgres
run: cargo pgrx init --pg15 download

- name: Run tests
run: docker compose -f .ci/compose.yaml run test_pg_uuidv7
run: cargo pgrx test pg15
56 changes: 33 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,44 @@
# Copied from https://github.com/supabase/pg_jsonschema/blob/master/dockerfiles/db/Dockerfile
FROM postgres:16-bookworm
# Based off of https://github.com/tembo-io/pgmq/blob/main/images/pgmq-pg/Dockerfile
ARG PG_MAJOR_VERSION=15

FROM postgres:${PG_MAJOR_VERSION}-bookworm as build

ARG PG_MAJOR_VERSION=15

RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
ca-certificates \
build-essential \
pkg-config \
ca-certificates \
clang \
curl \
gcc \
libssl-dev \
libclang-dev \
postgresql-server-dev-16 \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
pkg-config \
postgresql-server-dev-${PG_MAJOR_VERSION} \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /foo
ENV HOME=/foo
ENV PATH=/foo/.cargo/bin:$PATH
RUN chown postgres:postgres -R /foo
# Install Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
RUN $HOME/.cargo/bin/rustup default stable

USER postgres
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal
RUN cargo install --locked --version 0.11.0 cargo-pgrx
RUN cargo pgrx init --pg16 $(which pg_config)
# Install pgrx
RUN $HOME/.cargo/bin/cargo install --locked --version 0.11.0 cargo-pgrx
RUN $HOME/.cargo/bin/cargo pgrx init --pg${PG_MAJOR_VERSION} $(which pg_config)

USER root
# Install pg_uuidv7
COPY . .
RUN cargo pgrx install
RUN $HOME/.cargo/bin/cargo pgrx install -c $(which pg_config)

FROM postgres:${PG_MAJOR_VERSION}-bookworm

ARG PG_MAJOR_VERSION=15

RUN chown -R postgres:postgres /foo
RUN chown -R postgres:postgres /usr/share/postgresql/16/extension
RUN chown -R postgres:postgres /usr/lib/postgresql/16/lib
COPY --from=build /usr/share/postgresql/${PG_MAJOR_VERSION}/extension /usr/share/postgresql/${PG_MAJOR_VERSION}/extension
COPY --from=build /usr/lib/postgresql/${PG_MAJOR_VERSION}/lib /usr/lib/postgresql/${PG_MAJOR_VERSION}/lib

RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

USER postgres
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ should drop you into a psql prompt:
psql (16.0)
Type "help" for help.
pg_uuidv7=# create extension pg_uuidv7;
pg_uuidv7=# CREATE EXTENSION pg_uuidv7;
CREATE EXTENSION
pg_uuidv7=# select uuid_generate_v7();
pg_uuidv7=# SELECT uuid_generate_v7();
uuid_generate_v7
--------------------------------------
01890414-ce5e-7de1-bafe-3dfc8338fb1c
Expand Down

0 comments on commit f0b9cd7

Please sign in to comment.