Skip to content
Open
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
15 changes: 7 additions & 8 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
run: src/ci_scripts/build.sh ${{ inputs.build_type }}

- name: Add build and install to artifact tar file
run: tar -czf artifacts.tar src postgres pginst
run: tar -czf artifacts.tar src build postgres pginst

- name: Upload build artifacts
uses: actions/upload-artifact@v7
Expand Down Expand Up @@ -113,13 +113,12 @@ jobs:
with:
name: log-test-${{ inputs.pg_version }}-${{ inputs.os }}-${{ inputs.compiler }}-${{ inputs.build_type }}
path: |
src/regress_install
src/regress_install.log
src/regression.diffs
src/regression.out
src/results
src/t/results
src/tmp_check
build/meson-logs/testlog.txt
build/regress_install
build/regress_install.log
build/regression.diffs
build/results
build/testrun
retention-days: 3

test-psp-with-tde:
Expand Down
23 changes: 11 additions & 12 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
run: src/ci_scripts/build-and-install-psp.sh coverage

- name: Build pg_tde
run: src/ci_scripts/build.sh debug
run: src/ci_scripts/build.sh coverage

- name: Setup kmip and vault
run: src/ci_scripts/setup-keyring-servers.sh
Expand All @@ -57,9 +57,9 @@ jobs:

- name: Process coverage
run: |
geninfo -o coverage.info --no-external --rc lcov_branch_coverage=1 -i .
geninfo -o coverage.info --no-external --rc lcov_branch_coverage=1 .
working-directory: src
geninfo -o coverage.info --rc lcov_branch_coverage=1 -i .
geninfo -o coverage.info --rc lcov_branch_coverage=1 .
working-directory: build

- name: Upload coverage data to codecov.io
uses: codecov/codecov-action@v5
Expand All @@ -68,7 +68,7 @@ jobs:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
disable_search: true
files: coverage.info
files: ../build/coverage.info
working-directory: src

- name: Report on test fail
Expand All @@ -77,11 +77,10 @@ jobs:
with:
name: coverage-testlog
path: |
src/regress_install
src/regress_install.log
src/regression.diffs
src/regression.out
src/results
src/t/results
src/tmp_check
build/meson-logs/testlog.txt
build/regress_install
build/regress_install.log
build/regression.diffs
build/results
build/testrun
retention-days: 3
67 changes: 67 additions & 0 deletions .github/workflows/make.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Build and test with make
on:
pull_request:
paths-ignore:
- documentation/**
push:
branches:
- main
paths-ignore:
- documentation/**

env:
pg_version: 18

jobs:
run:
name: Run
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- name: Clone repository
uses: actions/checkout@v5
with:
path: src
submodules: recursive

- name: Clone postgres repository
uses: actions/checkout@v5
with:
path: postgres
repository: percona/postgres.git
ref: PSP_REL_${{ env.pg_version }}_STABLE

# KMIP server don't support Python 3.12 for now: https://github.com/OpenKMIP/PyKMIP/pull/707
- name: Downgrade python to 3.11
uses: actions/setup-python@v6
with:
python-version: 3.11

- name: Install dependencies
run: src/ci_scripts/ubuntu-deps.sh

- name: Build postgres
run: src/ci_scripts/build-and-install-psp.sh debugoptimized

- name: Build pg_tde
run: src/ci_scripts/make-build.sh

- name: Setup kmip and vault
run: src/ci_scripts/setup-keyring-servers.sh

- name: Run pg_tde tests
run: src/ci_scripts/make-test.sh

- name: Report on test fail
uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: make-testlog
path: |
src/regress_install
src/regress_install.log
src/regression.diffs
src/regression.out
src/results
src/tmp_check
retention-days: 3
13 changes: 6 additions & 7 deletions .github/workflows/sanitizers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ jobs:
name: sanitizers-testlog
path: |
sanitize.log.*
src/regress_install
src/regress_install.log
src/regression.diffs
src/regression.out
src/results
src/t/results
src/tmp_check
build/meson-logs/testlog.txt
build/regress_install
build/regress_install.log
build/regression.diffs
build/results
build/testrun
retention-days: 3
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ __pycache__
# Generated subdirectories
/log/
/results/
/t/results/
/tmp_check/
/regress_install/
/regress_install.log
Expand Down
29 changes: 13 additions & 16 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,39 +68,36 @@ To build `pg_tde` from source code, you require the following:

* git
* make
* gcc
* pg_config
* gcc or clang
* Percona Server for PostgreSQL 17 or later

Refer to the [Building from source code](https://github.com/percona/pg_tde?tab=readme-ov-file#building-from-sources-for-community-postgresql) section for guidelines.

### Run tests

When you work, you should periodically run tests to check that your changes don’t break existing code.

You can find the tests in the `sql` directory.
You can find the tests in the `sql` and `t` directories.

#### Run manually

1. Change the directory to `pg_tde`

**NOTE**: Make sure `postgres` user is the owner of the `pg_tde` directory
2. Build and install `pg_tde` with the following command:

2. Start the tests
1. If you built PostgreSQL from PGDG, use the following command:
```sh
make PG_CONFIG=/path/to/postgresql/bin/pg_config install
```

```sh
make installcheck
```
3. Start Percona Server for PostgreSQL

2. If you installed PostgreSQL server from Percona Distribution for PostgreSQL, use the following command:
4. Run the tests using the following command:

```sh
sudo su postgres bash -c 'make installcheck USE_PGXS=1'
```
```sh
make PG_CONFIG=/path/to/postgresql/bin/pg_config installcheck
```

#### Run automatically

The tests are run automatically with GitHub actions once you commit and push your changes. Make sure all tests are successfully passed before you proceed.
The tests are run automatically with GitHub actions once you create a pull request.

## Documentation contribution

Expand Down
2 changes: 1 addition & 1 deletion ci_scripts/build-and-install-psp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ case "$1" in

*)
echo "Unknown build type: $1"
echo "Please use one of the following: debug, debugoptimized, sanitize"
echo "Please use one of the following: debug, debugoptimized, coverage, sanitize"
exit 1
;;
esac
Expand Down
25 changes: 17 additions & 8 deletions ci_scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,40 @@ set -e

SCRIPT_DIR="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)"
PG_CONFIG="$SCRIPT_DIR/../../pginst/bin/pg_config"
CFLAGS=-Werror

cd "$SCRIPT_DIR/.."
BUILD_TYPE=
ARGS=

case "$1" in
debug)
echo "Building with debug option"
BUILD_TYPE=$1
;;

debugoptimized)
echo "Building with debugoptimized option"
CFLAGS+=" -O2"
BUILD_TYPE=$1
;;

coverage)
echo "Building with coverage option"
BUILD_TYPE=debug
ARGS+=-Db_coverage=true
;;

sanitize)
echo "Building with sanitize option"
CFLAGS+=" -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer -fno-inline-functions"
BUILD_TYPE=debug
ARGS+=" -Dc_args=['-fsanitize=address','-fsanitize=undefined','-fno-omit-frame-pointer','-fno-inline-functions']"
ARGS+=" -Dc_link_args=['-fsanitize=address','-fsanitize=undefined']"
;;

*)
echo "Unknown build type: $1"
echo "Please use one of the following: debug, debugoptimized, sanitize"
echo "Please use one of the following: debug, debugoptimized, coverage, sanitize"
exit 1
;;
esac

export CFLAGS
make PG_CONFIG="$PG_CONFIG" install -j
cd "$SCRIPT_DIR/.."
meson setup --buildtype="$BUILD_TYPE" -Dpg_config="$PG_CONFIG" -Dwerror=true $ARGS ../build
meson install -C ../build
4 changes: 2 additions & 2 deletions ci_scripts/dump-typedefs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
set -e

SCRIPT_DIR="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)"
cd "$SCRIPT_DIR/.."
cd "$SCRIPT_DIR/../../build"

if ! test -f pg_tde.so; then
echo "pg_tde.so doesn't exists, run build.sh first in debug mode"
Expand All @@ -19,4 +19,4 @@ fi
../postgres/src/tools/find_typedef .
wget -q -O - "https://buildfarm.postgresql.org/cgi-bin/typedefs.pl?branch=REL_17_STABLE"
wget -q -O - "https://buildfarm.postgresql.org/cgi-bin/typedefs.pl?branch=REL_18_STABLE"
) | sort -u > typedefs.list
) | sort -u > ../src/typedefs.list
3 changes: 2 additions & 1 deletion ci_scripts/macos-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ DEPS=(
lz4
openssl
zstd

# Build pg_tde
meson
# Run pgperltidy
perltidy
)
Expand Down
11 changes: 11 additions & 0 deletions ci_scripts/make-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -e

SCRIPT_DIR="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)"
PG_CONFIG="$SCRIPT_DIR/../../pginst/bin/pg_config"

cd "$SCRIPT_DIR/.."

export CFLAGS="-Werror -O2"
make PG_CONFIG="$PG_CONFIG" install -j
17 changes: 17 additions & 0 deletions ci_scripts/make-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

set -e

SCRIPT_DIR="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)"

cd "$SCRIPT_DIR/.."

OPTS='--set shared_preload_libraries=pg_tde'

../pginst/bin/pg_ctl -D regress_install -l regress_install.log init -o "$OPTS"

../pginst/bin/pg_ctl -D regress_install -l regress_install.log start

make PG_CONFIG=../pginst/bin/pg_config installcheck

../pginst/bin/pg_ctl -D regress_install stop
4 changes: 2 additions & 2 deletions ci_scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e

SCRIPT_DIR="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)"

cd "$SCRIPT_DIR/.."
cd "$SCRIPT_DIR/../../build"

OPTS='--set shared_preload_libraries=pg_tde'

Expand All @@ -16,6 +16,6 @@ fi

../pginst/bin/pg_ctl -D regress_install -l regress_install.log start

make PG_CONFIG=../pginst/bin/pg_config installcheck
meson test --timeout-multiplier=0 --print-errorlogs

../pginst/bin/pg_ctl -D regress_install stop
2 changes: 2 additions & 0 deletions ci_scripts/ubuntu-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ DEPS=(
xsltproc
zlib1g-dev
zstd
# pg_tde dependencies
meson
# pg_tde test dependencies
lcov
perltidy
Expand Down
2 changes: 1 addition & 1 deletion fetools/pg18/pg_basebackup/astreamer_inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ typedef struct astreamer_pg_tde_injector
astreamer base;
bool skip_file;
bool encryped_wal;
} astreamer_pg_tde_injector;
} astreamer_pg_tde_injector;

static void astreamer_pg_tde_injector_content(astreamer *streamer,
astreamer_member *member,
Expand Down
Loading
Loading