From 528943263040c9f383361b1a37a3ee4db66412af Mon Sep 17 00:00:00 2001 From: Anthony Oleinik <48811365+antholeole@users.noreply.github.com> Date: Thu, 14 Mar 2024 01:59:47 -0700 Subject: Add support for other procfile runners (#5) * WIP * WIP * WIP * done * done * fix CI * fix CI * refactor: default to overmind in mkProcfileRunner * module: cleanup option docs * refactor: cleanup multi-test suite --------- Co-authored-by: seth --- test/flake.nix | 89 +++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 66 insertions(+), 23 deletions(-) (limited to 'test') diff --git a/test/flake.nix b/test/flake.nix index 724fc9c..c465c0e 100644 --- a/test/flake.nix +++ b/test/flake.nix @@ -26,35 +26,78 @@ lib, pkgs, ... - }: { - procfiles.daemons.processes = { - redis = lib.getExe' pkgs.redis "redis-server"; - }; + }: let + mkTestShell = runtimeInputs: text: + pkgs.mkShellNoCC { + packages = [ + (pkgs.writeShellApplication { + name = "run-ci"; + + inherit runtimeInputs text; + }) + ]; + }; - devShells.default = pkgs.mkShellNoCC { - packages = [ - (pkgs.writeShellApplication { - name = "run-ci"; + testScript = exe: check: kill: '' + set -x - runtimeInputs = [pkgs.overmind]; + ${exe} + sleep 5 # avoid race conditions - text = '' - set -x + if ${check}; then + echo "Processes failed to launch! Exiting with error" + ${kill} + exit 1 + fi - exec ${lib.getExe config.procfiles.daemons.package} & - sleep 5 # avoid race conditions + ${kill} + echo "Process finished! Exiting as success" + ''; + + processes = { + redis = lib.getExe' pkgs.redis "redis-server"; + }; + in { + procfiles = { + # overmind as default + overmind-dft = {inherit processes;}; + + # explicit overmind + overmind = { + inherit processes; + procRunner = pkgs.overmind; + }; + + # honcho + honcho = { + inherit processes; + procRunner = pkgs.honcho; + }; + }; - if ! overmind status | grep running; then - echo "Processes failed to launch! Exiting with error" - overmind kill - exit 1 - fi + devShells = { + overmind-dft = mkTestShell [pkgs.overmind] ( + testScript + "exec ${(lib.getExe config.procfiles.overmind-dft.package)} &" + "! overmind status | grep running" + "overmind kill" + ); - overmind kill - echo "Process finished! Exiting as success" - ''; - }) - ]; + overmind = mkTestShell [pkgs.overmind] ( + testScript + "exec ${(lib.getExe config.procfiles.overmind.package)} &" + "! overmind status | grep running" + "overmind kill" + ); + honcho = mkTestShell [pkgs.honcho] ( + testScript + '' + exec ${(lib.getExe config.procfiles.honcho.package)} & \ + PROC_PID=$! + '' + "! ps -p \"$PROC_PID\" > /dev/null" + "kill -2 $PROC_PID; pkill -f \"redis\"" + ); }; }; }; -- cgit v1.2.3