-
Notifications
You must be signed in to change notification settings - Fork 9
chore: Support npm, yarn, and pnpm across reusable workflows - W-23613503 #185
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,60 @@ | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| package-manager: | ||
| type: string | ||
| required: false | ||
| default: yarn | ||
| description: "Package manager to use: npm, pnpm, or yarn" | ||
| package-manager-version: | ||
| type: string | ||
| required: false | ||
| default: "10" | ||
| description: pnpm version to install when package-manager is pnpm | ||
| cache-dependency-path: | ||
| type: string | ||
| required: false | ||
| default: yarn.lock | ||
| description: Path to the package manager lockfile | ||
| install-command: | ||
| type: string | ||
| required: false | ||
| default: yarn install --network-timeout 600000 | ||
| description: Command used to install repository dependencies | ||
| build-command: | ||
| type: string | ||
| required: false | ||
| default: yarn build | ||
| description: Command used to build the project | ||
| test-command: | ||
| type: string | ||
| required: false | ||
| default: yarn test | ||
| description: Command used to run unit tests | ||
| wireit-install-command: | ||
| type: string | ||
| required: false | ||
| default: yarn add wireit@^0.14.12 | ||
| description: Command used to install the wireit workaround | ||
|
|
||
| jobs: | ||
| linux-unit-tests: | ||
| uses: salesforcecli/github-workflows/.github/workflows/unitTestsLinux.yml@main | ||
| with: | ||
| package-manager: ${{ inputs.package-manager }} | ||
| package-manager-version: ${{ inputs.package-manager-version }} | ||
| cache-dependency-path: ${{ inputs.cache-dependency-path }} | ||
| install-command: ${{ inputs.install-command }} | ||
| build-command: ${{ inputs.build-command }} | ||
| test-command: ${{ inputs.test-command }} | ||
| wireit-install-command: ${{ inputs.wireit-install-command }} | ||
| windows-unit-tests: | ||
| uses: salesforcecli/github-workflows/.github/workflows/unitTestsWindows.yml@main | ||
| with: | ||
| package-manager: ${{ inputs.package-manager }} | ||
| package-manager-version: ${{ inputs.package-manager-version }} | ||
| cache-dependency-path: ${{ inputs.cache-dependency-path }} | ||
| install-command: ${{ inputs.install-command }} | ||
| build-command: ${{ inputs.build-command }} | ||
| test-command: ${{ inputs.test-command }} | ||
| wireit-install-command: ${{ inputs.wireit-install-command }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why yarn as default and not npm ci? The shared composite action setupNodeAndInstall has smart auto-substitution logic but it only fires when the incoming install-command is exactly "npm ci", so if someone chooses npm/pnpm but misses passing the install command then yarn would still run.
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.
Yarn is the default on that input because
unitTestsWindows.ymlstill always installs with Yarn.setupNodeAndInstallonly rewrites an install command when it is exactlynpm ci, so a Yarn default does not get rewritten whenpackage-managerisnpmorpnpm.The reviewed
default: yarn/default: yarn install --network-timeout 600000inputs are on PR head5468051, not in this checkout. This worktree iscd2eafc. Here the workflow has noinstall-commandinput and hardcodes Yarn:Current callers pass no package-manager inputs. A workflow default of
npm ciwould change those runs. The Yarn default keeps that behavior.The substitution claim matches the composite action in this tree. Its own defaults are
npmandnpm ci, and the rewrite runs only for that exact command:There is no reverse case.
yarn install --network-timeout 600000is passed through. Settingpackage-managertonpmorpnpmand leavinginstall-commandat the workflow default still runs Yarn.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.
Ahgot it. It would be nice add something like below to avoid the case of mismatching package-manager and install command: