From 0bba1d265aeb84d8993ed78e62c7e18dfa5dfcc5 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Mon, 4 May 2026 19:52:19 +0200 Subject: [PATCH] ci: test NixOS' VM test for PostgREST This adds a CI job to run our latest postgrest version against the NixOS VM test currently available in Nixpkgs. Now, this will not always be in sync, so has the potential to be failing. However, since the Nixpkgs VM test is really simple, this should only happen when we introduce a breaking change on a very fundamental level. The failing test will then be resolved once the new version is available in Nixpkgs and we have updated our lock file. This is essentially just a sanity check to make sure we're not breaking something fundamentally - and if we do, it's a head up for me to adjust the Nixpkgs tests accordingly. Those might otherwise break unnoticed since Nixpkgs does not have a good notification system for such breakages in place. We do use the chance to run the static executable in this test, which was previously not tested at all. It also gives us a first test whether NixOS VM tests work well in GitHub Actions. --- .github/workflows/build.yaml | 5 +++++ default.nix | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 22202de4d..632bfd4cf 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -68,6 +68,11 @@ jobs: path: postgrest-docker-${{ matrix.artifact }}.tar.gz if-no-files-found: error + - name: Test static executable with NixOS' VM test + # GHA's ARM runner does not support KVM + if: runner.arch == 'X64' + run: nix-build -A nixpkgs-nixos-test + macos: name: Nix - MacOS diff --git a/default.nix b/default.nix index 859c3ebb4..2161e2624 100644 --- a/default.nix +++ b/default.nix @@ -77,6 +77,16 @@ let "-f dev --test-show-detail=direct"; inherit (pkgs.haskell) lib; + + nixos-lib = import (pkgs.path + "/nixos/lib") { }; + runTest = postgrest: test: (nixos-lib.runTest { + hostPkgs = pkgs; + # Replace the top-level `pkgs.postgrest` attribute with our current version on this branch. + defaults.nixpkgs.overlays = [ (_: _: { inherit postgrest; }) ]; + # Speeds up evaluation a little bit; documentation is really not required for tests. + defaults.documentation.enable = pkgs.lib.mkDefault false; + imports = [ test ]; + }).config.result; in rec { inherit nixpkgs pkgs; @@ -162,4 +172,7 @@ rec { # Docker images and loading script. docker = pkgs.callPackage nix/tools/docker { postgrest = postgrestStatic; }; + + # NixOS VM tests + nixpkgs-nixos-test = runTest postgrestStatic (pkgs.path + "/nixos/tests/postgrest.nix"); }