From 8d15ee11acca4b076a427362ea3f3097a4f2b6c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rolf=20Schr=C3=B6der?= Date: Tue, 24 Sep 2024 05:57:38 +0200 Subject: [PATCH] tests/nextflow: init --- nixos/tests/all-tests.nix | 1 + nixos/tests/nextflow.nix | 60 +++++++++++++++++++ .../interpreters/nextflow/default.nix | 2 + 3 files changed, 63 insertions(+) create mode 100644 nixos/tests/nextflow.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 15efe3a06b56..5bdd0a1a7aa1 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -658,6 +658,7 @@ in { # TODO: put in networking.nix after the test becomes more complete networkingProxy = handleTest ./networking-proxy.nix {}; nextcloud = handleTest ./nextcloud {}; + nextflow = handleTest ./nextflow.nix {}; nextjs-ollama-llm-ui = runTest ./web-apps/nextjs-ollama-llm-ui.nix; nexus = handleTest ./nexus.nix {}; # TODO: Test nfsv3 + Kerberos diff --git a/nixos/tests/nextflow.nix b/nixos/tests/nextflow.nix new file mode 100644 index 000000000000..b4aad98483b9 --- /dev/null +++ b/nixos/tests/nextflow.nix @@ -0,0 +1,60 @@ +import ./make-test-python.nix ( + { pkgs, ... }: + let + bash = pkgs.dockerTools.pullImage { + imageName = "quay.io/nextflow/bash"; + imageDigest = "sha256:bea0e244b7c5367b2b0de687e7d28f692013aa18970941c7dd184450125163ac"; + sha256 = "161s9f24njjx87qrwq0c9nmnwvyc6iblcxka7hirw78lm7i9x4w5"; + finalImageName = "quay.io/nextflow/bash"; + }; + + hello = pkgs.stdenv.mkDerivation { + name = "nextflow-hello"; + src = pkgs.fetchFromGitHub { + owner = "nextflow-io"; + repo = "hello"; + rev = "afff16a9b45c8e8a4f5a3743780ac13a541762f8"; + hash = "sha256-c8FirHc+J5Y439g0BdHxRtXVrOAzIrGEKA0m1mp9b/U="; + }; + installPhase = '' + cp -r $src $out + ''; + }; + run-nextflow-pipeline = pkgs.writeShellApplication { + name = "run-nextflow-pipeline"; + runtimeInputs = [ pkgs.nextflow ]; + text = '' + export NXF_OFFLINE=true + for b in false true; do + echo "docker.enabled = $b" > nextflow.config + cat nextflow.config + nextflow run -ansi-log false ${hello} + done + ''; + }; + in + { + name = "nextflow"; + + nodes.machine = + { ... }: + { + environment.systemPackages = [ + run-nextflow-pipeline + pkgs.nextflow + ]; + virtualisation = { + docker.enable = true; + }; + }; + + testScript = + { nodes, ... }: + '' + start_all() + machine.wait_for_unit("docker.service") + machine.succeed("docker load < ${bash}") + machine.succeed("run-nextflow-pipeline >&2") + ''; + } +) diff --git a/pkgs/development/interpreters/nextflow/default.nix b/pkgs/development/interpreters/nextflow/default.nix index 3b2a41919a06..e76265f63d35 100644 --- a/pkgs/development/interpreters/nextflow/default.nix +++ b/pkgs/development/interpreters/nextflow/default.nix @@ -12,6 +12,7 @@ coreutils, bash, testers, + nixosTests, }: stdenv.mkDerivation (finalAttrs: { pname = "nextflow"; @@ -83,6 +84,7 @@ stdenv.mkDerivation (finalAttrs: { --set JAVA_HOME ${openjdk.home} ''; + passthru.tests.default = nixosTests.nextflow; # versionCheckHook doesn't work as of 2024-09-23. # See https://github.com/NixOS/nixpkgs/pull/339197#issuecomment-2363495060 passthru.tests.version = testers.testVersion {