|
| 1 | +name: regression |
| 2 | + |
| 3 | +# Run pgrx regression tests on every PR + manual dispatch. |
| 4 | +# Mirrors `make test` (which calls `cargo pgrx regress --resetdb`) inside |
| 5 | +# the project's Docker build stage so we exercise the real IvorySQL pg_config, |
| 6 | +# pg_duckdb install, and the bgworker codepath end-to-end. |
| 7 | + |
| 8 | +on: |
| 9 | + pull_request: |
| 10 | + branches: [main] |
| 11 | + workflow_dispatch: |
| 12 | + |
| 13 | +env: |
| 14 | + IVORYSQL_BASE: registry.highgo.com/ivorysql/ivorysql:5.3-ubi8 |
| 15 | + TEST_IMAGE: ivy_mooncake:regress-${{ github.run_id }} |
| 16 | + |
| 17 | +jobs: |
| 18 | + regress: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + timeout-minutes: 90 |
| 21 | + permissions: |
| 22 | + contents: read |
| 23 | + steps: |
| 24 | + - name: Checkout (with submodules) |
| 25 | + uses: actions/checkout@v4 |
| 26 | + with: |
| 27 | + submodules: recursive |
| 28 | + |
| 29 | + - name: Set up Docker Buildx |
| 30 | + uses: docker/setup-buildx-action@v3 |
| 31 | + |
| 32 | + # Build the `build` stage of the project Dockerfile. That stage ends |
| 33 | + # with: |
| 34 | + # - /ivy_mooncake = source tree (incl. all 3 submodules) |
| 35 | + # - /etc/pgconfig = absolute path to IvorySQL pg_config |
| 36 | + # - pg_duckdb + libduckdb.so installed into IvorySQL libdir/sharedir |
| 37 | + # - rust 1.91.1 + cargo-pgrx 0.16.1 + `cargo pgrx init --pg18=$PG_CONFIG` done |
| 38 | + # Stopping at this stage means we can run `cargo pgrx regress` from the |
| 39 | + # same container without re-paying any build cost. |
| 40 | + - name: Build (Dockerfile target=build) |
| 41 | + uses: docker/build-push-action@v5 |
| 42 | + with: |
| 43 | + context: . |
| 44 | + file: ./Dockerfile |
| 45 | + target: build |
| 46 | + load: true |
| 47 | + tags: ${{ env.TEST_IMAGE }} |
| 48 | + build-args: | |
| 49 | + IVORYSQL_BASE=${{ env.IVORYSQL_BASE }} |
| 50 | + cache-from: type=gha |
| 51 | + cache-to: type=gha,mode=max |
| 52 | + |
| 53 | + - name: Run cargo pgrx regress (pg18) |
| 54 | + id: regress |
| 55 | + run: | |
| 56 | + mkdir -p _artifacts |
| 57 | + set -o pipefail |
| 58 | + docker run --rm \ |
| 59 | + -v "$PWD/_artifacts:/out" \ |
| 60 | + -w /ivy_mooncake \ |
| 61 | + -e RUST_BACKTRACE=1 \ |
| 62 | + -e CARGO_TERM_COLOR=always \ |
| 63 | + "${{ env.TEST_IMAGE }}" \ |
| 64 | + bash -c ' |
| 65 | + set -eux |
| 66 | +
|
| 67 | + # PG refuses to run as root, so spin up an unprivileged user |
| 68 | + # (tester) and have it drive cargo pgrx regress. |
| 69 | + useradd -m -u 2000 -s /bin/bash tester |
| 70 | +
|
| 71 | + # Share /root/.cargo and /root/.rustup with tester via chmod |
| 72 | + # rather than cp -a / chown -R: on overlayfs chown forces a |
| 73 | + # copy_up of every file (~1GB doubling), and a full chown of |
| 74 | + # the build tree wastes minutes + GBs. chmod only flips |
| 75 | + # metadata bits. |
| 76 | + chmod o+rx /root |
| 77 | + chmod -R o+rX /root/.cargo /root/.rustup |
| 78 | +
|
| 79 | + # target/ from the image build is root-owned + stale once |
| 80 | + # cargo recompiles with different feature flags during regress, |
| 81 | + # so wipe it instead of chown-recursing. |
| 82 | + rm -rf /ivy_mooncake/target |
| 83 | + chown -R tester:tester /ivy_mooncake |
| 84 | +
|
| 85 | + # /out is a host-mounted volume owned by the host user; tester |
| 86 | + # would otherwise lack write perms. |
| 87 | + chown tester:tester /out |
| 88 | +
|
| 89 | + PG_CONFIG="$(cat /etc/pgconfig)" |
| 90 | + LIBDIR="$($PG_CONFIG --pkglibdir)" |
| 91 | + SHAREDIR="$($PG_CONFIG --sharedir)" |
| 92 | + chmod -R a+rwX "$LIBDIR" "$SHAREDIR/extension" |
| 93 | +
|
| 94 | + su - tester -c " |
| 95 | + set -eux |
| 96 | + # Share the root-owned cargo/rustup caches in place; per-user |
| 97 | + # pgrx state still goes under tester home. |
| 98 | + export CARGO_HOME=/root/.cargo |
| 99 | + export RUSTUP_HOME=/root/.rustup |
| 100 | + export PGRX_HOME=/home/tester/.pgrx |
| 101 | + export PATH=/root/.cargo/bin:\$PATH |
| 102 | +
|
| 103 | + cargo pgrx init --pg18=\"$PG_CONFIG\" |
| 104 | + cd /ivy_mooncake |
| 105 | + # pg_duckdb refuses to load unless it is in |
| 106 | + # shared_preload_libraries; the IvorySQL base also expects |
| 107 | + # liboracle_parser/ivorysql_ora at preload time. |
| 108 | + cargo pgrx regress --resetdb \ |
| 109 | + --postgresql-conf \"shared_preload_libraries=liboracle_parser,ivorysql_ora,pg_duckdb,pg_mooncake\" \ |
| 110 | + --postgresql-conf \"wal_level=logical\" \ |
| 111 | + --postgresql-conf \"duckdb.allow_community_extensions=true\" \ |
| 112 | + 2>&1 | tee /out/regress.log |
| 113 | + " |
| 114 | + ' |
| 115 | +
|
| 116 | + - name: Collect regression diffs on failure |
| 117 | + if: failure() && steps.regress.outcome == 'failure' |
| 118 | + run: | |
| 119 | + docker run --rm \ |
| 120 | + -v "$PWD/_artifacts:/out" \ |
| 121 | + -w /ivy_mooncake \ |
| 122 | + "${{ env.TEST_IMAGE }}" \ |
| 123 | + bash -c ' |
| 124 | + set -eu |
| 125 | + # Best-effort: regression diffs land somewhere under the source |
| 126 | + # tree depending on pgrx version, so just grab everything that |
| 127 | + # could be useful for triage. |
| 128 | + find . -name regression.diffs -exec cp -v {} /out/ \; 2>/dev/null || true |
| 129 | + find . -name regression.out -exec cp -v {} /out/ \; 2>/dev/null || true |
| 130 | + find . -path "*/pg_regress/results/*" -exec cp -v {} /out/ \; 2>/dev/null || true |
| 131 | + # cargo target log (if any) |
| 132 | + find . -name "postmaster.log" -exec cp -v {} /out/ \; 2>/dev/null || true |
| 133 | + ls -la /out/ || true |
| 134 | + ' || true |
| 135 | +
|
| 136 | + - name: Upload regression artifacts |
| 137 | + if: always() |
| 138 | + uses: actions/upload-artifact@v4 |
| 139 | + with: |
| 140 | + name: regression-artifacts-${{ github.run_id }} |
| 141 | + path: _artifacts/ |
| 142 | + if-no-files-found: ignore |
| 143 | + retention-days: 14 |
0 commit comments