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

docs: remove github-actions-cpu-cores recommendation #14421

Closed
wants to merge 1 commit into from

Conversation

blimmer
Copy link
Contributor

@blimmer blimmer commented Aug 16, 2023

Summary

As of Jest 29.4.0, you no longer need to use the github-actions-cpu-cores action to properly set --max-workers. All that action does is use os.availableParallelism(), which jest now does natively after #13738.

Test plan

Docs only

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Aug 16, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: blimmer / name: Ben Limmer (92551e8)

@netlify
Copy link

netlify bot commented Aug 16, 2023

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 92551e8
🔍 Latest deploy log https://app.netlify.com/sites/jestjs/deploys/64de45bd4b2f6d00081ab7f6
😎 Deploy Preview https://deploy-preview-14421--jestjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@blimmer blimmer force-pushed the deprecate-cpu-cores-action-rec branch from 09943c5 to 0a986ff Compare August 16, 2023 16:26
uses: SimenB/github-actions-cpu-cores@v1
- name: run tests
run: yarn jest --max-workers ${{ steps.cpu-cores.outputs.count }}
```
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alternatively, we could leave this and add an info section that it's necessary beyond 29.4.0

@blimmer blimmer changed the title docs: remove github-actions-cpu-cores rec docs: remove github-actions-cpu-cores recommendation Aug 16, 2023
@blimmer blimmer marked this pull request as ready for review August 16, 2023 16:30
@SimenB
Copy link
Member

SimenB commented Aug 17, 2023

While that API has been backported to node 18, it has not been backported to v14 or v16, both of which Jest still supports.

I'm happy to tweak the docs to point that out, but I don't think we should remove it yet.

@blimmer blimmer force-pushed the deprecate-cpu-cores-action-rec branch from 0a986ff to 92551e8 Compare August 17, 2023 16:07
@blimmer
Copy link
Contributor Author

blimmer commented Aug 17, 2023

Ah, good to know. I've updated this PR - feedback on phrasing is welcome.

@blimmer
Copy link
Contributor Author

blimmer commented Aug 17, 2023

@SimenB , given what you said, is the action inaccurately configured? https://github.com/SimenB/github-actions-cpu-cores/blob/a0a2b80333e58828f914f98cfffe6d91350afa9d/action.yml#L6-L8

It appears to be running on Node 16, which doesn't have the availableParallelism method.

@SimenB
Copy link
Member

SimenB commented Aug 18, 2023

It's forward compatible 😀

Runners are only available using Node 12 (deprecated) and 16: https://github.blog/changelog/2022-05-20-actions-can-now-run-in-a-node-js-16-runtime/

@blimmer
Copy link
Contributor Author

blimmer commented Aug 21, 2023

Gotcha. I guess I'm a little bit confused when this action would be useful, then. From what I can gather, as configured, it's using os.cpus().length, which is built into Jest and has been available since Node 14.

Testing this on a sample GitHub action, it looks like os.cpus().length is properly returning 2 CPUs on the default runner.

If os.cpus.length() was returning an invalid response and the github-actions-cpu-cores could opt into Node 18+ (for os.availableParallelism()), I could see why you'd want to use it.

Could you help me understand a concrete scenario where this action would be better than the default Jest behavior?

@SimenB
Copy link
Member

SimenB commented Aug 22, 2023

#10653 (comment)

Jest's default implementation is to leave one core alone, though, which is why I specify it

As mentioned there though, we can probably stop doing - 1 on CI. I'd consider that a breaking change tho (if people do CI=1 npx jest locally, we'd swamp their resources)

@blimmer
Copy link
Contributor Author

blimmer commented Aug 26, 2023

Ah, OK, thanks for the explanation. I understand now why the action is helpful. I agree that using all cores on CI by default (with a major version bump) would be a nice improvement. I'll just close this for now. Thanks!

@blimmer blimmer closed this Aug 26, 2023
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants