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

fix: bail if purs exits non-ok #1285

Merged
merged 16 commits into from
Nov 4, 2024
Merged

fix: bail if purs exits non-ok #1285

merged 16 commits into from
Nov 4, 2024

Conversation

cakekindel
Copy link
Contributor

@cakekindel cakekindel commented Sep 16, 2024

closes #1284

Description of the change

TODO

Checklist:

  • Added the change to the "Unreleased" section of the changelog
  • Added some example of the new feature to the README
  • Added a test for the contribution (if applicable)

P.S.: the above checks are not compulsory to get a change merged, so you may skip them. However, taking care of them will result in less work for the maintainers and will be much appreciated 😊

@cakekindel
Copy link
Contributor Author

root@3a9a77b24532:/app# node ../spago/bin/bundle.js build
Reading Spago workspace configuration...

✓ Selecting 14 packages to build:
  ...
  
Downloading dependencies...
Building...
‼ Failed to decode PsaResult at index '0': Unexpected end of JSON input
Json was: 

✘ purs exited with non-ok status code: BySignal "SIGKILL"

@cakekindel cakekindel changed the title draft: fix: bail if purs exits non-ok fix: bail if purs exits non-ok Sep 16, 2024
@cakekindel
Copy link
Contributor Author

hmm maybe dying isn't the right thing to do?

@f-f
Copy link
Member

f-f commented Sep 16, 2024

Uh, it looks like this uncovered a funny bug - CI is failing on this test, which should have never passed in the first place because we are supposed to fail in that condition

logSuccess "Build succeeded."
pure true
else if Array.all identity arrErrorsIsEmpty && not (Cmd.exitedOk result) then do
Copy link
Member

@f-f f-f Sep 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having this code structured as a series of if/else makes it extra confusing, let's move it to a case statement, e.g.

case Array.all identity arrErrorsIsEmpty, Cmd.exitedOk result of
  -- No errors, and 0 exit code
  true, true -> ...
  -- No errors, but non-zero exit code, so something's up
  true, false -> ...
  -- Compilation errors, print them out
  false, _ -> ...

Let's also try to catch the JSON decoding error earlier: the scenario we are trying to prevent here has err being an empty string. So let's try to not print the warning if that's the case, hopefully it will reduce the log noise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok no problem, ended up changing the output traversal to collect into an array of eithers to defer that logging and changed to a case expression

Copy link
Member

@f-f f-f left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good - could we add a test for this? The best way I can think of is to try to pass a nonexistent flag to purs.

@cakekindel
Copy link
Contributor Author

Sorry forgot about this. Will do tomorrow!

@f-f
Copy link
Member

f-f commented Oct 31, 2024

@cakekindel did you get around to finish this or shall I take care of the last bits? I'd like to get this merged ASAP before it gets out of date

@cakekindel
Copy link
Contributor Author

cakekindel commented Oct 31, 2024

@cakekindel did you get around to finish this or shall I take care of the last bits? I'd like to get this merged ASAP before it gets out of date

Sorry I forgot again, updated & added test!

  • Chose to have the test override the purs binary so that we can directly control its behavior rather than trying to provoke a specific behavior from purs
  • Failure message ("IF YOURE SEEING THIS ...") is searchable. I can only imagine how awful it would be to identify this test as the root cause of failures if someone tried to run them in parallel for example 🥴
  • Test fails on master e7a4e7e

test/Spago/Build.purs Outdated Show resolved Hide resolved
Copy link
Member

@f-f f-f left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good, thanks! 👏

Let's see if I can merge with just applying the suggestion or if we need to fight CI any further

test/Spago/Build.purs Outdated Show resolved Hide resolved
test/Spago/Build.purs Outdated Show resolved Hide resolved
@cakekindel
Copy link
Contributor Author

cakekindel commented Nov 2, 2024

Is it still CRLF? No diff in log output 😕

@cakekindel

This comment was marked as resolved.

@cakekindel

This comment was marked as resolved.

@cakekindel

This comment was marked as resolved.

add contrarian newlines to the long list of problems bill gates is
responsible for cursing us with on this godforsaken hellscape we call
Earth.
@f-f
Copy link
Member

f-f commented Nov 3, 2024

@cakekindel could I ask you to not force push? It makes it harder to follow the changeset over the history of the PR.
We already have a way to deal with Windows newlines, and that that's through the sanitize hook; I pushed something that should approximate a fix in this commit. We use it in a similar way across all the tests, and I'd like to keep that consistent (we do use separate fixtures for windows in other places, but it's best to avoid those if possible, as they are annoying to regenerate)

@cakekindel
Copy link
Contributor Author

cakekindel commented Nov 3, 2024

@cakekindel could I ask you to not force push? It makes it harder to follow the changeset over the history of the PR.

Understood! I can definitely respect this, but also ask in return for patience / understanding as my instinct is not to prioritize a linear history on working branches. I may rebase onto upstream rather than merge by mistake.

I usually don't force push amendments, not sure why i did that here

We already have a way to deal with Windows newlines, and that that's through the sanitize hook; I pushed something that should approximate a fix in this commit. We use it in a similar way across all the tests, and I'd like to keep that consistent (we do use separate fixtures for windows in other places, but it's best to avoid those if possible, as they are annoying to regenerate)

I saw this after I realized I was out of date but the test still failed for some reason.

I'll revert my commits on top of yours and try to get your solution passing on windows, sorry 😔

@f-f
Copy link
Member

f-f commented Nov 4, 2024

Understood! I can definitely respect this, but also ask in return for patience / understanding as my instinct is not to prioritize a linear history on working branches. I may rebase onto upstream rather than merge by mistake.

Oh yeah no worries! It's not a hard rule, but using merge commits instead of rebasing makes it harder to lose content if I'm pushing to the same branch when trying to get things merged in 🙂
If you wouldn't like me to mess with your branch at all you can disable that - there should be a checkbox in the PR settings "allow edits from maintainers".

Comment on lines +101 to +105
let
renderNonPrinting =
String.replaceAll (String.Pattern "\r") (String.Replacement "␍")
>>> String.replaceAll (String.Pattern "\t") (String.Replacement "␉-->")
in
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is contentious i can undo, just thought it would be a good unobtrusive addition to catch failures early in CI

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah, I like it! (for now, let's see how it fares over time 😂)

Copy link
Member

@f-f f-f left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OMG CI passes 🎉 thank you again @cakekindel for getting this over the finish line! ❤️

@f-f f-f merged commit fb24ee6 into purescript:master Nov 4, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"failed to decode PsaResult" when purs compile exits due to OOM
2 participants