bcomnes / npm-run-all2

A CLI tool to run multiple npm-scripts in parallel or sequential. (Maintenance fork)
MIT License
250 stars 12 forks source link

Provide a way to limit max-parallel on CI #116

Open atomicpages opened 1 year ago

atomicpages commented 1 year ago

CI systems generally have restricted resources so it'd be great to limit the number of parallel processes via env var. I envision something like this:

MAX_PARALLEL_TASKS=4 npm-run-all -p build:*

a more verbose example with gitlab CI might look like:

build:
  stage: build
  script:
    - export MAX_PARALLEL_TASKS=2
    - npm ci
    - npx npm-run-all -p lint test check-types
    - npm run build

I'd be happy to make a MR for this if the community is interested. LMK! 🙏

bcomnes commented 1 year ago

Open to it.

lunsdorf commented 8 months ago

Hi there. I was looking to see if this was something I could do. There is already an --max-parallel <number> option. @atomicpages, is your suggestion different from that?

atomicpages commented 8 months ago

Slightly! My suggestion was to read from an environment variable if --max-parallel can't be used. In my case I have a complex monorepo that uses npm-run-all at the root and in packages so something like:

{
  "scripts": {
    "build": "pnpm --filter '@internal' build --if-present"
  }
}

triggers a bunch of npm-run-all scripts to get executed as well.

bcomnes commented 8 months ago

If you want to add an ENV lookup where the flag is read, it probably wouldn't be hard to add (hopefully). Maybe call it RUN_P_MAX_PARALLE just so it's a bit more scoped.

voxpelli commented 7 months ago

@atomicpages The better solution would be to add workspace support to npm-run-all2, right? https://github.com/bcomnes/npm-run-all2/issues/60 Although that's easier said than done so I can see the need for a stopgap measure like this – either within this module itself or through some other mechanism