Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make CI red when build fails #119

Closed
rudymatela opened this issue Jun 10, 2022 · 3 comments · Fixed by #120
Closed

Make CI red when build fails #119

rudymatela opened this issue Jun 10, 2022 · 3 comments · Fixed by #120
Assignees
Labels
bug Something isn't working hackathon Hackathon day testing Testing

Comments

@rudymatela
Copy link

rudymatela commented Jun 10, 2022

Currently (Jun 2022) Hoff, whenever the nix-build step fails, the CI does not detect it and we are left with a green build ✔️ even though the build was supposed to be red ❌.

Here is an example:

Here's the failing command and output section:

$ nix-build --no-out-link release.nix | cachix push channable-public
...
[11 of 12] Compiling WebInterface     ( src/WebInterface.hs, dist/build/WebInterface.p_o ) 00:43
[12 of 12] Compiling Server           ( src/Server.hs, dist/build/Server.p_o ) 00:45
dist/build/libHShoff-0.25.2-9YPwmF3FCRkEo14kDrjgdt-ghc8.10.4.a: hPutBuf: resource exhausted (No space left on device) 00:45
error: writing to file: No space left on device 00:45
Nothing to push. 00:45 

Semaphore fails to detect this as although nix-build fails, cachix succeeds. The error code of a pipe is (normally) the error code of the last command. So we should try to break down the commands into two. Something like this:

nix-build --no-out-link release.nix > something

cat something | cachix push channable-public

Issue present since 19 April 2022

The CI build was failing all along for two previous versions:

The issue has been here since 19 April 2022 after this merge with hash c4c2e38 PR #105.

The CI build was still okay on v0.24.0

@rudymatela rudymatela self-assigned this Jun 10, 2022
@rudymatela rudymatela added bug Something isn't working testing Testing hackathon Hackathon day labels Jun 10, 2022
@rudymatela
Copy link
Author

Btw, thanks to @ReinierMaas for actually discovering that the build was broken in the first place. ... and to @maartenberg for suggesting cachix push channable $(nix-build ...) as an alternative fix. :-)

@tomwassenberg
Copy link
Member

suggesting cachix push channable $(nix-build ...) as an alternative fix. :-)

I think cachix push channable $(nix-build ...) will still attempt to run the outer command (cachix ...) when the inner command (nix-build ...) fails.

So if we don't want to rely on the cachix command itself returning a non-zero exit code, I think this would fix it:

# This will return the exit code of the inner command 
$ hoff_store_path=$(nix-build ...)

# Thus, the pipeline will have failed before here if the nix-build was unsuccessful.
$ cachix push channable $hoff_store_path

@ruuda
Copy link

ruuda commented Jun 11, 2022

Semaphore fails to detect this as although nix-build fails, cachix succeeds. The error code of a pipe is (normally) the error code of the last command.

You can also set -o pipefail to prevent errors from being masked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hackathon Hackathon day testing Testing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants