-
Notifications
You must be signed in to change notification settings - Fork 2k
feat: allow specifying concurrency in config / environment #10236
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
feat: allow specifying concurrency in config / environment #10236
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@kade-robertson is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for the contribution. Everything looks good aside from the removing of the inputs.execution_args
reference in opts
.
If you could rebase, I'll work on getting this merged and released in the next canary. Thank you for the contribution! |
4296e89
to
447b0e8
Compare
Should be good to go! |
### Description This is a follow-up fix to: #10236 As it turns out, this change presented a regression in how the `--concurrency` flag behaves in watch mode. Previously, since this flag was read from the `execution_args` directly, it worked as expected. After switching it to read from `config`, it no longer worked in `watch` mode, as `Args` would only extract correctly from the `Run` command. This change lets the `Args::execution_args()` getter return the execution args from the watch command that has been run, if present. This _is_ a pretty significant change, as previously _none_ of the run mode execution args would be respected in watch mode. I'm not totally confident this is desired. The alternative is to bring back the special case for `concurrency`, and try to read from execution_args directly when parsing it, and falling back to `config` otherwise. ### Testing Instructions 1. Clone `main` and `pnpm build:turbo` 2. Run `./path/to/turbo watch <some-cmd>` in a repository where more than 10 tasks (the default) are persistent 3. Observe that even specifying `--concurrency=<task-count>` does not override this setting 4. Checkout the v2.5.0 commit and rebuild 5. Run the same test, and observe that the concurrency flag works as expected 6. Finally, clone this branch and rebuild 7. Run the same test, and observe that the concurrency flag works as expected
### Description This is a follow-up fix to: #10236 Unfortunately I didn't notice `turbo-types` is where the schema actually lives and is generated from, so the configuration schema never got updated to support this option. ### Testing Instructions 1. Install turborepo 2.5.1 2. Add a "concurrency" option to your `turbo.json` 3. Observe that using the public schema URL in `$schema` flags the concurrency option as an unknown property. 4. Clone this branch 5. Change the path in `$schema` to point to the schema in this branch 6. Observe the previous warning goes away.
Description
This adds a couple new ways to configure task run concurrency:
TURBO_CONCURRENCY
environment variableconcurrency
configuration value inturbo.json
These options should follow the same precedence rules for other options which are made available in multiple locations. I think the environment variable is the most valuable to me (IMO), as this would make it a lot easier to turn off or drastically reduce concurrency in CI scenarios with restricted performance, where running multiple test suites at the same time could cause flaky results due to timeouts, or too much resource contention in general scenarios. Being able to specify this in the configuration file is maybe less valuable, but there are situations where it might be desirable.
The
--concurrency
option is obviously already available and certainly usable in combination with other changes (enforcing the use of an alias, or setting up differentpackage.json
scripts for CI and local development), but enabling this to be enforced via the config or an environment variable makes it a lot easier to turn off concurrency in CI, for example.There is some active desire for this feature to exist:
Notably, this does not enable configuring concurrency per task, which was part of one of the discussions here. That seemed like a much larger lift vs. just adding an environment variable and config option that behaved exactly like the CLI argument already does. There is still some demand for this "simple" option.
Testing Instructions
turbo
turbo.json
, with the same behaviour as the CLI argument.TURBO_CONCURRENCY
environment variable, with the same behaviour as the CLI argument.I've done this checks (with some print debugging) on repos where I use
turbo
and it seems to work as expected. I've added some unit and integration tests where it seemed to make the most sense, but there were some spots where it was unclear if I should add something. If I've missed a spot or need some additional checks, let me know!