From a8935ff7855fa774bc45e7a6602632fbbd26c0c9 Mon Sep 17 00:00:00 2001 From: Mathieu Fenniak Date: Fri, 6 Jun 2025 18:49:33 -0600 Subject: [PATCH 1/7] ci: update test automation to run PG17, Python 3.12, Python 3.13 --- flake.lock | 12 ++++++------ flake.nix | 27 +++++++++++++++++---------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/flake.lock b/flake.lock index 4c78699..973ef76 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "owner": "numtide", "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "type": "github" }, "original": { @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1715534503, - "narHash": "sha256-5ZSVkFadZbFP1THataCaSf0JH2cAH3S29hU9rrxTEqk=", + "lastModified": 1749143949, + "narHash": "sha256-QuUtALJpVrPnPeozlUG/y+oIMSLdptHxb3GK6cpSVhA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "2057814051972fa1453ddfb0d98badbea9b83c06", + "rev": "d3d2d80a2191a73d1e86456a751b83aa13085d7d", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 2ba474a..e6ac85b 100644 --- a/flake.nix +++ b/flake.nix @@ -18,15 +18,15 @@ [ ps.sqlalchemy ] ++ ps.sqlalchemy.optional-dependencies.postgresql ); - devPostgresql = pkgs.postgresql_15.overrideAttrs (oldAttrs: {} // pkgs.lib.optionalAttrs debugBuild { dontStrip = true; }); # If debug symbols are needed. - devPython = pkgs.python310.withPackages (ps: (requiredPythonPackages ps)); + devPostgresql = pkgs.postgresql_17.overrideAttrs (oldAttrs: {} // pkgs.lib.optionalAttrs debugBuild { dontStrip = true; }); # If debug symbols are needed. + devPython = pkgs.python313.withPackages (ps: (requiredPythonPackages ps)); testPythonVersions = with pkgs; [ - python39 - python310 + # python39 # end of security support is scheduled for 2025-10-31; therefore nixpkgs support was dropped before nixos 25.05 was released + # python310 # error: sphinx-8.2.3 not supported for interpreter python3.10 python311 - # python312 # tests are currently broken - # python313 # tests are currently broken + python312 + python313 ]; testPostgresVersions = with pkgs; [ postgresql_13 @@ -35,7 +35,7 @@ postgresql_16 postgresql_17 ]; - testVersionCombos = pkgs.lib.cartesianProductOfSets { + testVersionCombos = pkgs.lib.cartesianProduct { python = testPythonVersions; postgres = testPostgresVersions; }; @@ -63,10 +63,13 @@ chmod -R +w . ''; - buildInputs = target_postgresql.buildInputs ++ [ - target_postgresql + buildInputs = [ (target_python.withPackages (ps: (requiredPythonPackages ps))) ]; + nativeBuildInputs = [ + target_postgresql.pg_config + pkgs.clang + ]; installPhase = '' runHook preInstall install -D multicorn${target_postgresql.dlSuffix} -t $out/lib/ @@ -101,7 +104,9 @@ chmod -R +w . ''; - nativeBuildInputs = [ target_postgresql ]; + nativeBuildInputs = [ + target_postgresql.pg_config + ]; separateDebugInfo = true; }; @@ -128,6 +133,8 @@ ./test-3.9 ./test-3.10 ./test-3.11 + ./test-3.12 + ./test-3.13 ./test-common ]; unpackPhase = '' From 829603d37a88b3cb4715637925169e485fb37069 Mon Sep 17 00:00:00 2001 From: Mathieu Fenniak Date: Fri, 6 Jun 2025 20:56:59 -0600 Subject: [PATCH 2/7] fix: Reorganize build ordering due to pg_config Upstream nixpkgs separated out pg_config into a separate development tool package, rather than being part of the std. PostgreSQL package. However, installing a PG extension is only part of the std PostgreSQL package, so we can't get a pg_config that references a PG with extensions preconfigured. To fix this, reorder the package builds so that we build up from the Python module first and assemble the PostgreSQL package last. --- flake.nix | 52 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/flake.nix b/flake.nix index e6ac85b..27c8bbe 100644 --- a/flake.nix +++ b/flake.nix @@ -64,7 +64,7 @@ ''; buildInputs = [ - (target_python.withPackages (ps: (requiredPythonPackages ps))) + target_python ]; nativeBuildInputs = [ target_postgresql.pg_config @@ -121,7 +121,28 @@ python3 = test_python; }); - makeTestSuite = test_python: test_postgresql: pkgs.stdenv.mkDerivation { + makeTestSuite = test_python: test_postgresql: + let + # "Build order", so to speak... + # 1. Multicorn python package first, using the "raw" Python & "raw" PostgreSQL + # 2. Python enhanced w/ the multicorn package + # 3. PostgreSQL w/ plpython3, using "enhanced" Python + # 4. Multicorn postgresql extension, using the "enhanced" Python & plpython3 PostgreSQL + # 5. PostgreSQL w/ plpython3 + multicorn extension + + multicornPython = (makeMulticornPythonPackage test_python test_postgresql); + enhancedPython = (test_python.withPackages (ps: + [multicornPython] + ++ + (requiredPythonPackages ps) + )); + pythonEnabledPostgres = (makePostgresWithPlPython enhancedPython test_postgresql); + multicornPostgresExtension = (makeMulticornPostgresExtension enhancedPython pythonEnabledPostgres); + postgresqlWithMulticorn = pythonEnabledPostgres.withPackages (ps: [ + pythonEnabledPostgres.plpython3 + multicornPostgresExtension + ]); + in pkgs.stdenv.mkDerivation { name = "multicorn2-python-test"; phases = [ "unpackPhase" "checkPhase" "installPhase" ]; @@ -145,22 +166,28 @@ ''; nativeCheckInputs = [ - ( - (makePostgresWithPlPython test_python test_postgresql).withPackages (ps: [ - (makeMulticornPostgresExtension test_python test_postgresql) - ]) - ) - (test_python.withPackages (ps: - [(makeMulticornPythonPackage test_python test_postgresql)] - ++ - (requiredPythonPackages ps) - )) + postgresqlWithMulticorn + postgresqlWithMulticorn.pg_config + enhancedPython ]; checkPhase = '' runHook preCheck + # Verify that we can load sqlalchemy & psycopg2 before we attempt tests, otherwise `UNSUPPORTS_SQLALCHEMY` + # will quietly be set and the tests will skipped silently. + echo "Verifying sqlalchemy is installed..." python -c "import sqlalchemy;import psycopg2" + # Verify that pg_config is available, otherwise pgxs may not be available to be loaded into the Makefile, + # which will result in pg_regress_check being undefined, which will result in an empty command, which will + # result in tests exiting and being ignored from `easycheck`. + echo "Verifying pg_config is accessible..." + pg_config --version + + # Verifying that `multicorn` python module can be accessed by the in-PATH python. + echo "Verifying that multicorn python module is accessible..." + python -c "import multicorn" + set +e make easycheck RESULT=$? @@ -181,6 +208,7 @@ buildInputs = [ devPython devPostgresql + devPostgresql.pg_config ]; }; From 843824a12938e2e2cc6d75e612cf754a8fd0959b Mon Sep 17 00:00:00 2001 From: Mathieu Fenniak Date: Fri, 6 Jun 2025 21:07:48 -0600 Subject: [PATCH 3/7] fix: redisable tests that don't currently work --- flake.nix | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/flake.nix b/flake.nix index 27c8bbe..20d4798 100644 --- a/flake.nix +++ b/flake.nix @@ -19,21 +19,21 @@ ); devPostgresql = pkgs.postgresql_17.overrideAttrs (oldAttrs: {} // pkgs.lib.optionalAttrs debugBuild { dontStrip = true; }); # If debug symbols are needed. - devPython = pkgs.python313.withPackages (ps: (requiredPythonPackages ps)); + devPython = pkgs.python311.withPackages (ps: (requiredPythonPackages ps)); testPythonVersions = with pkgs; [ # python39 # end of security support is scheduled for 2025-10-31; therefore nixpkgs support was dropped before nixos 25.05 was released # python310 # error: sphinx-8.2.3 not supported for interpreter python3.10 python311 - python312 - python313 + # python312 # tests are currently broken where plpython3u is used -- https://github.com/pgsql-io/multicorn2/issues/60 + # python313 # tests are currently broken where plpython3u is used -- https://github.com/pgsql-io/multicorn2/issues/60 ]; testPostgresVersions = with pkgs; [ postgresql_13 postgresql_14 postgresql_15 postgresql_16 - postgresql_17 + # postgresql_17 ]; testVersionCombos = pkgs.lib.cartesianProduct { python = testPythonVersions; @@ -123,21 +123,22 @@ makeTestSuite = test_python: test_postgresql: let - # "Build order", so to speak... + # "# -> Build order", so to speak... structed to build up a PostgreSQL with a compatible Python interpreter that + # is already configured to load the multicorn module. + # # 1. Multicorn python package first, using the "raw" Python & "raw" PostgreSQL + multicornPython = (makeMulticornPythonPackage test_python test_postgresql); + # 2. Python enhanced w/ the multicorn package - # 3. PostgreSQL w/ plpython3, using "enhanced" Python - # 4. Multicorn postgresql extension, using the "enhanced" Python & plpython3 PostgreSQL - # 5. PostgreSQL w/ plpython3 + multicorn extension + enhancedPython = (test_python.withPackages (ps: [multicornPython] ++ (requiredPythonPackages ps) )); - multicornPython = (makeMulticornPythonPackage test_python test_postgresql); - enhancedPython = (test_python.withPackages (ps: - [multicornPython] - ++ - (requiredPythonPackages ps) - )); + # 3. PostgreSQL w/ plpython3, using "enhanced" Python pythonEnabledPostgres = (makePostgresWithPlPython enhancedPython test_postgresql); + + # 4. Multicorn postgresql extension, using the "enhanced" Python & plpython3 PostgreSQL multicornPostgresExtension = (makeMulticornPostgresExtension enhancedPython pythonEnabledPostgres); + + # 5. PostgreSQL w/ plpython3 + multicorn extension postgresqlWithMulticorn = pythonEnabledPostgres.withPackages (ps: [ pythonEnabledPostgres.plpython3 multicornPostgresExtension From 30d385abc2937c59bdea7c2be5752ee21a0d77db Mon Sep 17 00:00:00 2001 From: Mathieu Fenniak Date: Sat, 7 Jun 2025 08:06:43 -0600 Subject: [PATCH 4/7] fix: enable PG17 tests and fix initdb failures --- flake.nix | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index 20d4798..caf7953 100644 --- a/flake.nix +++ b/flake.nix @@ -33,7 +33,7 @@ postgresql_14 postgresql_15 postgresql_16 - # postgresql_17 + postgresql_17 ]; testVersionCombos = pkgs.lib.cartesianProduct { python = testPythonVersions; @@ -144,7 +144,7 @@ multicornPostgresExtension ]); in pkgs.stdenv.mkDerivation { - name = "multicorn2-python-test"; + name = "multicorn2-python-test-pg${test_postgresql.version}-py${test_python.version}"; phases = [ "unpackPhase" "checkPhase" "installPhase" ]; doCheck = true; @@ -190,12 +190,17 @@ python -c "import multicorn" set +e - make easycheck + # PG17+ has a regression-test optimization to reduce initdb runs by doing initdb once and copying it to future + # tests. However, it fails to work in this build environment -- `with_temp_install=""` disables that + # optimization. + make with_temp_install="" easycheck RESULT=$? set -e if [[ $RESULT -ne 0 ]]; then echo "easycheck failed" - cat /build/regression.diffs + [[ -f /build/log/initdb.log ]] && cat /build/log/initdb.log + [[ -f /build/log/postmaster.log ]] && cat /build/log/postmaster.log + [[ -f /build/regression.diffs ]] && cat /build/regression.diffs exit $RESULT fi From fb29f8990cb81af59848a574cdc3e6b237fb7eaf Mon Sep 17 00:00:00 2001 From: Mathieu Fenniak Date: Sat, 7 Jun 2025 08:29:32 -0600 Subject: [PATCH 5/7] test: add one more sanity-check that all tests are running --- flake.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index caf7953..0da8827 100644 --- a/flake.nix +++ b/flake.nix @@ -143,6 +143,9 @@ pythonEnabledPostgres.plpython3 multicornPostgresExtension ]); + + pgMajorVersion = pkgs.lib.versions.major test_postgresql.version; + expectedTestCount = if pkgs.lib.versionOlder pgMajorVersion "14" then "18" else "19"; in pkgs.stdenv.mkDerivation { name = "multicorn2-python-test-pg${test_postgresql.version}-py${test_python.version}"; @@ -193,7 +196,7 @@ # PG17+ has a regression-test optimization to reduce initdb runs by doing initdb once and copying it to future # tests. However, it fails to work in this build environment -- `with_temp_install=""` disables that # optimization. - make with_temp_install="" easycheck + make with_temp_install="" easycheck | tee /build/easycheck.log RESULT=$? set -e if [[ $RESULT -ne 0 ]]; then @@ -204,6 +207,10 @@ exit $RESULT fi + echo "Verifying all ${expectedTestCount} test suites were executed..." + # should exit non-zero if grep doesn't match + grep "All ${expectedTestCount} tests passed." /build/easycheck.log + runHook postCheck ''; installPhase = "touch $out"; From e89e91c0a4879641aefd33723a15babca51a8bee Mon Sep 17 00:00:00 2001 From: Mathieu Fenniak Date: Sat, 7 Jun 2025 09:04:17 -0600 Subject: [PATCH 6/7] verify that test failures break CI --- test-common/multicorn_testfilesystem.include | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test-common/multicorn_testfilesystem.include b/test-common/multicorn_testfilesystem.include index e45c46b..418ab4c 100644 --- a/test-common/multicorn_testfilesystem.include +++ b/test-common/multicorn_testfilesystem.include @@ -105,7 +105,7 @@ SELECT count(1) from testmulticorn where data ilike '% UPDATED!'; BEGIN; UPDATE testmulticorn set data = data || ' UPDATED!'; UPDATE testmulticorn set data = data || ' TWICE!'; - SELECT data from testmulticorn order by filename; + SELECT data from testmulticorn order by filename; ROLLBACK; -- No 'UPDATED! or 'TWICE!' @@ -121,7 +121,7 @@ BEGIN; -- There should be one line with magenta, and 0 with cyan and the old -- filename UPDATE testmulticorn set color = 'magenta' where color = 'cyan'; - SELECT filename, data from testmulticorn where color = 'magenta' order by filename; + SELECT filename, data from testmulticorn where color = 'magenta' order by filename; SELECT filename, data from testmulticorn where color = 'cyan' order by filename; SELECT filename, data from testmulticorn where filename = 'blue/big/rectangle.txt' order by filename; UPDATE testmulticorn set color = 'blue' where color = 'magenta'; @@ -155,7 +155,7 @@ BEGIN; select count(1) from testmulticorn where color = 'red'; ROLLBACK; -- Should have 4 rows -select count(1) from testmulticorn where color = 'red'; +select count(1) from testmulticorn where color = 're3d'; -- Test various combinations of INSERT/UPDATE/DELETE From 7e645e06c0f5044c504a5979796294d1e6919278 Mon Sep 17 00:00:00 2001 From: Mathieu Fenniak Date: Sat, 7 Jun 2025 09:05:24 -0600 Subject: [PATCH 7/7] Revert "verify that test failures break CI" This reverts commit e89e91c0a4879641aefd33723a15babca51a8bee. --- test-common/multicorn_testfilesystem.include | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test-common/multicorn_testfilesystem.include b/test-common/multicorn_testfilesystem.include index 418ab4c..e45c46b 100644 --- a/test-common/multicorn_testfilesystem.include +++ b/test-common/multicorn_testfilesystem.include @@ -105,7 +105,7 @@ SELECT count(1) from testmulticorn where data ilike '% UPDATED!'; BEGIN; UPDATE testmulticorn set data = data || ' UPDATED!'; UPDATE testmulticorn set data = data || ' TWICE!'; - SELECT data from testmulticorn order by filename; + SELECT data from testmulticorn order by filename; ROLLBACK; -- No 'UPDATED! or 'TWICE!' @@ -121,7 +121,7 @@ BEGIN; -- There should be one line with magenta, and 0 with cyan and the old -- filename UPDATE testmulticorn set color = 'magenta' where color = 'cyan'; - SELECT filename, data from testmulticorn where color = 'magenta' order by filename; + SELECT filename, data from testmulticorn where color = 'magenta' order by filename; SELECT filename, data from testmulticorn where color = 'cyan' order by filename; SELECT filename, data from testmulticorn where filename = 'blue/big/rectangle.txt' order by filename; UPDATE testmulticorn set color = 'blue' where color = 'magenta'; @@ -155,7 +155,7 @@ BEGIN; select count(1) from testmulticorn where color = 'red'; ROLLBACK; -- Should have 4 rows -select count(1) from testmulticorn where color = 're3d'; +select count(1) from testmulticorn where color = 'red'; -- Test various combinations of INSERT/UPDATE/DELETE