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
14 changes: 0 additions & 14 deletions .github/docker/Dockerfile

This file was deleted.

64 changes: 0 additions & 64 deletions .github/resources/scripts/healthcheck.sh

This file was deleted.

12 changes: 0 additions & 12 deletions .github/resources/set_user.yml

This file was deleted.

58 changes: 0 additions & 58 deletions .github/workflows/regression-tests.yml

This file was deleted.

38 changes: 38 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
on:
push:
branches:
- integration
- '**-ci'
pull_request:
branches:
- master
- integration

jobs:
test:
runs-on: ubuntu-latest

strategy:
# Let all the jobs run to completion even if one fails
fail-fast: false

# Test all supported versions
matrix:
pgver: [12, 13, 14, 15, 16, 17]

steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
path: set_user

- name: Build Test Container
run: docker build --build-arg UID=$(id -u) --build-arg GID=$(id -g) --build-arg PGVER=${{matrix.pgver}} -f ${GITHUB_WORKSPACE?}/set_user/test/Dockerfile.debian -t set_user-test ${GITHUB_WORKSPACE?}/set_user

- name: Run Test
run: docker run -v ${GITHUB_WORKSPACE?}/set_user:/set_user set_user-test /set_user/test/test.sh

- name: Show Any Regression Diffs
if: ${{ failure() }}
run: |
cat ${GITHUB_WORKSPACE?}/set_user/regression.diffs
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Derived objects
set_user.o
set_user.so
set_user.bc
results

# Generated documentation
Expand Down
43 changes: 43 additions & 0 deletions test/Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM ubuntu:latest

# Install packages
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y sudo wget gnupg tzdata locales lsb-release apt-utils make gcc libssl-dev \
libkrb5-dev

# PostgreSQL version
ARG PGVER=18

# Remove the default ubuntu user to reduce the chance of a conflict with the host user
RUN userdel ubuntu

# Create postgres user/group with specific IDs
ARG UID=1000
ARG GID=1000

RUN groupadd -g $GID -o postgres
RUN useradd -m -u $UID -g $GID -o -s /bin/bash postgres

# Add PostgreSQL repository
RUN RELEASE_CODENAME=`lsb_release -c | awk '{print $2}'` && \
echo 'deb http://apt.postgresql.org/pub/repos/apt/ '${RELEASE_CODENAME?}'-pgdg main '${PGVER?} | \
tee -a /etc/apt/sources.list.d/pgdg.list
RUN APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 && \
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
RUN apt-get update

# Install PostgreSQL
RUN apt-get install -y postgresql-${PGVER?} postgresql-server-dev-${PGVER?}

# Create PostgreSQL cluster
ENV PGBIN=/usr/lib/postgresql/${PGVER}/bin
ENV PGDATA="/var/lib/postgresql/${PGVER}/test"
ENV PATH="${PATH}:${PGBIN}"

RUN sudo -u postgres ${PGBIN?}/initdb -A trust -k ${PGDATA?}
RUN echo "shared_preload_libraries = 'set_user'" >> ${PGDATA}/postgresql.conf

# Configure sudo
RUN echo 'postgres ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

USER postgres
10 changes: 10 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Testing

Testing is performed using a Docker container. First build the container with the desired PostgreSQL version:
```
docker build --build-arg UID=$(id -u) --build-arg GID=$(id -g) --build-arg PGVER=17 -f test/Dockerfile.debian -t set_user-test .
```
Then run the test:
```
docker run --rm -v $(pwd):/set_user set_user-test /set_user/test/test.sh
```
14 changes: 14 additions & 0 deletions test/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -e

# Clean and build set_user
make -C /set_user clean all USE_PGXS=1

# Install set_user so postgres will start with shared_preload_libraries set
sudo bash -c "PATH=${PATH?} make -C /set_user install USE_PGXS=1"

# Start postgres
${PGBIN}/pg_ctl -w start -D ${PGDATA}

# Test set_user
make -C /set_user installcheck USE_PGXS=1