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

Output only to stdout in github actions #7135

Merged
merged 6 commits into from
Feb 13, 2023

Conversation

underyx
Copy link
Member

@underyx underyx commented Feb 13, 2023

PR checklist:

  • Purpose of the code is evident to future readers
  • Tests included or PR comment includes a reproducible test plan
  • Documentation is up-to-date
  • A changelog entry was added to changelog.d for any user-facing change
  • Change has no security implications (otherwise, ping security team)

If you're unsure on any of this, please see:

@underyx underyx requested a review from nmote February 13, 2023 18:16
@emjin
Copy link
Collaborator

emjin commented Feb 13, 2023

😭 This is interfering with how the benchmarks ingest results

@underyx
Copy link
Member Author

underyx commented Feb 13, 2023

😭 This is interfering with how the benchmarks ingest results

Could you link me to error logs or a line of code? Do benchmarks parse timing out of semgrep's text formatter output? If yes, can we switch it to use JSON output?

@emjin
Copy link
Collaborator

emjin commented Feb 13, 2023

@emjin
Copy link
Collaborator

emjin commented Feb 13, 2023

Do benchmarks parse timing out of semgrep's text formatter output? If yes, can we switch it to use JSON output?

No, but they are now stumped by the results header

2023-02-13 18:27:45,342 - /home/runner/work/semgrep/semgrep/cli/../perf/run-benchmarks - ERROR - Unable to decode the Semgrep result as JSON. Exiting.
******
b'                                                                                \n                                                                                \n\xe2\x95\xad\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x95\xae                                                                     \n\xe2\x94\x82 Results \xe2\x94\x82                                                                     \n\xe2\x95\xb0\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x95\xaf                                                                     \n                                                                                \n{"errors": [], "paths": {"_comment": "<add --verbose for a list of skipped paths>", "scanned": ["/home/runner/work/semgrep/semgrep/perf/bench/dummy/input/dummy/targets/hello.js",  ...

@nmote
Copy link
Collaborator

nmote commented Feb 13, 2023

I guess it's a bit problematic to change this behavior whenever we are in GHA, since we run all of our tests in GHA. It seems like this will make all the snapshot tests behave differently when run locally vs when run in CI. This seems problematic, and I'm not sure how best to address it.

@underyx
Copy link
Member Author

underyx commented Feb 13, 2023

I guess it's a bit problematic to change this behavior whenever we are in GHA, since we run all of our tests in GHA. It seems like this will make all the snapshot tests behave differently when run locally vs when run in CI. This seems problematic, and I'm not sure how best to address it.

Our tests are already immune from this issue and have isolated env vars 👍

@underyx
Copy link
Member Author

underyx commented Feb 13, 2023

@emjin I think this is all we needed to do to fix benchmarks 2bb63ba

@underyx underyx requested a review from emjin February 13, 2023 19:08
@nmote
Copy link
Collaborator

nmote commented Feb 13, 2023

Cool, I will let @emjin finish the review then. Thanks for addressing this so quickly!

@emjin
Copy link
Collaborator

emjin commented Feb 13, 2023

Benchmarks work! Unfortunately there are other tests failing. It looks like semgrep-core's stdout and stderr streams might also be mixed? And this is causing semgrep-core output to be incorrectly processed. Note that semgrep-proprietary isn't well tested so presumably has a similar problem

@underyx
Copy link
Member Author

underyx commented Feb 13, 2023

Oof. The issue is that semgrep-core has a Python preexec function which uses the same logger as the CLI.

This just happened to work before due to luck, but is conceptually wrong as there are very different rules of communication between core -> cli, than there are between cli -> user :D

@emjin
Copy link
Collaborator

emjin commented Feb 13, 2023

Maybe we just have the offset output for launch, and we merge this after? This is seeming like a larger change since we're fixing how semgrep-core communicates, and I don't think the output being off is a blocker for launch

@underyx underyx enabled auto-merge (squash) February 13, 2023 22:10
Copy link
Collaborator

@emjin emjin left a comment

Choose a reason for hiding this comment

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

We went through a bunch of edge cases and think it looks good!

@underyx underyx merged commit 7820b65 into develop Feb 13, 2023
@underyx underyx deleted the bence/sc-607-stdout-and-stderr-are-mixed-together-in branch February 13, 2023 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants