cucumber-js icon indicating copy to clipboard operation
cucumber-js copied to clipboard

Add an additional argument setParallelCanAssign

Open limaAniceto opened this issue 2 years ago • 1 comments

Thanks for looking but this is still a draft PR!

🤔 What's changed?

Hi there, First of all thank you very much for maintaining/developing cucumber!

If possible, I'd like to propose the following change based on my own requirements and other people's that I've seen here in github :)

The change is adding an additional argument to setParallelCanAssign which is an object with information regarding the worker

⚡️ What's your motivation?

Several folks have asked for the ability to run features per runner, from my own use-case this is doable if we get the CUCUMBER_WORKER_ID.

It should be available via process.env.CUCUMBER_ID, however that is not actually the case, see:

// This prints the CUCUMBER_WORKER_ID correctly: 0 | 1 | 2 | ...
console.log("Outside -> Works", process.env.CUCUMBER_WORKER_ID);

setParallelCanAssign((pickleInQuestion, inProgress) => {
  // Prints: undefined
  console.log("Inside -> Does not Work", process.env.CUCUMBER_WORKER_ID);

  return dontRunPicklesWithTag(pickleInQuestion, inProgress);
});

Therefore while looking at the source-code I realised it would be simple to add the worker information as an argument to the function (or more properties if needed later)

🏷️ What kind of change is this?

  • :bank: Refactoring/debt/DX (improvement to code design, tooling, documentation etc. without changing behaviour)
  • :zap: New feature (non-breaking change which adds new behaviour)

♻️ Anything particular you want feedback on?

Do you want an object with more information other than the worker?

📋 Checklist:

  • [x] I agree to respect and uphold the Cucumber Community Code of Conduct
  • [x] I've changed the behaviour of the code
    • [ ] I have added/updated tests to cover my changes.
  • [x] My change requires a change to the documentation.
    • [x] I have updated the documentation accordingly.
  • [x] Users should know about my change
    • [ ] I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.

limaAniceto avatar Feb 06 '23 17:02 limaAniceto

Coverage Status

Coverage: 98.561%. Remained the same when pulling 9212900fc357141097075d86c34772b8d7f4648b on limaAniceto:ma-parallel-add-worker into bf8f6816c1015090a323e38a5052fd6ac6711b51 on cucumber:main.

coveralls avatar Feb 27 '23 15:02 coveralls