From 1b5223720c0171ee234e01c64c48e1936d3cfaf4 Mon Sep 17 00:00:00 2001 From: Jason Sipula Date: Fri, 6 Feb 2026 03:46:01 +0000 Subject: [PATCH 1/3] feat: automatic node setup --- .github/actions/setup-node/action.yaml | 145 ++++++++++++++++++ .github/workflows/eslint-lint-check.yaml | 8 +- .github/workflows/markdown-lint-check.yaml | 8 +- .github/workflows/npm-publish-package.yaml | 2 +- .github/workflows/npm-semantic-release.yaml | 2 +- .github/workflows/npm-test.yaml | 2 +- .github/workflows/prettier-format-check.yaml | 8 +- .../workflows/redocly-bundle-lint-check.yaml | 8 +- .github/workflows/redocly-lint-check.yaml | 8 +- .github/workflows/spectral-lint-check.yaml | 8 +- 10 files changed, 184 insertions(+), 15 deletions(-) create mode 100644 .github/actions/setup-node/action.yaml diff --git a/.github/actions/setup-node/action.yaml b/.github/actions/setup-node/action.yaml new file mode 100644 index 0000000..df432c4 --- /dev/null +++ b/.github/actions/setup-node/action.yaml @@ -0,0 +1,145 @@ +name: Setup Node +description: > + Setup Node.js using an explicit version override, or version files (.tool-versions, .nvmrc, .node-version) if available. + Falls back to the latest LTS version if no version is specified and no version files are found. + Requires the repository to be checked out before using this action. + For more details on available inputs and outputs, see: https://github.com/actions/setup-node + +inputs: + node-version: + description: Node version specifier override (e.g., 22.17.1, 22.x, lts/*, latest). + required: false + default: "" + + fallback-node-version: + description: > + Fallback Node version specifier to use if no version is specified and no version files are found. + Defaults to latest LTS version. + required: false + default: "lts/*" + + cache: + description: > + Specify a package manager for caching in the default directory. + Supported values are 'npm', 'yarn', and 'pnpm'. + Package manager should be pre-installed. + required: false + default: "" + + cache-dependency-path: + description: > + Path to the dependency file (e.g., package-lock.json, yarn.lock, pnpm-lock.yaml) for caching. + Useful for monorepos, multi-workspaces, and non-conventional project structures. + required: false + default: "" + + package-manager-cache: + description: Controls setup-node automatic npm caching (passed through). Set to "false" to disable auto caching. + required: false + default: "true" + + check-latest: + description: > + Check for the latest Node version that satisfies the specified version range, instead of using a cached version. + It will only affect version ranges, such as "16.x", "18.x", "lts/*", etc. + Exact versions will not be affected. + required: false + default: "false" + + log-resolution: + description: Prints a brief summary of how the Node version was resolved. + required: false + default: "false" + + registry-url: + description: Optional registry URL for auth (passed through to actions/setup-node). + required: false + default: "" + + scope: + description: Optional npm scope for auth (passed through to actions/setup-node). + required: false + default: "" + +outputs: + resolved-source: + description: Where the Node version was resolved from (override, .tool-versions, .nvmrc, .node-version, fallback) + value: ${{ steps.resolve.outputs.source }} + + resolved-node-version: + description: Resolved Node version specifier that was used (override or fallback), if applicable. + value: ${{ steps.resolve.outputs.node_version }} + + resolved-node-version-file: + description: Resolved version file that was used (.tool-versions, .nvmrc, .node-version), if applicable. + value: ${{ steps.resolve.outputs.node_version_file }} + +runs: + using: "composite" + steps: + - name: Resolve Node version source + id: resolve + shell: bash + run: | + set -euo pipefail + + if [[ -n "${{ inputs.node-version }}" ]]; then + echo "source=override" >> "$GITHUB_OUTPUT" + echo "node_version=${{ inputs.node-version }}" >> "$GITHUB_OUTPUT" + echo "node_version_file=" >> "$GITHUB_OUTPUT" + + elif [[ -f ".tool-versions" ]]; then + echo "source=.tool-versions" >> "$GITHUB_OUTPUT" + echo "node_version=" >> "$GITHUB_OUTPUT" + echo "node_version_file=.tool-versions" >> "$GITHUB_OUTPUT" + + elif [[ -f ".nvmrc" ]]; then + echo "source=.nvmrc" >> "$GITHUB_OUTPUT" + echo "node_version=" >> "$GITHUB_OUTPUT" + echo "node_version_file=.nvmrc" >> "$GITHUB_OUTPUT" + + elif [[ -f ".node-version" ]]; then + echo "source=.node-version" >> "$GITHUB_OUTPUT" + echo "node_version=" >> "$GITHUB_OUTPUT" + echo "node_version_file=.node-version" >> "$GITHUB_OUTPUT" + + else + echo "source=fallback" >> "$GITHUB_OUTPUT" + echo "node_version=${{ inputs.fallback-node-version }}" >> "$GITHUB_OUTPUT" + echo "node_version_file=" >> "$GITHUB_OUTPUT" + fi + + - name: Node resolution summary + if: ${{ inputs.log-resolution == 'true' }} + shell: bash + run: | + echo "Node resolution source: ${{ steps.resolve.outputs.source }}" + if [[ -n "${{ steps.resolve.outputs.node_version_file }}" ]]; then + echo "Node version file: ${{ steps.resolve.outputs.node_version_file }}" + else + echo "Node version: ${{ steps.resolve.outputs.node_version }}" + fi + + - name: Setup Node (from version file) + if: ${{ steps.resolve.outputs.node_version_file != '' }} + uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6 + with: + node-version-file: ${{ steps.resolve.outputs.node_version_file }} + cache: ${{ inputs.cache }} + cache-dependency-path: ${{ inputs.cache-dependency-path }} + package-manager-cache: ${{ inputs.package-manager-cache }} + check-latest: ${{ inputs.check-latest }} + registry-url: ${{ inputs.registry-url }} + scope: ${{ inputs.scope }} + + - name: Setup Node (from specified version) + if: ${{ steps.resolve.outputs.node_version_file == '' }} + uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6 + with: + node-version: ${{ steps.resolve.outputs.node_version }} + cache: ${{ inputs.cache }} + cache-dependency-path: ${{ inputs.cache-dependency-path }} + package-manager-cache: ${{ inputs.package-manager-cache }} + check-latest: ${{ inputs.check-latest }} + registry-url: ${{ inputs.registry-url }} + scope: ${{ inputs.scope }} diff --git a/.github/workflows/eslint-lint-check.yaml b/.github/workflows/eslint-lint-check.yaml index f102770..2de3fee 100644 --- a/.github/workflows/eslint-lint-check.yaml +++ b/.github/workflows/eslint-lint-check.yaml @@ -3,6 +3,10 @@ name: ESlint Lint Check on: workflow_call: inputs: + node-version: + required: false + type: string + default: "" eslint-version: required: false type: string @@ -29,9 +33,9 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - name: Setup Node.js - uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6 + uses: ./.github/actions/setup-node@main with: - node-version: latest + node-version: ${{ inputs.node-version }} cache: ${{ inputs.cache-dependency-manager }} - name: Install Dependencies diff --git a/.github/workflows/markdown-lint-check.yaml b/.github/workflows/markdown-lint-check.yaml index 320fae7..2865ae7 100644 --- a/.github/workflows/markdown-lint-check.yaml +++ b/.github/workflows/markdown-lint-check.yaml @@ -3,6 +3,10 @@ name: Markdown Lint Check on: workflow_call: inputs: + node-version: + required: false + type: string + default: "" markdownlint-version: required: false type: string @@ -25,9 +29,9 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - name: Setup Node.js - uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6 + uses: ./.github/actions/setup-node@main with: - node-version: latest + node-version: ${{ inputs.node-version }} cache: ${{ inputs.cache-dependency-manager }} - name: Lint Check diff --git a/.github/workflows/npm-publish-package.yaml b/.github/workflows/npm-publish-package.yaml index e5cf5ec..6604aad 100644 --- a/.github/workflows/npm-publish-package.yaml +++ b/.github/workflows/npm-publish-package.yaml @@ -42,7 +42,7 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - name: Setup Node.js - uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6 + uses: ./.github/actions/setup-node@main with: node-version: ${{ inputs.node-version }} cache: ${{ inputs.cache-dependency-manager }} diff --git a/.github/workflows/npm-semantic-release.yaml b/.github/workflows/npm-semantic-release.yaml index 6ef562f..ca09aed 100644 --- a/.github/workflows/npm-semantic-release.yaml +++ b/.github/workflows/npm-semantic-release.yaml @@ -43,7 +43,7 @@ jobs: fetch-depth: 0 - name: Setup Node.js - uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6 + uses: ./.github/actions/setup-node@main with: node-version: ${{ inputs.node-version }} cache: ${{ inputs.cache-dependency-manager }} diff --git a/.github/workflows/npm-test.yaml b/.github/workflows/npm-test.yaml index f74af31..9780adc 100644 --- a/.github/workflows/npm-test.yaml +++ b/.github/workflows/npm-test.yaml @@ -32,7 +32,7 @@ jobs: - name: Checkout Source uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - - name: Set up Node.js + - name: Setup Node.js uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6 with: node-version: ${{ inputs.node-version }} diff --git a/.github/workflows/prettier-format-check.yaml b/.github/workflows/prettier-format-check.yaml index d8ab4aa..ba8d672 100644 --- a/.github/workflows/prettier-format-check.yaml +++ b/.github/workflows/prettier-format-check.yaml @@ -3,6 +3,10 @@ name: Prettier Format Check on: workflow_call: inputs: + node-version: + required: false + type: string + default: "" prettier-version: required: false type: string @@ -29,9 +33,9 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - name: Setup Node.js - uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6 + uses: ./.github/actions/setup-node@main with: - node-version: latest + node-version: ${{ inputs.node-version }} cache: ${{ inputs.cache-dependency-manager }} - name: Check Formatting diff --git a/.github/workflows/redocly-bundle-lint-check.yaml b/.github/workflows/redocly-bundle-lint-check.yaml index 95a56e5..97793cf 100644 --- a/.github/workflows/redocly-bundle-lint-check.yaml +++ b/.github/workflows/redocly-bundle-lint-check.yaml @@ -3,6 +3,10 @@ name: Redocly Bundle Lint Check on: workflow_call: inputs: + node-version: + required: false + type: string + default: "" redocly-version: required: false type: string @@ -29,9 +33,9 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - name: Setup Node.js - uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6 + uses: ./.github/actions/setup-node@main with: - node-version: latest + node-version: ${{ inputs.node-version }} cache: ${{ inputs.cache-dependency-manager }} - name: Bundle APIs diff --git a/.github/workflows/redocly-lint-check.yaml b/.github/workflows/redocly-lint-check.yaml index e75ce3a..e0cae8e 100644 --- a/.github/workflows/redocly-lint-check.yaml +++ b/.github/workflows/redocly-lint-check.yaml @@ -3,6 +3,10 @@ name: Redocly Lint Check on: workflow_call: inputs: + node-version: + required: false + type: string + default: "" redocly-version: required: false type: string @@ -29,9 +33,9 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - name: Setup Node.js - uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6 + uses: ./.github/actions/setup-node@main with: - node-version: latest + node-version: ${{ inputs.node-version }} cache: ${{ inputs.cache-dependency-manager }} - name: Lint Check diff --git a/.github/workflows/spectral-lint-check.yaml b/.github/workflows/spectral-lint-check.yaml index cb970e3..aa21970 100644 --- a/.github/workflows/spectral-lint-check.yaml +++ b/.github/workflows/spectral-lint-check.yaml @@ -3,6 +3,10 @@ name: Spectral Lint Check on: workflow_call: inputs: + node-version: + required: false + type: string + default: "" spectral-version: required: false type: string @@ -29,9 +33,9 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - name: Setup Node.js - uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6 + uses: ./.github/actions/setup-node@main with: - node-version: latest + node-version: ${{ inputs.node-version }} cache: ${{ inputs.cache-dependency-manager }} - name: Lint Check From 7a2fea50de3b2e613e71685e4d649413b7825715 Mon Sep 17 00:00:00 2001 From: Jason Sipula Date: Fri, 6 Feb 2026 03:51:09 +0000 Subject: [PATCH 2/3] fix: defer to underlying action defaults when consumer don't pass in value --- .github/workflows/npm-publish-package.yaml | 2 +- .github/workflows/npm-semantic-release.yaml | 2 +- .github/workflows/npm-test.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/npm-publish-package.yaml b/.github/workflows/npm-publish-package.yaml index 6604aad..784c310 100644 --- a/.github/workflows/npm-publish-package.yaml +++ b/.github/workflows/npm-publish-package.yaml @@ -6,7 +6,7 @@ on: node-version: required: false type: string - default: "latest" + default: "" cache-dependency-manager: required: false type: string diff --git a/.github/workflows/npm-semantic-release.yaml b/.github/workflows/npm-semantic-release.yaml index ca09aed..06cc967 100644 --- a/.github/workflows/npm-semantic-release.yaml +++ b/.github/workflows/npm-semantic-release.yaml @@ -6,7 +6,7 @@ on: node-version: required: false type: string - default: "latest" + default: "" cache-dependency-manager: required: false type: string diff --git a/.github/workflows/npm-test.yaml b/.github/workflows/npm-test.yaml index 9780adc..e748454 100644 --- a/.github/workflows/npm-test.yaml +++ b/.github/workflows/npm-test.yaml @@ -6,7 +6,7 @@ on: node-version: required: false type: string - default: "latest" + default: "" cache-dependency-manager: required: false type: string From efd5df6597fba821f50ecbcabb289d6f19d8724f Mon Sep 17 00:00:00 2001 From: Jason Sipula Date: Fri, 6 Feb 2026 03:52:09 +0000 Subject: [PATCH 3/3] chore: enable debug logging for testing --- .github/workflows/prettier-format-check.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/prettier-format-check.yaml b/.github/workflows/prettier-format-check.yaml index ba8d672..3fc1ddd 100644 --- a/.github/workflows/prettier-format-check.yaml +++ b/.github/workflows/prettier-format-check.yaml @@ -37,6 +37,7 @@ jobs: with: node-version: ${{ inputs.node-version }} cache: ${{ inputs.cache-dependency-manager }} + log-resolution: true - name: Check Formatting run: npx prettier@${{ inputs.prettier-version }} --check ${{ inputs.check-path }}