Skip to content

Commit

Permalink
Merge branch 'develop' into spi-readonly
Browse files Browse the repository at this point in the history
  • Loading branch information
eeeebbbbrrrr authored Dec 20, 2022
2 parents 01d1d24 + 71d8ea0 commit 3a15b54
Show file tree
Hide file tree
Showing 97 changed files with 1,921 additions and 1,463 deletions.
10 changes: 8 additions & 2 deletions .github/docker/Dockerfile.alpine:3.16
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,18 @@ ENV USER=rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y
ENV PATH="/home/rust/.cargo/bin:${PATH}"

# By default, we always want to use '--locked'. However, there are some circumstances
# where we might want to try it unlocked. In those one-off scenarios, the image
# can be built by docker with: --build-arg CARGO_LOCKED_OPTION=''
ARG CARGO_LOCKED_OPTION='--locked'
ENV CARGO_LOCKED_OPTION=${CARGO_LOCKED_OPTION}

# Install cargo-pgx from source copied into this container
RUN cargo install --path cargo-pgx/ --locked
RUN echo "Running cargo install --path cargo-pgx/ $CARGO_LOCKED_OPTION" && cargo install --path cargo-pgx/ $CARGO_LOCKED_OPTION

# This seems strange, but by this point $PG_MAJOR_VER is blank and
# $PG_MAJOR is always set to the correct version. I think it's something built
# into the postgres:XX-alpine3.16 images, so it was easier to go with the grain
RUN cargo pgx init --pg$PG_MAJOR=$(which pg_config)

CMD ["cargo", "test", "--no-default-features", "--features", "pg${PG_MAJOR_VER}"]
CMD ["cargo", "test", "--no-default-features", "--features", "pg${PG_MAJOR_VER} cshim", "${CARGO_LOCKED_OPTION}"]
17 changes: 14 additions & 3 deletions .github/docker/Dockerfile.amazon:2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Example of how to build this container (ran from pgx checkout directory):
# docker build --build-arg PG_MAJOR_VER=14 -f .github/docker/Dockerfile.alpine\:3.16 -t pgx-amazonlinux2 .
# docker build --build-arg PG_MAJOR_VER=14 -f .github/docker/Dockerfile.amazon\:2 -t pgx-amazonlinux2 .
#
# Example of how to run this container with tests after building the image:
# docker run pgx-amazonlinux2 cargo test --no-default-features --features pg14 --locked
Expand Down Expand Up @@ -75,9 +75,20 @@ ENV USER=rust

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y
ENV PATH="/home/rust/.cargo/bin:${PATH}"
RUN cargo install --path cargo-pgx/ --locked

# By default, we always want to use '--locked'. However, there are some circumstances
# where we might want to try it unlocked. In those one-off scenarios, the image
# can be built by docker with: --build-arg CARGO_LOCKED_OPTION=''
ARG CARGO_LOCKED_OPTION='--locked'
ENV CARGO_LOCKED_OPTION=${CARGO_LOCKED_OPTION}

# Install cargo-pgx from source copied into this container
RUN echo "Running cargo install --path cargo-pgx/ $CARGO_LOCKED_OPTION" && cargo install --path cargo-pgx/ $CARGO_LOCKED_OPTION

# Initialize cargo pgx so that we can run the tests
RUN cargo pgx init --pg$PG_MAJOR_VER=$(which pg_config)
CMD ["cargo", "test", "--no-default-features", "--features", "pg${PG_MAJOR_VER}"]

CMD ["cargo", "test", "--no-default-features", "--features", "pg${PG_MAJOR_VER} cshim", "${CARGO_LOCKED_OPTION}"]

# === Previous "amazon-linux-extras" steps, kept for historical purposes ===
# RUN amazon-linux-extras enable postgresql$PG_MAJOR_VER
Expand Down
12 changes: 9 additions & 3 deletions .github/docker/Dockerfile.debian:bullseye
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Example of how to build this container (ran from pgx checkout directory):
# docker build --build-arg PG_MAJOR_VER=14 -f .github/docker/Dockerfile.alpine\:3.16 -t pgx-debian.
# docker build --build-arg PG_MAJOR_VER=14 -f .github/docker/Dockerfile.debian\:bullseye -t pgx-debian .
#
# Example of how to run this container with tests after building the image:
# docker run pgx-debian cargo test --no-default-features --features pg14 --locked
Expand Down Expand Up @@ -54,10 +54,16 @@ ENV USER=rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/home/rust/.cargo/bin:${PATH}"

# By default, we always want to use '--locked'. However, there are some circumstances
# where we might want to try it unlocked. In those one-off scenarios, the image
# can be built by docker with: --build-arg CARGO_LOCKED_OPTION=''
ARG CARGO_LOCKED_OPTION='--locked'
ENV CARGO_LOCKED_OPTION=${CARGO_LOCKED_OPTION}

# Install cargo-pgx from source copied into this container
RUN cargo install --path cargo-pgx/ --locked
RUN echo "Running cargo install --path cargo-pgx/ $CARGO_LOCKED_OPTION" && cargo install --path cargo-pgx/ $CARGO_LOCKED_OPTION

# Initialize cargo pgx so that we can run the tests
RUN cargo pgx init --pg$PG_MAJOR_VER=$(which pg_config)

CMD ["cargo", "test", "--no-default-features", "--features", "pg${PG_MAJOR_VER}"]
CMD ["cargo", "test", "--no-default-features", "--features", "pg${PG_MAJOR_VER} cshim", "${CARGO_LOCKED_OPTION}"]
12 changes: 9 additions & 3 deletions .github/docker/Dockerfile.fedora:36
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Example of how to build this container (ran from pgx checkout directory):
# docker build --build-arg PG_MAJOR_VER=14 -f .github/docker/Dockerfile.alpine\:3.16 -t pgx-fedora .
# docker build --build-arg PG_MAJOR_VER=14 -f .github/docker/Dockerfile.fedora\:36 -t pgx-fedora .
#
# Example of how to run this container with tests after building the image:
# docker run pgx-fedora cargo test --no-default-features --features pg14 --locked
Expand Down Expand Up @@ -45,10 +45,16 @@ ENV USER=rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/home/rust/.cargo/bin:${PATH}"

# By default, we always want to use '--locked'. However, there are some circumstances
# where we might want to try it unlocked. In those one-off scenarios, the image
# can be built by docker with: --build-arg CARGO_LOCKED_OPTION=''
ARG CARGO_LOCKED_OPTION='--locked'
ENV CARGO_LOCKED_OPTION=${CARGO_LOCKED_OPTION}

# Install cargo-pgx from source copied into this container
RUN cargo install --path cargo-pgx/ --locked
RUN echo "Running cargo install --path cargo-pgx/ $CARGO_LOCKED_OPTION" && cargo install --path cargo-pgx/ $CARGO_LOCKED_OPTION

# Initialize cargo pgx so that we can run the tests
RUN cargo pgx init --pg$PG_MAJOR_VER=/usr/pgsql-$PG_MAJOR_VER/bin/pg_config

CMD ["cargo", "test", "--no-default-features", "--features", "pg${PG_MAJOR_VER}"]
CMD ["cargo", "test", "--no-default-features", "--features", "pg${PG_MAJOR_VER} cshim", "${CARGO_LOCKED_OPTION}"]
29 changes: 25 additions & 4 deletions .github/docker/run-docker.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
#! /usr/bin/env bash

# Environment variables:
# PG_MAJOR_VER: The major version of Postgres in which to build/run. E.g. 14, 12, 15
# DOCKERFILE_ID: The Dockerfile identifier to be built, included in this repo,
# e.g. debian:bullseye or amazon:2
# CARGO_LOCKED_OPTION: Set to '--locked' to use "cargo --locked", or set to
# blank '' to use "cargo" without "--locked"

# Examples of running this script in CI (currently Github Actions):
# ./.github/docker/run-docker.sh 14 debian:bullseye
# ./.github/docker/run-docker.sh 12 fedora:36

set -x

PG_MAJOR_VER=$1
DOCKERFILE_ID=$2

echo "Building docker container for PGX using Postgres version $PG_MAJOR_VER in container $DOCKERFILE_ID"
echo "Cargo lock flag set to: '$CARGO_LOCKED_OPTION'"

docker build \
--build-arg PG_MAJOR_VER=$PG_MAJOR_VER \
-t pgx -f ".github/docker/Dockerfile.$DOCKERFILE_ID" .
--build-arg PG_MAJOR_VER="$PG_MAJOR_VER" \
--build-arg CARGO_LOCKED_OPTION="$CARGO_LOCKED_OPTION" \
-t pgx \
-f ".github/docker/Dockerfile.$DOCKERFILE_ID" \
.

echo "Running PGX test suite using Postgres version $PG_MAJOR_VER in container $DOCKERFILE_ID"
echo "Running PGX test suite using Postgres version $PG_MAJOR_VER in container $DOCKERFILE_ID with 'cshim'"

docker run pgx cargo test --no-default-features --features pg$PG_MAJOR_VER --locked
docker run pgx \
cargo test \
--no-default-features \
--features "pg$PG_MAJOR_VER cshim" \
"$CARGO_LOCKED_OPTION"
15 changes: 13 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,25 @@ jobs:
- name: Run base-level tests
run: |
cargo test \
--features "pg$PG_VER" --no-default-features \
--features "pg$PG_VER" \
--package cargo-pgx \
--package pgx \
--package pgx-macros \
--package pgx-pg-sys \
--package pgx-tests \
--package pgx-sql-entity-graph
- name: Run pgx-tests with cshim enabled
run: |
cargo test \
--features "pg$PG_VER cshim" \
--package pgx-tests
- name: Run pgx-tests with cshim disabled
run: |
cargo test \
--features "pg$PG_VER" \
--package pgx-tests
- name: Run aggregate example tests
run: cargo test --package aggregate --features "pg$PG_VER" --no-default-features

Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/will-it-blend-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,42 @@ jobs:
run: |
export PG_MAJOR_VER=$(echo ${{ matrix.pg_version}} | cut -c3-)
echo "PG_MAJOR_VER=$PG_MAJOR_VER" >> $GITHUB_ENV
echo "CARGO_LOCKED_OPTION=--locked" >> $GITHUB_ENV
- name: Run PGX tests for Postgres ${{ matrix.pg_version }} using container ${{ matrix.container }}
shell: bash
run: ./.github/docker/run-docker.sh "$PG_MAJOR_VER" ${{ matrix.container }}

cargo_unlocked_tests:
name: Cargo unlocked tests
runs-on: ubuntu-latest
strategy:
fail-fast: false # We want all of them to run, even if one fails
matrix:
pg_version: ["pg11", "pg12", "pg13", "pg14", "pg15"]
container: ["debian:bullseye"]
steps:
# See above for logic details here
- name: Set up correct branch environment variable
run: |
if [ $GITHUB_EVENT_NAME == "schedule" ]; then
echo "Running via schedule, so using branch develop"
echo "NIGHTLY_BUILD_REF=develop" >> $GITHUB_ENV
else
echo "Not running via schedule, so using branch $GITHUB_HEAD_REF"
echo "NIGHTLY_BUILD_REF=$GITHUB_HEAD_REF" >> $GITHUB_ENV
fi
- uses: actions/checkout@v3
with:
ref: ${{ env.NIGHTLY_BUILD_REF }}

- name: Set up environment variables
run: |
export PG_MAJOR_VER=$(echo ${{ matrix.pg_version}} | cut -c3-)
echo "PG_MAJOR_VER=$PG_MAJOR_VER" >> $GITHUB_ENV
echo "CARGO_LOCKED_OPTION=" >> $GITHUB_ENV
- name: Run PGX tests for Postgres ${{ matrix.pg_version }} using container ${{ matrix.container }}
shell: bash
run: ./.github/docker/run-docker.sh "$PG_MAJOR_VER" ${{ matrix.container }}
47 changes: 0 additions & 47 deletions .github/workflows/will-it-blend.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ target/
cmake*/
.direnv
pgx-examples/*/target
/bin
Loading

0 comments on commit 3a15b54

Please sign in to comment.