Skip to content

Commit b806c07

Browse files
jfrochesamrose
andauthored
feat: multiple versions for the wrappers extension (#1663)
* feat(cargo-pgrx): build extensions with specified Rust version This change allows developers to target specific Rust versions for building extensions. It implements support for building cargo extensions and `cargo-pgrx` using the specified Rust version. * feat: multiple versions for the wrappers extension Build multiple versions of the wrappers extension on different PostgreSQL versions. Add test for the extensions and their upgrade on PostgreSQL 15 and 17. Make sure we build cargo extension and cargo-pgrx with the specified Rust version. * Fix darwin build by using unix sockets only Stop using TCP sockets in builds to avoid port conflicts * Support more versions of wrappers extension Update rust overlay to build using more recent rust versions. * Build wrapper 0.3.0 using pgrx 0.11.3 Avoid compilation errors related to bindgen on aarch64-linux * Build wrapper 0.5.2 using pgrx 0.14.3 * Limit the numbers of versions to build * tests: update regress tests for new version of wrappers * Build and cache a single version Current MacOS builder cannot handle multiple versions * Do not run parallel builds on MacOS Current runner doesn't have enough disk space * feat: update wrappers to 0.5.3 * feat: bugfix on same version * fix: free up space in the case of macos builder * fix: also pass in nix.conf max-jobs setting on macos * Revert "fix: also pass in nix.conf max-jobs setting on macos" This reverts commit b67f7ce. * fix(ci): only build devshell on linux aarch64 darwin has issues building all the postgresql with their extensions in parallel. `devShell` depends on `start-server` which depends on the `makePostgresDevSetup`which depends on all databases. * fix(ci): build each postgresql version separately The `makeCheckHarness` function depends on all postgresql versions. * chore: fix formatting * chore: bump versions to release --------- Co-authored-by: Sam Rose <[email protected]>
1 parent 4db4d5b commit b806c07

16 files changed

+5904
-217
lines changed

.github/workflows/nix-build.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
run: |
5858
cat << 'EOF' | sudo tee /etc/nix/upload-to-cache.sh > /dev/null
5959
#!/usr/bin/env bash
60-
set -eouf
60+
set -euf
6161
export IFS=' '
6262
/nix/var/nix/profiles/default/bin/nix copy --to 's3://nix-postgres-artifacts?secret-key=/etc/nix/nix-secret-key' $OUT_PATHS
6363
EOF
@@ -77,10 +77,34 @@ jobs:
7777
extra-conf: |
7878
substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com
7979
trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI=% cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
80+
- name: Aggressive disk cleanup for DuckDB build
81+
if: matrix.runner == 'macos-latest-xlarge'
82+
run: |
83+
echo "=== BEFORE CLEANUP ==="
84+
df -h
85+
# Remove major space consumers
86+
sudo rm -rf /usr/share/dotnet || true
87+
sudo rm -rf /usr/local/lib/android || true
88+
sudo rm -rf /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform || true
89+
sudo rm -rf /Applications/Xcode.app/Contents/Developer/Platforms/watchOS.platform || true
90+
sudo rm -rf /Applications/Xcode.app/Contents/Developer/Platforms/tvOS.platform || true
91+
# Clean everything possible
92+
sudo rm -rf /opt/ghc || true
93+
sudo rm -rf /usr/local/share/boost || true
94+
sudo rm -rf /opt/homebrew || true
95+
sudo xcrun simctl delete all 2>/dev/null || true
96+
# Aggressive cache cleanup
97+
sudo rm -rf /System/Library/Caches/* 2>/dev/null || true
98+
sudo rm -rf /Library/Caches/* 2>/dev/null || true
99+
sudo rm -rf ~/Library/Caches/* 2>/dev/null || true
100+
sudo rm -rf /private/var/log/* 2>/dev/null || true
101+
sudo rm -rf /tmp/* 2>/dev/null || true
102+
echo "=== AFTER CLEANUP ==="
103+
df -h
80104
- name: Build psql bundle
81105
run: >
82106
nix run "github:Mic92/nix-fast-build?rev=b1dae483ab7d4139a6297e02b6de9e5d30e43d48"
83-
-- --skip-cached --no-nom
107+
-- --skip-cached --no-nom ${{ matrix.runner == 'macos-latest-xlarge' && '--max-jobs 1' || '' }}
84108
--flake ".#checks.$(nix eval --raw --impure --expr 'builtins.currentSystem')"
85109
env:
86110
AWS_ACCESS_KEY_ID: ${{ env.AWS_ACCESS_KEY_ID }}

ansible/vars.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ postgres_major:
99

1010
# Full version strings for each major version
1111
postgres_release:
12-
postgresorioledb-17: "17.0.1.100-orioledb"
13-
postgres17: "17.4.1.050"
14-
postgres15: "15.8.1.107"
12+
postgresorioledb-17: "17.0.1.101-orioledb"
13+
postgres17: "17.4.1.051"
14+
postgres15: "15.8.1.108"
1515

1616
# Non Postgres Extensions
1717
pgbouncer_release: "1.19.0"

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nix/cargo-pgrx/buildPgrxExtension.nix

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,13 @@
2626
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2727
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2828
# SOFTWARE.
29-
3029
{
3130
lib,
3231
cargo-pgrx,
3332
pkg-config,
3433
rustPlatform,
3534
stdenv,
36-
Security,
35+
darwin,
3736
writeShellScriptBin,
3837
}:
3938

@@ -94,7 +93,13 @@ let
9493
export PGRX_HOME=$(mktemp -d)
9594
export PGDATA="$PGRX_HOME/data-${pgrxPostgresMajor}/"
9695
cargo-pgrx pgrx init "--pg${pgrxPostgresMajor}" ${lib.getDev postgresql}/bin/pg_config
97-
echo "unix_socket_directories = '$(mktemp -d)'" > "$PGDATA/postgresql.conf"
96+
97+
# unix sockets work in sandbox, too.
98+
export PGHOST="$(mktemp -d)"
99+
cat > "$PGDATA/postgresql.conf" <<EOF
100+
listen_addresses = '''
101+
unix_socket_directories = '$PGHOST'
102+
EOF
98103
99104
# This is primarily for Mac or other Nix systems that don't use the nixbld user.
100105
export USER="$(whoami)"
@@ -112,7 +117,9 @@ let
112117
# so we don't accidentally `(rustPlatform.buildRustPackage argsForBuildRustPackage) // { ... }` because
113118
# we forgot parentheses
114119
finalArgs = argsForBuildRustPackage // {
115-
buildInputs = (args.buildInputs or [ ]) ++ lib.optionals stdenv.hostPlatform.isDarwin [ Security ];
120+
buildInputs =
121+
(args.buildInputs or [ ])
122+
++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.apple_sdk.frameworks.Security ];
116123

117124
nativeBuildInputs =
118125
(args.nativeBuildInputs or [ ])
@@ -156,6 +163,7 @@ let
156163
cargo-pgrx pgrx stop all
157164
158165
mv $out/${postgresql}/* $out
166+
mv $out/${postgresql.lib}/* $out
159167
rm -rf $out/nix
160168
161169
${maybeLeaveBuildAndTestSubdir}

nix/cargo-pgrx/default.nix

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
makeRustPlatform,
88
stdenv,
99
rust-bin,
10+
rustVersion ? "1.85.1",
1011
}:
1112
let
12-
rustVersion = "1.85.1";
1313
rustPlatform = makeRustPlatform {
1414
cargo = rust-bin.stable.${rustVersion}.default;
1515
rustc = rust-bin.stable.${rustVersion}.default;
1616
};
17-
generic =
17+
mkCargoPgrx =
1818
{
1919
version,
2020
hash,
@@ -57,25 +57,25 @@ let
5757
};
5858
in
5959
{
60-
cargo-pgrx_0_11_3 = generic {
60+
cargo-pgrx_0_11_3 = mkCargoPgrx {
6161
version = "0.11.3";
6262
hash = "sha256-UHIfwOdXoJvR4Svha6ud0FxahP1wPwUtviUwUnTmLXU=";
6363
cargoHash = "sha256-j4HnD8Zt9uhlV5N7ldIy9564o9qFEqs5KfXHmnQ1WEw=";
6464
};
65-
cargo-pgrx_0_12_6 = generic {
65+
cargo-pgrx_0_12_6 = mkCargoPgrx {
6666
version = "0.12.6";
6767
hash = "sha256-7aQkrApALZe6EoQGVShGBj0UIATnfOy2DytFj9IWdEA=";
6868
cargoHash = "sha256-Di4UldQwAt3xVyvgQT1gUhdvYUVp7n/a72pnX45kP0w=";
6969
};
70-
cargo-pgrx_0_12_9 = generic {
70+
cargo-pgrx_0_12_9 = mkCargoPgrx {
7171
version = "0.12.9";
7272
hash = "sha256-aR3DZAjeEEAjLQfZ0ZxkjLqTVMIEbU0UiZ62T4BkQq8=";
7373
cargoHash = "sha256-KTKcol9qSNLQZGW32e6fBb6cPkUGItknyVpLdBYqrBY=";
7474
};
75-
cargo-pgrx_0_14_3 = generic {
75+
cargo-pgrx_0_14_3 = mkCargoPgrx {
7676
version = "0.14.3";
7777
hash = "sha256-3TsNpEqNm3Uol5XPW1i0XEbP2fF2+RKB2d7lO6BDnvQ=";
7878
cargoHash = "sha256-Ny7j56pwB+2eEK62X0nWfFKQy5fBz+Q1oyvecivxLkk=";
7979
};
80-
inherit rustPlatform;
80+
inherit mkCargoPgrx;
8181
}

nix/cargo-pgrx/mkPgrxExtension.nix

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
callPackage,
3+
rustVersion,
4+
pgrxVersion,
5+
makeRustPlatform,
6+
rust-bin,
7+
}:
8+
let
9+
inherit ((callPackage ./default.nix { inherit rustVersion; })) mkCargoPgrx;
10+
11+
rustPlatform = makeRustPlatform {
12+
cargo = rust-bin.stable.${rustVersion}.default;
13+
rustc = rust-bin.stable.${rustVersion}.default;
14+
};
15+
16+
versions = builtins.fromJSON (builtins.readFile ./versions.json);
17+
18+
cargo-pgrx =
19+
let
20+
pgrx =
21+
versions.${pgrxVersion}
22+
or (throw "Unsupported pgrx version ${pgrxVersion}. Available versions: ${builtins.toString (builtins.attrNames versions)}. Change 'nix/cargo-pgrx/versions.json' to add support for new versions.");
23+
mapping = {
24+
inherit (pgrx) hash;
25+
cargoHash =
26+
pgrx.rust."${rustVersion}".cargoHash
27+
or (throw "Unsupported rust version ${rustVersion} for pgrx version ${pgrxVersion}. Available Rust versions: ${builtins.toString (builtins.attrNames pgrx.rust)}. Change 'nix/cargo-pgrx/versions.json' to add support for new versions.");
28+
};
29+
in
30+
mkCargoPgrx {
31+
inherit (mapping) hash cargoHash;
32+
version = pgrxVersion;
33+
};
34+
in
35+
callPackage ./buildPgrxExtension.nix {
36+
inherit rustPlatform;
37+
inherit cargo-pgrx;
38+
}

nix/cargo-pgrx/versions.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"0.11.2": {
3+
"hash": "sha256-8NlpMDFaltTIA8G4JioYm8LaPJ2RGKH5o6sd6lBHmmM=",
4+
"rust": {
5+
"1.70.0": {
6+
"cargoHash": "sha256-qTb3JV3u42EilaK2jP9oa5D09mkuHyRbGGRs9Rg4TzI="
7+
},
8+
"1.76.0": {
9+
"cargoHash": "sha256-qTb3JV3u42EilaK2jP9oa5D09mkuHyRbGGRs9Rg4TzI="
10+
},
11+
"1.85.1": {
12+
"cargoHash": "sha256-CbU5B0pvB9ApTZOdYP/ZwuIG8bqGzk/ING2PCM0q2bQ="
13+
}
14+
}
15+
},
16+
"0.11.3": {
17+
"hash": "sha256-UHIfwOdXoJvR4Svha6ud0FxahP1wPwUtviUwUnTmLXU=",
18+
"rust": {
19+
"1.76.0": {
20+
"cargoHash": "sha256-j4HnD8Zt9uhlV5N7ldIy9564o9qFEqs5KfXHmnQ1WEw="
21+
},
22+
"1.85.1": {
23+
"cargoHash": "sha256-KBlT3FARjGcbtHIGDoC6ir3aNXXfDRmIoy990SOqoFg="
24+
}
25+
}
26+
},
27+
"0.12.6": {
28+
"hash": "sha256-7aQkrApALZe6EoQGVShGBj0UIATnfOy2DytFj9IWdEA=",
29+
"rust": {
30+
"1.80.0": {
31+
"cargoHash": "sha256-Di4UldQwAt3xVyvgQT1gUhdvYUVp7n/a72pnX45kP0w="
32+
},
33+
"1.81.0": {
34+
"cargoHash": "sha256-Di4UldQwAt3xVyvgQT1gUhdvYUVp7n/a72pnX45kP0w="
35+
}
36+
}
37+
},
38+
"0.12.9": {
39+
"hash": "sha256-aR3DZAjeEEAjLQfZ0ZxkjLqTVMIEbU0UiZ62T4BkQq8=",
40+
"rust": {
41+
"1.81.0": {
42+
"cargoHash": "sha256-53HKhvsKLTa2JCByLEcK3UzWXoM+LTatd98zvS1C9no="
43+
},
44+
"1.84.0": {
45+
"cargoHash": "sha256-KTKcol9qSNLQZGW32e6fBb6cPkUGItknyVpLdBYqrBY="
46+
},
47+
"1.87.0": {
48+
"cargoHash": "sha256-KTKcol9qSNLQZGW32e6fBb6cPkUGItknyVpLdBYqrBY="
49+
}
50+
}
51+
},
52+
"0.14.3": {
53+
"hash": "sha256-3TsNpEqNm3Uol5XPW1i0XEbP2fF2+RKB2d7lO6BDnvQ=",
54+
"rust": {
55+
"1.87.0": {
56+
"cargoHash": "sha256-Ny7j56pwB+2eEK62X0nWfFKQy5fBz+Q1oyvecivxLkk="
57+
}
58+
}
59+
}
60+
61+
}

nix/checks.nix

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
let
2323
# Create a testing harness for a PostgreSQL package. This is used for
2424
# 'nix flake check', and works with any PostgreSQL package you hand it.
25+
# deadnix: skip
2526
makeCheckHarness =
2627
pgpkg:
2728
let
@@ -286,16 +287,15 @@
286287
'';
287288
in
288289
{
289-
psql_15 = makeCheckHarness self'.packages."psql_15/bin";
290-
psql_17 = makeCheckHarness self'.packages."psql_17/bin";
291-
psql_orioledb-17 = makeCheckHarness self'.packages."psql_orioledb-17/bin";
290+
psql_15 = self'.packages."psql_15/bin";
291+
psql_17 = self'.packages."psql_17/bin";
292+
psql_orioledb-17 = self'.packages."psql_orioledb-17/bin";
292293
inherit (self'.packages)
293294
wal-g-2
294295
wal-g-3
295296
dbmate-tool
296297
pg_regress
297298
;
298-
devShell = self'.devShells.default;
299299
}
300300
// pkgs.lib.optionalAttrs (system == "aarch64-linux") {
301301
inherit (self'.packages)
@@ -306,6 +306,13 @@
306306
postgresql_17_debug
307307
postgresql_17_src
308308
;
309+
}
310+
// pkgs.lib.optionalAttrs (system == "x86_64-linux") {
311+
wrappers = import ./ext/tests/wrappers.nix {
312+
inherit self;
313+
inherit pkgs;
314+
};
315+
devShell = self'.devShells.default;
309316
};
310317
};
311318
}

0 commit comments

Comments
 (0)