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

[Feature] Add -l,--label argument to workspaces foreach as a step down from -v,--verbose. #6033

Closed
2 tasks done
seansfkelley opened this issue Dec 22, 2023 · 0 comments · Fixed by #6034
Closed
2 tasks done
Labels
enhancement New feature or request

Comments

@seansfkelley
Copy link
Contributor

seansfkelley commented Dec 22, 2023

  • I'd be willing to implement this feature (contributing guide)
  • This feature is important to have in this repository; a contrib plugin wouldn't do

Describe the user story

Using workspaces foreach in CI all but requires the use of --verbose so that you know which package any given output line comes from. But if a task has no or minimal output, the CI output is polluted with usually-pretty-uninteresting Process started/Process exited pairs, which (when you have dozens of packages) help obscure any output of interest.

notionalized output from only part of my CI running Prettier
[some-package]: Process started
[package-number-2]: Process started
[a-third-package]: Process started
[@namespace/helloworld]: Process started
[package-number-2]: Checking formatting...
[package-number-2]: All matched files use Prettier code style!
[package-number-2]: Process exited (exit code 0), completed in 18s 874ms
[some-package]: Checking formatting...
[some-package]: All matched files use Prettier code style!
[some-package]: Process exited (exit code 0), completed in 22s 991ms
[@namespace/helloworld]: Checking formatting...
[@namespace/helloworld]: All matched files use Prettier code style!
[@namespace/helloworld]: Process exited (exit code 0), completed in 25s 365ms
[my-awesome-package]: Process started
[a-third-package]: Checking formatting...
[a-third-package]: [warn] lib/timezones.js
[a-third-package]: [warn] Code style issues found in the above file. Run Prettier to fix.
[a-third-package]: Process exited (exit code 1), completed in 32s 530ms
[shortie]: Process started
[my-awesome-package]: Checking formatting...
[my-awesome-package]: All matched files use Prettier code style!
[my-awesome-package]: Process exited (exit code 0), completed in 20s 127ms
[almost-there]: Process started
[shortie]: Checking formatting...
[shortie]: All matched files use Prettier code style!
[shortie]: Process exited (exit code 0), completed in 23s 518ms
[why-hello-there]: Process started
[almost-there]: Checking formatting...
[almost-there]: All matched files use Prettier code style!
[almost-there]: Process exited (exit code 0), completed in 18s 920ms
[why-hello-there]: Checking formatting...
[why-hello-there]: All matched files use Prettier code style!
[why-hello-there]: Process exited (exit code 0), completed in 16s 461ms

Try to see which file in the above output failed the task! Now imagine doing that for 100 packages.

Describe the solution you'd like

A -l,--label argument to workspaces foreach run, which prefixes every log line with the package but does not print start/exit/timing information. -v,--verbose would imply -l,--label.

This has to be implemented in core, since this behavior is part of a core plugin.

same notional output as above, but without the start/exit lines
[package-number-2]: Checking formatting...
[package-number-2]: All matched files use Prettier code style!
[some-package]: Checking formatting...
[some-package]: All matched files use Prettier code style!
[@namespace/helloworld]: Checking formatting...
[@namespace/helloworld]: All matched files use Prettier code style!
[a-third-package]: Checking formatting...
[a-third-package]: [warn] lib/timezones.js
[a-third-package]: [warn] Code style issues found in the above file. Run Prettier to fix.
[my-awesome-package]: Checking formatting...
[my-awesome-package]: All matched files use Prettier code style!
[shortie]: Checking formatting...
[shortie]: All matched files use Prettier code style!
[almost-there]: Checking formatting...
[almost-there]: All matched files use Prettier code style!
[why-hello-there]: Checking formatting...
[why-hello-there]: All matched files use Prettier code style!

The above example is still pretty wordy because of the Prettier CLI configuration, but it's already a lot easier to scan the highly-repetitive Prettier output for outliers.

Describe the drawbacks of your solution

  • Adding bloat to an already flag-ful command. It's not related to picking packages though, and I think it's the include/exclude/all/etc. flags that make the command a bit unwieldy, not logging.
  • Opens up the possibility of the rather weird --verbose --no-label, which if you want to do it... go for it. It's your party.

Describe alternatives you've considered

  1. Post-filtering the output to remove the offending lines. It works, but is overhead and can theoretically have false positives.
  2. Not using --verbose. Makes the CI all but impossible to understand. :(
@seansfkelley seansfkelley added the enhancement New feature or request label Dec 22, 2023
arcanis pushed a commit that referenced this issue Jan 3, 2024
…fying less logging. (#6034)

**What's the problem this PR addresses?**

Fixes #6033.

**How did you fix it?**

Changes the `-v,--verbose` flag in `workspaces foreach` to be a counter
rather than a boolean. With one level it prints prefixes, with two
levels it additionally prints start/finish/timing information (as was
the behavior before).

The default TTY behavior has not changed (maximum verbosity). The
behavior with a single `--verbose` _has_ changed, to be less verbose.

**Checklist**
<!--- Don't worry if you miss something, chores are automatically
tested. -->
<!--- This checklist exists to help you remember doing the chores when
you submit a PR. -->
<!--- Put an `x` in all the boxes that apply. -->
- [x] I have read the [Contributing
Guide](https://yarnpkg.com/advanced/contributing).

<!-- See
https://yarnpkg.com/advanced/contributing#preparing-your-pr-to-be-released
for more details. -->
<!-- Check with `yarn version check` and fix with `yarn version check
-i` -->
- [x] I have set the packages that need to be released for my changes to
be effective.

<!-- The "Testing chores" workflow validates that your PR follows our
guidelines. -->
<!-- If it doesn't pass, click on it to see details as to what your PR
might be missing. -->
- [x] I will check that all automated PR checks pass before the PR gets
reviewed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
1 participant