name: Setup Node and pnpm description: Set up Node.js, activate pnpm via Corepack, and optionally install dependencies. inputs: node-version: description: Node.js version to install. required: false default: "26" pnpm-version: description: pnpm version to activate via Corepack. required: false default: "11" install: description: Whether to run pnpm install. required: false default: "true" cache: description: Whether to enable pnpm dependency caching. required: false default: "true" cache-dependency-path: description: Path(s) used to generate the cache key. required: false default: "pnpm-lock.yaml" prefetch: description: Whether to run pnpm fetch before installation. required: false default: "false" runs: using: composite steps: - name: Set up Node.js uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version: ${{ inputs.node-version }} - name: Enable Corepack and activate pnpm shell: bash run: | corepack enable corepack prepare "pnpm@${{ inputs.pnpm-version }}" --activate # pnpm must be on PATH before its store path can be resolved for cache keying, # so caching is configured in a separate step after Corepack activates pnpm. - name: Get pnpm store directory if: ${{ inputs.cache == 'true' }} id: pnpm-store shell: bash run: echo "path=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT" - name: Cache pnpm store if: ${{ inputs.cache == 'true' }} uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: ${{ steps.pnpm-store.outputs.path }} key: ${{ runner.os }}-pnpm-${{ inputs.pnpm-version }}-store-${{ hashFiles(inputs.cache-dependency-path) }} restore-keys: | ${{ runner.os }}-pnpm-${{ inputs.pnpm-version }}-store- - name: Prefetch dependencies if: ${{ inputs.prefetch == 'true' }} shell: bash run: pnpm fetch --frozen-lockfile # onnxruntime-node's postinstall otherwise downloads its CUDA provider on Linux x64. Nothing in CI # uses it, and the CPU binding the read-aloud worker tests load ships in the npm package itself. - name: Install dependencies if: ${{ inputs.install == 'true' }} shell: bash env: ONNXRUNTIME_NODE_INSTALL: skip run: pnpm install --frozen-lockfile