Skip to content

chore: Support npm, yarn, and pnpm across reusable workflows - W-23613503 - #185

Merged
mshanemc merged 3 commits into
mainfrom
sm/W-23613503
Sep 28, 2026
Merged

mshanemc merged 3 commits into
mainfrom
sm/W-23613503

Conversation

@mshanemc

@mshanemc mshanemc commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

What issues does this PR fix or reference?

@W-23613503@

What changed and why?

  • Parameterized unit-test and NUT reusable workflows so callers can use npm, Yarn, or pnpm.
  • Routed Node setup, caching, and installs through .github/actions/setupNodeAndInstall/action.yml.
  • Replaced hard-coded Yarn build/test/compile/manifest steps with caller-provided commands.
  • Kept Yarn defaults so existing callers keep working without new inputs.
  • Documented npm and pnpm caller examples in README.md.

CLI publish/pack/docs workflows (tarballs, packUpload*, publishTypedoc) are unchanged.

@mshanemc
mshanemc marked this pull request as ready for review September 18, 2026 03:51
@mshanemc
mshanemc requested a review from a team as a code owner September 18, 2026 03:51
wireit-install-command:
type: string
required: false
default: yarn add wireit@^0.14.12

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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.yml still always installs with Yarn. setupNodeAndInstall only rewrites an install command when it is exactly npm ci, so a Yarn default does not get rewritten when package-manager is npm or pnpm.

The reviewed default: yarn / default: yarn install --network-timeout 600000 inputs are on PR head 5468051, not in this checkout. This worktree is cd2eafc. Here the workflow has no install-command input and hardcodes Yarn:

      - uses: actions/setup-node@v4
        with:
          node-version: ${{ matrix.node_version }}
          cache: yarn
      # ...
          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' }}
      # ...
        run: yarn add wireit@^0.14.12

      - run: yarn build
      # ...
          command: yarn test

Current callers pass no package-manager inputs. A workflow default of npm ci would change those runs. The Yarn default keeps that behavior.

The substitution claim matches the composite action in this tree. Its own defaults are npm and npm ci, and the rewrite runs only for that exact command:

    description: 'Package manager to use: npm, pnpm, or yarn.'
    required: false
    default: npm
  # ...
  install-command:
    description: 'Command used to install repository dependencies.'
    required: false
    default: npm ci
        if [ "$INSTALL_COMMAND" = "npm ci" ]; then
          case "$PACKAGE_MANAGER" in
            pnpm) INSTALL_COMMAND="pnpm install --frozen-lockfile" ;;
            yarn) INSTALL_COMMAND="yarn install --network-timeout 600000" ;;
          esac
        fi

There is no reverse case. yarn install --network-timeout 600000 is passed through. Setting package-manager to npm or pnpm and leaving install-command at the workflow default still runs Yarn.

Copy link
Copy Markdown
Contributor

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:

    - name: Validate package manager
      shell: bash
      env:
        PACKAGE_MANAGER: ${{ inputs.package-manager }}
      run: |
        if [ "$PACKAGE_MANAGER" != "npm" ] && [ "$PACKAGE_MANAGER" != "pnpm" ] && [ "$PACKAGE_MANAGER" != "yarn" ]; then
          echo "::error::Unsupported package manager: $PACKAGE_MANAGER. Expected npm, pnpm, or yarn."
          exit 1
        fi

    - name: Validate cache-dependency-path and install-command match package-manager
      shell: bash
      env:
        PACKAGE_MANAGER: ${{ inputs.package-manager }}
        CACHE_DEPENDENCY_PATH: ${{ inputs.cache-dependency-path }}
        INSTALL_COMMAND: ${{ inputs.install-command }}
      run: |
        case "$PACKAGE_MANAGER" in
          npm)  expected_lockfile="package-lock.json"; expected_bin="npm" ;;
          yarn) expected_lockfile="yarn.lock";          expected_bin="yarn" ;;
          pnpm) expected_lockfile="pnpm-lock.yaml";     expected_bin="pnpm" ;;
        esac

        actual_lockfile=$(basename "$CACHE_DEPENDENCY_PATH")
        if [ "$actual_lockfile" != "$expected_lockfile" ]; then
          echo "::error::package-manager is '$PACKAGE_MANAGER' but cache-dependency-path points at '$CACHE_DEPENDENCY_PATH' (expected a '$expected_lockfile' file). Pass a matching cache-dependency-path for '$PACKAGE_MANAGER'."
          exit 1
        fi

        install_bin=$(echo "$INSTALL_COMMAND" | awk '{print $1}')
        if [ "$install_bin" != "$expected_bin" ]; then
          echo "::error::package-manager is '$PACKAGE_MANAGER' but install-command '$INSTALL_COMMAND' runs '$install_bin'. Pass an install-command that starts with '$expected_bin' (or leave it unset to use the default)."
          exit 1
        fi

@mshanemc
mshanemc merged commit 48329dd into main Sep 28, 2026
3 checks passed
nvuillam added a commit to hardisgroupcom/sfdx-hardis that referenced this pull request Sep 29, 2026
salesforcecli/github-workflows#185 made nut.yml run its compile and manifest
steps through `bash -c` without `shell: bash`. On Windows runners that
does nothing, so lib/ is never built and every Windows nut fails with
"command hello:world not found", on every branch since 2026-09-28.

Pin nut.yml to the commit before that change until upstream fixes it.
nvuillam added a commit to hardisgroupcom/sfdx-hardis that referenced this pull request Sep 29, 2026
* docs: add a user guide for each VS Code extension workbench

One page per workbench under the VS Code Extension menu (Welcome, DevOps
Pipeline, Org Monitoring, command execution, Orgs Manager, Metadata
Retriever, Metadata Dependencies, Data and Files workbenches, Customize),
each with its GIF, numbered-pill screenshots and its customization options.

The pill tooling is ported from the training course: annotate-doc-images.mjs
draws the pills from docs/assets/annotations.json, check-doc-pills.mjs proves
the pages cite exactly the pills their screenshots carry, and a CI job runs
both on every Pull Request.

* docs: harden the pill checks and fix the VS Code guides after review

- annotate-doc-images.mjs: stamps also hash the drawing code and the image
  written, so a hand-edited image or a new pill style is stale; stamps are
  saved after each image and the browser is always closed; pills past 10 are
  refused; the main-module guard resolves symlinks.
- check-doc-pills.mjs: JPEG, WebP and <img> screenshots are checked too, and
  fenced code blocks are ignored.
- pill-refs.js only paints (1) to (10), the colours the palette has.
- Orgs Manager guide shows the open row menu; Welcome pill (8) covers every
  card group; the overview no longer promises a ? button on every panel.

* reorder menu

* docs: feature branches are shown by default in the DevOps Pipeline

* ci: pin the nuts reusable workflow before its Windows regression

salesforcecli/github-workflows#185 made nut.yml run its compile and manifest
steps through `bash -c` without `shell: bash`. On Windows runners that
does nothing, so lib/ is never built and every Windows nut fails with
"command hello:world not found", on every branch since 2026-09-28.

Pin nut.yml to the commit before that change until upstream fixes it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants