push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
{
lib,
callPackage,
makeSetupHook,
valkey,
python3Packages,
}:
makeSetupHook {
name = "redis-test-hook";
substitutions = {
cli = lib.getExe' valkey "redis-cli";
server = lib.getExe' valkey "redis-server";
};
passthru.tests = {
simple = callPackage ./test.nix { };
python3-valkey = python3Packages.valkey;
};
} ./redis-test-hook.sh

View File

@@ -0,0 +1,45 @@
preCheckHooks+=('redisStart')
postCheckHooks+=('redisStop')
redisStart() {
if [[ "${redisTestPort:-}" == "" ]]; then
redisTestPort=6379
fi
mkdir -p "$NIX_BUILD_TOP/run"
if [[ "${REDIS_SOCKET:-}" == "" ]]; then
REDIS_SOCKET="$NIX_BUILD_TOP/run/redis.sock"
fi
export REDIS_SOCKET
REDIS_CONF="$NIX_BUILD_TOP/run/redis.conf"
export REDIS_CONF
cat <<EOF > "$REDIS_CONF"
unixsocket ${REDIS_SOCKET}
port ${redisTestPort}
protected-mode no
enable-debug-command yes
enable-module-command yes
EOF
echo 'starting redis'
# Note about Darwin: unless the output is redirected, the parent process becomes launchd instead of bash.
# This would leave the Redis process running in case of a test failure (the postCheckHook would not be executed),
# hanging the Nix build forever.
@server@ "$REDIS_CONF" > /dev/null 2>&1 &
REDIS_PID=$!
echo 'waiting for redis to be ready'
while ! @cli@ --scan -s "$REDIS_SOCKET" ; do
sleep 1
done
}
redisStop() {
echo 'stopping redis'
kill "$REDIS_PID"
}

View File

@@ -0,0 +1,47 @@
{
valkey,
redisTestHook,
stdenv,
}:
stdenv.mkDerivation {
name = "redis-test-hook-test";
nativeCheckInputs = [
valkey
redisTestHook
];
dontUnpack = true;
doCheck = true;
preCheck = ''
redisTestPort=6380
REDIS_SOCKET=/tmp/customredis.sock
'';
checkPhase = ''
runHook preCheck
echo "running test"
if redis-cli --scan -p $redisTestPort; then
echo "connected to redis via localhost"
PORT_TEST_RAN=1
fi
if redis-cli --scan -s $REDIS_SOCKET; then
echo "connected to redis via domain socket"
SOCKET_TEST_RAN=1
fi
runHook postCheck
'';
installPhase = ''
[[ $PORT_TEST_RAN == 1 && $SOCKET_TEST_RAN == 1 ]]
echo "test passed"
touch $out
'';
__darwinAllowLocalNetworking = true;
}