This haskell package does not much for now but query a redis server, just pings it to be exact.
Locally everything was fine so far. I nix-env’d a redis and spawned the redis-server, which got discovered, when the nix-build was executed and the package got it’s ping resolved by the server answering pong.
On the github-ci workflow side I tried different approaches including nix-env as locally etc., using a docker-based redis as service and using some other third-party action that installed redis onto the ci-machine.
I even injected REDIS_HOST and REDIS_PORT to the environment with no change to the end that all options regarding building on github’s CI lead to the error message:
Network.Socket.connect: <socket: 16>: does not exist (Connection refused)
To be translated roughly as: redis-server can’t be found by the haskell app.
I have a slight clue about it all but am unable yet to solve the problem. So my question would be for pointers or help what to do here.
The clue or part of the above question would be: Is it related to the pure nature of nix-build, might be visible just on github-CI due to effects on my local system, that the redis instance cannot be found? And if so, how would I prepare my nix file to include redis directly to the build and also spawn the server instance therein ?
Hi @573, maybe it isn’t so clear from the manuals but Nix builders usually forbid access to sockets in order to ensure that no impure side effects could alter the build process. If you need to do integration tests where you test your application to correctly work with external services I would advise you to do that using the NixOS testing infrastructure. You can find many examples of those tests in the /nixos/tests subdirectory of the nixpkgs repository
@azazel75 thanks, that information was indeed missing on my side, though I suspected it to be the case that external services will break purity. This is definitly something to work with.
And yes, I do indeed want integration tests using nixpkgs.
I will try and figure out how NixOS does it at the moment and if that applies to cachix-action/install-nix-action as well somehow.
I do hope to stick with github for that.
Note that there is still a potential bug when running the test, but that is out of the scope of my initial question here. Has to do with permissions in the vm spawned by the test. If I come up with progress on the former I will open up a new topic and link it here.
To clarify my original question once more: I wanted to do an integration test for my haskell project.
Luckily I was able to do exactly that now w/o qemu or nixosTests even.
Just writing that addendum due to nixosTests foreseen to be testing service to service communication which on an OS level something like my little haskell project does not apply to.