From cd2eafce936387a7f7fa57b98f2ea9c26106de1e Mon Sep 17 00:00:00 2001 From: mshanemc Date: Thu, 17 Sep 2026 22:46:21 -0500 Subject: [PATCH 1/3] chore: Support npm, yarn, and pnpm across reusable workflows - W-23613503 --- plans/W-23613503.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 plans/W-23613503.md diff --git a/plans/W-23613503.md b/plans/W-23613503.md new file mode 100644 index 0000000..29f3057 --- /dev/null +++ b/plans/W-23613503.md @@ -0,0 +1,40 @@ +# W-23613503 — Support npm, yarn, and pnpm across reusable workflows + +## Context + +Reusable workflows that currently hard-code Yarn need to accept npm, Yarn, or pnpm without duplicating setup and install logic. Use the existing `.github/actions/setupNodeAndInstall/action.yml` composite action as the single package-manager setup, cache, and dependency-install path, while preserving npm defaults for existing callers. + +Files to change: + +- `.github/workflows/unitTestsLinux.yml` +- `.github/workflows/unitTestsWindows.yml` +- `.github/workflows/nut.yml` +- `.github/workflows/publishTypedoc.yml` +- `.github/workflows/tarballs.yml` +- `.github/workflows/packUploadMac.yml` +- `.github/workflows/packUploadWindows.yml` +- `README.md` + +## Phases + +### Phase 1 — Parameterize package-manager setup and commands + +Commit message: `feat: support npm yarn and pnpm in reusable workflows` + +- Add consistent `workflow_call` inputs for package manager, package-manager version, cache dependency path, install command, and workflow-specific commands where a Yarn command is currently fixed. +- Replace workflow-local Node cache and Yarn installation steps with `.github/actions/setupNodeAndInstall/action.yml`. +- Execute caller-provided commands for build, test, documentation, packaging, upload, and promotion steps instead of fixed Yarn commands. +- Document npm, Yarn, and pnpm caller configuration and the npm-compatible defaults in `README.md`. + +## Skills to apply + +- `implement` — make the workflow and documentation changes from this plan. +- `tdd` — add or update workflow validation coverage before changing behavior where the repository has executable coverage for these files. + +## Verification + +- Install repository dependencies with the package manager declared by this repository. +- Run the repository's existing formatting, linting, type-checking, and test commands that cover workflow and action files. +- Validate every changed workflow as GitHub Actions YAML. +- Confirm each changed reusable workflow has npm-compatible defaults and routes npm, Yarn, and pnpm through `.github/actions/setupNodeAndInstall/action.yml`. +- Confirm the documented caller examples match the final input names and defaults. From 4bf498df2c93a2a9052402fe69e10233013a315c Mon Sep 17 00:00:00 2001 From: mshanemc Date: Fri, 18 Sep 2026 17:15:32 -0500 Subject: [PATCH 2/3] feat: support npm, yarn, and pnpm in reusable CLI workflows - W-23613503 --- .github/workflows/nut.yml | 68 ++++++++++++++++------ .github/workflows/packUploadMac.yml | 53 ++++++++++++++--- .github/workflows/packUploadWindows.yml | 54 +++++++++++++++--- .github/workflows/publishTypedoc.yml | 46 +++++++++++++-- .github/workflows/tarballs.yml | 76 +++++++++++++++++++++---- .github/workflows/unitTest.yml | 52 +++++++++++++++++ .github/workflows/unitTestsLinux.yml | 69 +++++++++++++++------- .github/workflows/unitTestsWindows.yml | 68 ++++++++++++++++------ README.md | 51 +++++++++++++++++ plans/W-23613503.md | 40 ------------- 10 files changed, 453 insertions(+), 124 deletions(-) delete mode 100644 plans/W-23613503.md diff --git a/.github/workflows/nut.yml b/.github/workflows/nut.yml index cfe837a..517daf8 100644 --- a/.github/workflows/nut.yml +++ b/.github/workflows/nut.yml @@ -53,6 +53,41 @@ on: type: number default: 3 description: "Number of times to attempt NUTs" + 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 + compile-command: + type: string + required: false + default: yarn compile + description: Command used to compile the project + oclif-manifest-command: + type: string + required: false + default: yarn oclif manifest + description: Command used to generate the oclif manifest + wireit-install-command: + type: string + required: false + default: yarn add wireit@^0.14.12 + description: Command used to install the wireit workaround jobs: nut: @@ -68,19 +103,13 @@ jobs: - uses: google/wireit@setup-github-actions-caching/v2 continue-on-error: true - - uses: actions/setup-node@v4 + - uses: salesforcecli/github-workflows/.github/actions/setupNodeAndInstall@main with: node-version: ${{ inputs.nodeVersion }} - cache: yarn - - - name: Cache node modules - id: cache-nodemodules - uses: actions/cache@v4 - env: - cache-name: cache-node-modules - with: - path: "**/node_modules" - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }} + package-manager: ${{ inputs.package-manager }} + package-manager-version: ${{ inputs.package-manager-version }} + cache-dependency-path: ${{ inputs.cache-dependency-path }} + install-command: ${{ inputs.install-command }} - name: add CLI as global dependency uses: salesforcecli/github-workflows/.github/actions/retry@main @@ -88,23 +117,28 @@ jobs: max_attempts: ${{ inputs.retries }} command: npm install @salesforce/cli@nightly -g - - uses: salesforcecli/github-workflows/.github/actions/yarnInstallWithRetries@main - if: ${{ steps.cache-nodemodules.outputs.cache-hit != 'true' }} - # This is a temporary workaround to ensure wireit is >= 0.14.12 # Once all plugins/libs that use this workflow are updated, this can be removed # See: https://github.com/google/wireit/issues/1297#issuecomment-2794737569 - name: Install wireit - run: yarn add wireit@^0.14.12 + env: + WIREIT_INSTALL_COMMAND: ${{ inputs.wireit-install-command }} + run: bash -c "$WIREIT_INSTALL_COMMAND" - - run: yarn compile + - name: Compile + env: + COMPILE_COMMAND: ${{ inputs.compile-command }} + run: bash -c "$COMPILE_COMMAND" - name: Check that oclif config exists id: is-oclif-plugin run: echo "bool=$(jq 'if .oclif then true else false end' package.json)" >> "$GITHUB_OUTPUT" - - run: yarn oclif manifest + - name: Generate oclif manifest if: ${{ steps.is-oclif-plugin.outputs.bool == 'true' }} + env: + OCLIF_MANIFEST_COMMAND: ${{ inputs.oclif-manifest-command }} + run: bash -c "$OCLIF_MANIFEST_COMMAND" - name: Set optional sf executable path if: inputs.sfdxExecutablePath diff --git a/.github/workflows/packUploadMac.yml b/.github/workflows/packUploadMac.yml index 4ca5095..bc82ca7 100644 --- a/.github/workflows/packUploadMac.yml +++ b/.github/workflows/packUploadMac.yml @@ -13,6 +13,42 @@ on: type: string default: lts/* description: node version to use for the tarball build + 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 + pack-command: + type: string + required: false + default: yarn pack:macos + description: Command used to pack the macos installer + upload-command: + type: string + required: false + default: yarn upload:macos + description: Command used to upload the macos installer + promote-command: + type: string + required: false + default: yarn channel:promote --cli sf --version "$INPUTS_VERSION" --target "$INPUTS_CHANNEL" --platform macos + description: Command used to promote the macos installer + jobs: macos: env: @@ -21,31 +57,34 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 + - uses: salesforcecli/github-workflows/.github/actions/setupNodeAndInstall@main with: node-version: ${{ inputs.nodeVersion }} - cache: yarn - - - uses: salesforcecli/github-workflows/.github/actions/yarnInstallWithRetries@main + package-manager: ${{ inputs.package-manager }} + package-manager-version: ${{ inputs.package-manager-version }} + cache-dependency-path: ${{ inputs.cache-dependency-path }} + install-command: ${{ inputs.install-command }} - name: Pack for macos uses: salesforcecli/github-workflows/.github/actions/retry@main with: - command: yarn pack:macos + command: ${{ inputs.pack-command }} - name: Upload macos - run: yarn upload:macos env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + UPLOAD_COMMAND: ${{ inputs.upload-command }} + run: bash -c "$UPLOAD_COMMAND" - name: Promote macos to ${{ inputs.channel }} channel - run: yarn channel:promote --cli sf --version "$INPUTS_VERSION" --target "$INPUTS_CHANNEL" --platform macos env: INPUTS_VERSION: ${{ inputs.version }} INPUTS_CHANNEL: ${{ inputs.channel }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + PROMOTE_COMMAND: ${{ inputs.promote-command }} + run: bash -c "$PROMOTE_COMMAND" - name: Upload artifacts to Github release run: gh release upload "$INPUTS_VERSION" ./dist/macos/sf-*.pkg --clobber --repo "$GIT_REPOSITORY" diff --git a/.github/workflows/packUploadWindows.yml b/.github/workflows/packUploadWindows.yml index 5721f09..efa7288 100644 --- a/.github/workflows/packUploadWindows.yml +++ b/.github/workflows/packUploadWindows.yml @@ -13,6 +13,41 @@ on: type: string default: lts/* description: node version to use for the tarball build + 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 + pack-command: + type: string + required: false + default: yarn pack:win + description: Command used to pack the Windows installer + upload-command: + type: string + required: false + default: yarn upload:win + description: Command used to upload the Windows installer + promote-command: + type: string + required: false + default: yarn channel:promote --cli sf --version "$INPUTS_VERSION" --target "$INPUTS_CHANNEL" --platform win + description: Command used to promote the Windows installer jobs: win: @@ -22,10 +57,13 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 + - uses: salesforcecli/github-workflows/.github/actions/setupNodeAndInstall@main with: node-version: ${{ inputs.nodeVersion }} - cache: yarn + package-manager: ${{ inputs.package-manager }} + package-manager-version: ${{ inputs.package-manager-version }} + cache-dependency-path: ${{ inputs.cache-dependency-path }} + install-command: ${{ inputs.install-command }} - name: Set up Homebrew uses: Homebrew/actions/setup-homebrew@e05416b42376bcda221f9102c4f595f4994016be @@ -33,24 +71,26 @@ jobs: # TODO: It would be nice if we chould ditch homebrew for this install - run: brew install makensis - - uses: salesforcecli/github-workflows/.github/actions/yarnInstallWithRetries@main - - name: Pack for Windows - run: yarn pack:win + env: + PACK_COMMAND: ${{ inputs.pack-command }} + run: bash -c "$PACK_COMMAND" - name: Upload Windows - run: yarn upload:win env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + UPLOAD_COMMAND: ${{ inputs.upload-command }} + run: bash -c "$UPLOAD_COMMAND" - name: Promote win to ${{ inputs.channel }} channel - run: yarn channel:promote --cli sf --version "$INPUTS_VERSION" --target "$INPUTS_CHANNEL" --platform win env: INPUTS_VERSION: ${{ inputs.version }} INPUTS_CHANNEL: ${{ inputs.channel }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + PROMOTE_COMMAND: ${{ inputs.promote-command }} + run: bash -c "$PROMOTE_COMMAND" - name: Upload artifacts to Github release run: gh release upload "$INPUTS_VERSION" ./dist/win32/sf-*.exe --clobber --repo "$GITHUB_REPOSITORY" diff --git a/.github/workflows/publishTypedoc.yml b/.github/workflows/publishTypedoc.yml index e4cbe35..17d435b 100644 --- a/.github/workflows/publishTypedoc.yml +++ b/.github/workflows/publishTypedoc.yml @@ -4,6 +4,37 @@ on: SVC_CLI_BOT_GITHUB_TOKEN: description: A Github PAT with repo write access. required: true + 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 + docs-command: + type: string + required: false + default: yarn docs + description: Command used to generate documentation + nodeVersion: + type: string + required: false + default: lts/* + description: Node.js version to use jobs: publish: @@ -15,12 +46,13 @@ jobs: with: token: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }} - - uses: actions/setup-node@v4 + - uses: salesforcecli/github-workflows/.github/actions/setupNodeAndInstall@main with: - node-version: lts/* - cache: yarn - - - uses: salesforcecli/github-workflows/.github/actions/yarnInstallWithRetries@main + node-version: ${{ inputs.nodeVersion }} + package-manager: ${{ inputs.package-manager }} + package-manager-version: ${{ inputs.package-manager-version }} + cache-dependency-path: ${{ inputs.cache-dependency-path }} + install-command: ${{ inputs.install-command }} - name: Get Github user info id: github-user-info @@ -34,12 +66,14 @@ jobs: email: ${{ steps.github-user-info.outputs.email }} - name: Build docs + env: + DOCS_COMMAND: ${{ inputs.docs-command }} run: | rm -rf docs git worktree prune git fetch origin gh-pages:gh-pages git worktree add docs gh-pages - yarn docs + bash -c "$DOCS_COMMAND" - name: Send to git run: | diff --git a/.github/workflows/tarballs.yml b/.github/workflows/tarballs.yml index 8c3acde..b421dc1 100644 --- a/.github/workflows/tarballs.yml +++ b/.github/workflows/tarballs.yml @@ -17,6 +17,51 @@ on: type: string default: lts/* description: node version to use for the tarball build + 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 + pack-command: + type: string + required: false + default: yarn pack:tarballs + description: Command used to pack tarballs + verify-command: + type: string + required: false + default: yarn pack:verify + description: Command used to verify packed tarballs + smoke-command: + type: string + required: false + default: yarn test:smoke-unix + description: Command used to run unix smoke tests + upload-command: + type: string + required: false + default: yarn upload:tarballs + description: Command used to upload tarballs + promote-command: + type: string + required: false + default: yarn channel:promote --cli sf --version "$INPUTS_VERSION" --target "$INPUTS_CHANNEL" + description: Command used to promote uploaded tarballs jobs: tarballs: @@ -26,36 +71,47 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 + - uses: salesforcecli/github-workflows/.github/actions/setupNodeAndInstall@main with: node-version: ${{ inputs.nodeVersion }} - cache: yarn - - - uses: salesforcecli/github-workflows/.github/actions/yarnInstallWithRetries@main + package-manager: ${{ inputs.package-manager }} + package-manager-version: ${{ inputs.package-manager-version }} + cache-dependency-path: ${{ inputs.cache-dependency-path }} + install-command: ${{ inputs.install-command }} - name: pack tarballs uses: salesforcecli/github-workflows/.github/actions/retry@main with: - command: yarn pack:tarballs + command: ${{ inputs.pack-command }} retry_on: error - - run: yarn pack:verify + - name: Verify tarballs + env: + VERIFY_COMMAND: ${{ inputs.verify-command }} + run: bash -c "$VERIFY_COMMAND" - - run: yarn test:smoke-unix + - name: Smoke tests + env: + SMOKE_COMMAND: ${{ inputs.smoke-command }} + run: bash -c "$SMOKE_COMMAND" - if: inputs.upload - run: yarn upload:tarballs + name: Upload tarballs env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + UPLOAD_COMMAND: ${{ inputs.upload-command }} + run: bash -c "$UPLOAD_COMMAND" - if: inputs.upload && inputs.version && inputs.channel - run: yarn channel:promote --cli sf --version "$INPUTS_VERSION" --target "$INPUTS_CHANNEL" + name: Promote tarballs env: INPUTS_VERSION: ${{ inputs.version }} INPUTS_CHANNEL: ${{ inputs.channel }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + PROMOTE_COMMAND: ${{ inputs.promote-command }} + run: bash -c "$PROMOTE_COMMAND" - if: inputs.upload run: | @@ -63,4 +119,4 @@ jobs: gh release upload "$INPUTS_VERSION" ./dist/*.xz --clobber --repo "$GITHUB_REPOSITORY" env: INPUTS_VERSION: ${{ inputs.version }} - GH_TOKEN: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }} \ No newline at end of file + GH_TOKEN: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }} diff --git a/.github/workflows/unitTest.yml b/.github/workflows/unitTest.yml index 2103393..51eac05 100644 --- a/.github/workflows/unitTest.yml +++ b/.github/workflows/unitTest.yml @@ -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 }} diff --git a/.github/workflows/unitTestsLinux.yml b/.github/workflows/unitTestsLinux.yml index 169818f..4b1d867 100644 --- a/.github/workflows/unitTestsLinux.yml +++ b/.github/workflows/unitTestsLinux.yml @@ -6,6 +6,41 @@ on: required: false default: false description: skip `prevent-typescript-dependency`. Use it for devDeps that ship TS + 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: determine-node-versions: @@ -33,37 +68,33 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node_version }} - cache: yarn - - uses: google/wireit@setup-github-actions-caching/v2 continue-on-error: true - - name: Cache node modules - id: cache-nodemodules - uses: actions/cache@v4 - env: - cache-name: cache-node-modules + - uses: salesforcecli/github-workflows/.github/actions/setupNodeAndInstall@main with: - path: "**/node_modules" - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }} - - - uses: salesforcecli/github-workflows/.github/actions/yarnInstallWithRetries@main - if: ${{ steps.cache-nodemodules.outputs.cache-hit != 'true' }} + node-version: ${{ matrix.node_version }} + package-manager: ${{ inputs.package-manager }} + package-manager-version: ${{ inputs.package-manager-version }} + cache-dependency-path: ${{ inputs.cache-dependency-path }} + install-command: ${{ inputs.install-command }} # This is a temporary workaround to ensure wireit is >= 0.14.12 # Once all plugins/libraries that use this workflow are updated, this can be removed # See: https://github.com/google/wireit/issues/1297#issuecomment-2794737569 - name: Install wireit - run: yarn add wireit@^0.14.12 + env: + WIREIT_INSTALL_COMMAND: ${{ inputs.wireit-install-command }} + run: bash -c "$WIREIT_INSTALL_COMMAND" - - run: yarn build + - name: Build + env: + BUILD_COMMAND: ${{ inputs.build-command }} + run: bash -c "$BUILD_COMMAND" - - name: yarn test + - name: Test uses: salesforcecli/github-workflows/.github/actions/retry@main with: - command: yarn test + command: ${{ inputs.test-command }} env: SF_DISABLE_TELEMETRY: true diff --git a/.github/workflows/unitTestsWindows.yml b/.github/workflows/unitTestsWindows.yml index 4021897..2e042d9 100644 --- a/.github/workflows/unitTestsWindows.yml +++ b/.github/workflows/unitTestsWindows.yml @@ -1,5 +1,41 @@ 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: determine-node-versions: @@ -28,34 +64,30 @@ jobs: - uses: google/wireit@setup-github-actions-caching/v2 continue-on-error: true - - uses: actions/setup-node@v4 + - uses: salesforcecli/github-workflows/.github/actions/setupNodeAndInstall@main with: node-version: ${{ matrix.node_version }} - cache: yarn - - - name: Cache node modules - id: cache-nodemodules - uses: actions/cache@v4 - env: - cache-name: cache-node-modules - with: - path: "**/node_modules" - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }} - - - uses: salesforcecli/github-workflows/.github/actions/yarnInstallWithRetries@main - if: ${{ steps.cache-nodemodules.outputs.cache-hit != 'true' }} + package-manager: ${{ inputs.package-manager }} + package-manager-version: ${{ inputs.package-manager-version }} + cache-dependency-path: ${{ inputs.cache-dependency-path }} + install-command: ${{ inputs.install-command }} # This is a temporary workaround to ensure wireit is >= 0.14.12 # Once all plugins/libraries that use this workflow are updated, this can be removed # See: https://github.com/google/wireit/issues/1297#issuecomment-2794737569 - name: Install wireit - run: yarn add wireit@^0.14.12 + env: + WIREIT_INSTALL_COMMAND: ${{ inputs.wireit-install-command }} + run: bash -c "$WIREIT_INSTALL_COMMAND" - - run: yarn build + - name: Build + env: + BUILD_COMMAND: ${{ inputs.build-command }} + run: bash -c "$BUILD_COMMAND" - - name: yarn test + - name: Test uses: salesforcecli/github-workflows/.github/actions/retry@main with: - command: yarn test + command: ${{ inputs.test-command }} env: SF_DISABLE_TELEMETRY: true diff --git a/README.md b/README.md index a6c88be..7eff516 100644 --- a/README.md +++ b/README.md @@ -263,6 +263,57 @@ jobs: os: ${{ matrix.os }} ``` +Yarn is the default for these CLI testing workflows, so existing callers do not need new inputs. npm and pnpm callers pass package-manager setup and the commands that replaced hard-coded Yarn steps. + +```yml +jobs: + unit-tests: + uses: salesforcecli/github-workflows/.github/workflows/unitTest.yml@main + with: + package-manager: npm + cache-dependency-path: package-lock.json + install-command: npm ci + build-command: npm run build + test-command: npm test + wireit-install-command: npm install wireit@^0.14.12 + nuts: + needs: unit-tests + uses: salesforcecli/github-workflows/.github/workflows/nut.yml@main + secrets: inherit + with: + os: ubuntu-latest + package-manager: npm + cache-dependency-path: package-lock.json + install-command: npm ci + compile-command: npm run compile + oclif-manifest-command: npm run oclif -- manifest + command: npm run test:nuts + wireit-install-command: npm install wireit@^0.14.12 +``` + +```yml +jobs: + unit-tests: + uses: salesforcecli/github-workflows/.github/workflows/unitTest.yml@main + with: + package-manager: pnpm + package-manager-version: '10' + cache-dependency-path: pnpm-lock.yaml + install-command: pnpm install --frozen-lockfile + build-command: pnpm run build + test-command: pnpm test + wireit-install-command: pnpm add wireit@^0.14.12 +``` + +Shared inputs for `unitTest.yml`, `unitTestsLinux.yml`, `unitTestsWindows.yml`, `nut.yml`, `publishTypedoc.yml`, `tarballs.yml`, `packUploadMac.yml`, and `packUploadWindows.yml`: + +- `package-manager` (optional) - `npm`, `pnpm`, or `yarn` (default: `yarn`) +- `package-manager-version` (optional) - pnpm version to install when `package-manager` is `pnpm` (default: `10`) +- `cache-dependency-path` (optional) - lockfile path (default: `yarn.lock`) +- `install-command` (optional) - dependency install command (default: `yarn install --network-timeout 600000`) + +Workflow-specific command inputs keep the previous Yarn defaults (`yarn build`, `yarn test`, `yarn test:nuts`, `yarn docs`, `yarn pack:tarballs`, and the pack/upload/promote commands). Node setup, caching, and installs go through `.github/actions/setupNodeAndInstall`. + ## Other Tooling ### nut conditional on commit message diff --git a/plans/W-23613503.md b/plans/W-23613503.md deleted file mode 100644 index 29f3057..0000000 --- a/plans/W-23613503.md +++ /dev/null @@ -1,40 +0,0 @@ -# W-23613503 — Support npm, yarn, and pnpm across reusable workflows - -## Context - -Reusable workflows that currently hard-code Yarn need to accept npm, Yarn, or pnpm without duplicating setup and install logic. Use the existing `.github/actions/setupNodeAndInstall/action.yml` composite action as the single package-manager setup, cache, and dependency-install path, while preserving npm defaults for existing callers. - -Files to change: - -- `.github/workflows/unitTestsLinux.yml` -- `.github/workflows/unitTestsWindows.yml` -- `.github/workflows/nut.yml` -- `.github/workflows/publishTypedoc.yml` -- `.github/workflows/tarballs.yml` -- `.github/workflows/packUploadMac.yml` -- `.github/workflows/packUploadWindows.yml` -- `README.md` - -## Phases - -### Phase 1 — Parameterize package-manager setup and commands - -Commit message: `feat: support npm yarn and pnpm in reusable workflows` - -- Add consistent `workflow_call` inputs for package manager, package-manager version, cache dependency path, install command, and workflow-specific commands where a Yarn command is currently fixed. -- Replace workflow-local Node cache and Yarn installation steps with `.github/actions/setupNodeAndInstall/action.yml`. -- Execute caller-provided commands for build, test, documentation, packaging, upload, and promotion steps instead of fixed Yarn commands. -- Document npm, Yarn, and pnpm caller configuration and the npm-compatible defaults in `README.md`. - -## Skills to apply - -- `implement` — make the workflow and documentation changes from this plan. -- `tdd` — add or update workflow validation coverage before changing behavior where the repository has executable coverage for these files. - -## Verification - -- Install repository dependencies with the package manager declared by this repository. -- Run the repository's existing formatting, linting, type-checking, and test commands that cover workflow and action files. -- Validate every changed workflow as GitHub Actions YAML. -- Confirm each changed reusable workflow has npm-compatible defaults and routes npm, Yarn, and pnpm through `.github/actions/setupNodeAndInstall/action.yml`. -- Confirm the documented caller examples match the final input names and defaults. From 5468051b50314a6975d395cce7ee91d4082a5af8 Mon Sep 17 00:00:00 2001 From: mshanemc Date: Fri, 18 Sep 2026 17:25:12 -0500 Subject: [PATCH 3/3] revert: leave CLI publish/pack/docs workflows on Yarn --- .github/workflows/packUploadMac.yml | 53 +++-------------- .github/workflows/packUploadWindows.yml | 54 +++--------------- .github/workflows/publishTypedoc.yml | 46 ++------------- .github/workflows/tarballs.yml | 76 ++++--------------------- README.md | 4 +- 5 files changed, 32 insertions(+), 201 deletions(-) diff --git a/.github/workflows/packUploadMac.yml b/.github/workflows/packUploadMac.yml index bc82ca7..4ca5095 100644 --- a/.github/workflows/packUploadMac.yml +++ b/.github/workflows/packUploadMac.yml @@ -13,42 +13,6 @@ on: type: string default: lts/* description: node version to use for the tarball build - 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 - pack-command: - type: string - required: false - default: yarn pack:macos - description: Command used to pack the macos installer - upload-command: - type: string - required: false - default: yarn upload:macos - description: Command used to upload the macos installer - promote-command: - type: string - required: false - default: yarn channel:promote --cli sf --version "$INPUTS_VERSION" --target "$INPUTS_CHANNEL" --platform macos - description: Command used to promote the macos installer - jobs: macos: env: @@ -57,34 +21,31 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: salesforcecli/github-workflows/.github/actions/setupNodeAndInstall@main + - uses: actions/setup-node@v4 with: node-version: ${{ inputs.nodeVersion }} - package-manager: ${{ inputs.package-manager }} - package-manager-version: ${{ inputs.package-manager-version }} - cache-dependency-path: ${{ inputs.cache-dependency-path }} - install-command: ${{ inputs.install-command }} + cache: yarn + + - uses: salesforcecli/github-workflows/.github/actions/yarnInstallWithRetries@main - name: Pack for macos uses: salesforcecli/github-workflows/.github/actions/retry@main with: - command: ${{ inputs.pack-command }} + command: yarn pack:macos - name: Upload macos + run: yarn upload:macos env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - UPLOAD_COMMAND: ${{ inputs.upload-command }} - run: bash -c "$UPLOAD_COMMAND" - name: Promote macos to ${{ inputs.channel }} channel + run: yarn channel:promote --cli sf --version "$INPUTS_VERSION" --target "$INPUTS_CHANNEL" --platform macos env: INPUTS_VERSION: ${{ inputs.version }} INPUTS_CHANNEL: ${{ inputs.channel }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - PROMOTE_COMMAND: ${{ inputs.promote-command }} - run: bash -c "$PROMOTE_COMMAND" - name: Upload artifacts to Github release run: gh release upload "$INPUTS_VERSION" ./dist/macos/sf-*.pkg --clobber --repo "$GIT_REPOSITORY" diff --git a/.github/workflows/packUploadWindows.yml b/.github/workflows/packUploadWindows.yml index efa7288..5721f09 100644 --- a/.github/workflows/packUploadWindows.yml +++ b/.github/workflows/packUploadWindows.yml @@ -13,41 +13,6 @@ on: type: string default: lts/* description: node version to use for the tarball build - 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 - pack-command: - type: string - required: false - default: yarn pack:win - description: Command used to pack the Windows installer - upload-command: - type: string - required: false - default: yarn upload:win - description: Command used to upload the Windows installer - promote-command: - type: string - required: false - default: yarn channel:promote --cli sf --version "$INPUTS_VERSION" --target "$INPUTS_CHANNEL" --platform win - description: Command used to promote the Windows installer jobs: win: @@ -57,13 +22,10 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: salesforcecli/github-workflows/.github/actions/setupNodeAndInstall@main + - uses: actions/setup-node@v4 with: node-version: ${{ inputs.nodeVersion }} - package-manager: ${{ inputs.package-manager }} - package-manager-version: ${{ inputs.package-manager-version }} - cache-dependency-path: ${{ inputs.cache-dependency-path }} - install-command: ${{ inputs.install-command }} + cache: yarn - name: Set up Homebrew uses: Homebrew/actions/setup-homebrew@e05416b42376bcda221f9102c4f595f4994016be @@ -71,26 +33,24 @@ jobs: # TODO: It would be nice if we chould ditch homebrew for this install - run: brew install makensis + - uses: salesforcecli/github-workflows/.github/actions/yarnInstallWithRetries@main + - name: Pack for Windows - env: - PACK_COMMAND: ${{ inputs.pack-command }} - run: bash -c "$PACK_COMMAND" + run: yarn pack:win - name: Upload Windows + run: yarn upload:win env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - UPLOAD_COMMAND: ${{ inputs.upload-command }} - run: bash -c "$UPLOAD_COMMAND" - name: Promote win to ${{ inputs.channel }} channel + run: yarn channel:promote --cli sf --version "$INPUTS_VERSION" --target "$INPUTS_CHANNEL" --platform win env: INPUTS_VERSION: ${{ inputs.version }} INPUTS_CHANNEL: ${{ inputs.channel }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - PROMOTE_COMMAND: ${{ inputs.promote-command }} - run: bash -c "$PROMOTE_COMMAND" - name: Upload artifacts to Github release run: gh release upload "$INPUTS_VERSION" ./dist/win32/sf-*.exe --clobber --repo "$GITHUB_REPOSITORY" diff --git a/.github/workflows/publishTypedoc.yml b/.github/workflows/publishTypedoc.yml index 17d435b..e4cbe35 100644 --- a/.github/workflows/publishTypedoc.yml +++ b/.github/workflows/publishTypedoc.yml @@ -4,37 +4,6 @@ on: SVC_CLI_BOT_GITHUB_TOKEN: description: A Github PAT with repo write access. required: true - 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 - docs-command: - type: string - required: false - default: yarn docs - description: Command used to generate documentation - nodeVersion: - type: string - required: false - default: lts/* - description: Node.js version to use jobs: publish: @@ -46,13 +15,12 @@ jobs: with: token: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }} - - uses: salesforcecli/github-workflows/.github/actions/setupNodeAndInstall@main + - uses: actions/setup-node@v4 with: - node-version: ${{ inputs.nodeVersion }} - package-manager: ${{ inputs.package-manager }} - package-manager-version: ${{ inputs.package-manager-version }} - cache-dependency-path: ${{ inputs.cache-dependency-path }} - install-command: ${{ inputs.install-command }} + node-version: lts/* + cache: yarn + + - uses: salesforcecli/github-workflows/.github/actions/yarnInstallWithRetries@main - name: Get Github user info id: github-user-info @@ -66,14 +34,12 @@ jobs: email: ${{ steps.github-user-info.outputs.email }} - name: Build docs - env: - DOCS_COMMAND: ${{ inputs.docs-command }} run: | rm -rf docs git worktree prune git fetch origin gh-pages:gh-pages git worktree add docs gh-pages - bash -c "$DOCS_COMMAND" + yarn docs - name: Send to git run: | diff --git a/.github/workflows/tarballs.yml b/.github/workflows/tarballs.yml index b421dc1..8c3acde 100644 --- a/.github/workflows/tarballs.yml +++ b/.github/workflows/tarballs.yml @@ -17,51 +17,6 @@ on: type: string default: lts/* description: node version to use for the tarball build - 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 - pack-command: - type: string - required: false - default: yarn pack:tarballs - description: Command used to pack tarballs - verify-command: - type: string - required: false - default: yarn pack:verify - description: Command used to verify packed tarballs - smoke-command: - type: string - required: false - default: yarn test:smoke-unix - description: Command used to run unix smoke tests - upload-command: - type: string - required: false - default: yarn upload:tarballs - description: Command used to upload tarballs - promote-command: - type: string - required: false - default: yarn channel:promote --cli sf --version "$INPUTS_VERSION" --target "$INPUTS_CHANNEL" - description: Command used to promote uploaded tarballs jobs: tarballs: @@ -71,47 +26,36 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: salesforcecli/github-workflows/.github/actions/setupNodeAndInstall@main + - uses: actions/setup-node@v4 with: node-version: ${{ inputs.nodeVersion }} - package-manager: ${{ inputs.package-manager }} - package-manager-version: ${{ inputs.package-manager-version }} - cache-dependency-path: ${{ inputs.cache-dependency-path }} - install-command: ${{ inputs.install-command }} + cache: yarn + + - uses: salesforcecli/github-workflows/.github/actions/yarnInstallWithRetries@main - name: pack tarballs uses: salesforcecli/github-workflows/.github/actions/retry@main with: - command: ${{ inputs.pack-command }} + command: yarn pack:tarballs retry_on: error - - name: Verify tarballs - env: - VERIFY_COMMAND: ${{ inputs.verify-command }} - run: bash -c "$VERIFY_COMMAND" + - run: yarn pack:verify - - name: Smoke tests - env: - SMOKE_COMMAND: ${{ inputs.smoke-command }} - run: bash -c "$SMOKE_COMMAND" + - run: yarn test:smoke-unix - if: inputs.upload - name: Upload tarballs + run: yarn upload:tarballs env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - UPLOAD_COMMAND: ${{ inputs.upload-command }} - run: bash -c "$UPLOAD_COMMAND" - if: inputs.upload && inputs.version && inputs.channel - name: Promote tarballs + run: yarn channel:promote --cli sf --version "$INPUTS_VERSION" --target "$INPUTS_CHANNEL" env: INPUTS_VERSION: ${{ inputs.version }} INPUTS_CHANNEL: ${{ inputs.channel }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - PROMOTE_COMMAND: ${{ inputs.promote-command }} - run: bash -c "$PROMOTE_COMMAND" - if: inputs.upload run: | @@ -119,4 +63,4 @@ jobs: gh release upload "$INPUTS_VERSION" ./dist/*.xz --clobber --repo "$GITHUB_REPOSITORY" env: INPUTS_VERSION: ${{ inputs.version }} - GH_TOKEN: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }} \ No newline at end of file diff --git a/README.md b/README.md index 7eff516..f92d382 100644 --- a/README.md +++ b/README.md @@ -305,14 +305,14 @@ jobs: wireit-install-command: pnpm add wireit@^0.14.12 ``` -Shared inputs for `unitTest.yml`, `unitTestsLinux.yml`, `unitTestsWindows.yml`, `nut.yml`, `publishTypedoc.yml`, `tarballs.yml`, `packUploadMac.yml`, and `packUploadWindows.yml`: +Shared inputs for `unitTest.yml`, `unitTestsLinux.yml`, `unitTestsWindows.yml`, and `nut.yml`: - `package-manager` (optional) - `npm`, `pnpm`, or `yarn` (default: `yarn`) - `package-manager-version` (optional) - pnpm version to install when `package-manager` is `pnpm` (default: `10`) - `cache-dependency-path` (optional) - lockfile path (default: `yarn.lock`) - `install-command` (optional) - dependency install command (default: `yarn install --network-timeout 600000`) -Workflow-specific command inputs keep the previous Yarn defaults (`yarn build`, `yarn test`, `yarn test:nuts`, `yarn docs`, `yarn pack:tarballs`, and the pack/upload/promote commands). Node setup, caching, and installs go through `.github/actions/setupNodeAndInstall`. +Workflow-specific command inputs keep the previous Yarn defaults (`yarn build`, `yarn test`, `yarn test:nuts`). Node setup, caching, and installs go through `.github/actions/setupNodeAndInstall`. ## Other Tooling