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: Exit code not properly returned when using steps #760

Open
1 task done
bvoq opened this issue Sep 23, 2024 · 12 comments
Open
1 task done

fix: Exit code not properly returned when using steps #760

bvoq opened this issue Sep 23, 2024 · 12 comments
Labels
bug Something isn't working

Comments

@bvoq
Copy link

bvoq commented Sep 23, 2024

Is there an existing issue for this?

  • I have searched the existing issues.

Version

6.1.0

Description

Adding the following step will lead to a zero exit code, even when the test is supposed to fail.

scripts:
  test:
    steps:
      - melos exec -f --dir-exists=test -- flutter test

If you run melos test I would expect a non-zero exit code, however I get exit code 0.
However, if you run melos exec -f --dir-exists=test -- flutter test directly, you will get exit code 1.

Steps to reproduce

Add any failing test to your project.
Then add the above script to melos.yaml.
Then run melos test which should throw a non-zero exit code.

Expected behavior

I would expect a non-zero exit code but I get a zero exit code.

Screenshots

No response

Additional context and comments

This was tested on macOS but I don't think it's platform specific.

@bvoq bvoq added the bug Something isn't working label Sep 23, 2024
@bvoq bvoq changed the title Bug: Exit code not properly returned when using steps fix: Exit code not properly returned when using steps Sep 23, 2024
@spydon
Copy link
Collaborator

spydon commented Sep 23, 2024

This is a duplicate of #527
Which you also commented on...

@spydon spydon closed this as not planned Won't fix, can't repro, duplicate, stale Sep 23, 2024
@bvoq
Copy link
Author

bvoq commented Sep 23, 2024

This is a duplicate of #527 Which you also commented on...

Ok thanks, I wasn't sure if I needed to file a new issue.
Thanks for maintaining this cool tool :-)

@spydon
Copy link
Collaborator

spydon commented Sep 24, 2024

Ah, this is actually not a duplicate, I'm re-opening this one.

@spydon spydon reopened this Sep 24, 2024
@spydon
Copy link
Collaborator

spydon commented Sep 24, 2024

@jessicatarra could you maybe have a look at this one? :)

@Isakdl
Copy link

Isakdl commented Nov 29, 2024

I ran into this today, any updates?

@spydon
Copy link
Collaborator

spydon commented Nov 29, 2024

I ran into this today, any updates?

No updates, but we're open to PRs!

@christerswahn
Copy link
Contributor

This issue should be high priority to fix, it unfortunately makes melos unreliable to use in any scripting including CI.

Are you adressing it?

It seems the culprit is in persistent_shell.dart which swallows the exit code:

  Future<void> stopShell() async {
    await _process.stdin.close();
    final exitCode = await _process.exitCode;
    if (exitCode == 0) {
      logger.log(successLabel);
      return;
    }
    logger.log(failedLabel);
  }

@spydon
Copy link
Collaborator

spydon commented Dec 4, 2024

@christerswahn feel free to submit a PR, this issue isn't assigned to anyone currently (tell me if you plan to and I'll assign you).

A workaround meanwhile is to not use steps, but use a script separated by && like before the steps feature existed.

@christerswahn
Copy link
Contributor

I made a fork of your repo to see if it was a difficult fix or not, but the test suite failed out of the box (formatting checking tests it seemed) so I gave up on that.

@spydon
Copy link
Collaborator

spydon commented Dec 5, 2024

I made a fork of your repo to see if it was a difficult fix or not, but the test suite failed out of the box (formatting checking tests it seemed) so I gave up on that.

What OS are you on? The test suite passes for me, but I know it does have some flaky/broken tests in the CI too unfortunately (#724).

EDIT: also make sure that you've activated the local Melos before running the test suite.

@christerswahn
Copy link
Contributor

What OS are you on? The test suite passes for me, but I know it does have some flaky/broken tests in the CI too unfortunately (#724).
EDIT: also make sure that you've activated the local Melos before running the test suite.

I'm on MacOS, using Bash 5. Yes I activated local Melos.

@christerswahn
Copy link
Contributor

I made a first PR to fix the failing test cases. If this is approved and merged I could go ahead and look at this actual issue.

#799

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

No branches or pull requests

4 participants