Repository navigation
tools: fall back to a larger runner on cache miss #98282
Workflow file for this run
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
| name: Linters | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened, ready_for_review] | |
| push: | |
| branches: | |
| - main | |
| - v[0-9]+.x-staging | |
| - v[0-9]+.x | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| env: | |
| PYTHON_VERSION: '3.15' | |
| NODE_VERSION: lts/* | |
| permissions: | |
| contents: read | |
| jobs: | |
| lint-addon-docs: | |
| if: github.event.pull_request.draft == false | |
| runs-on: ubuntu-slim | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| sparse-checkout: | | |
| /* | |
| !/deps/ | |
| sparse-checkout-cone-mode: false | |
| - name: Use Node.js ${{ env.NODE_VERSION }} | |
| uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: Lint addon docs | |
| run: NODE=$(command -v node) make lint-addon-docs | |
| lint-cpp: | |
| if: github.event.pull_request.draft == false | |
| runs-on: ubuntu-slim | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| # Skip large vendored trees that lint-cpp does not use. | |
| sparse-checkout: | | |
| /* | |
| !/deps/openssl/ | |
| !/deps/v8/ | |
| sparse-checkout-cone-mode: false | |
| - name: Set up Python ${{ env.PYTHON_VERSION }} | |
| uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| allow-prereleases: true | |
| - name: Lint C/C++ files | |
| run: make lint-cpp | |
| format-cpp: | |
| if: ${{ github.event.pull_request && github.event.pull_request.draft == false && github.base_ref == github.event.repository.default_branch }} | |
| runs-on: ubuntu-slim | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| # The first parent of the PR merge commit is the base branch commit. | |
| fetch-depth: 2 | |
| persist-credentials: false | |
| - name: Use Node.js ${{ env.NODE_VERSION }} | |
| uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: Set up Python ${{ env.PYTHON_VERSION }} | |
| uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| allow-prereleases: true | |
| - name: Format C/C++ files | |
| run: | | |
| make format-cpp-build | |
| # The `make format-cpp` error code is intentionally ignored here | |
| # because it is irrelevant. We already check if the formatter produced | |
| # a diff in the next line. | |
| # Refs: https://github.com/nodejs/node/pull/42764 | |
| CLANG_FORMAT_START=HEAD^ \ | |
| make format-cpp || true | |
| git --no-pager diff --exit-code && EXIT_CODE="$?" || EXIT_CODE="$?" | |
| if [ "$EXIT_CODE" != "0" ] | |
| then | |
| echo | |
| echo 'ERROR: Please run:' | |
| echo | |
| echo " CLANG_FORMAT_START="$\(git merge-base HEAD ${GITHUB_BASE_REF}\)" make format-cpp" | |
| echo | |
| echo 'to format the commits in your branch.' | |
| exit "$EXIT_CODE" | |
| fi | |
| lint-js-and-md-slim: | |
| if: github.event.pull_request.draft == false | |
| runs-on: ubuntu-slim | |
| outputs: | |
| cache-restored: ${{ steps.lint.outputs.cache-restored }} | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - uses: ./.github/actions/lint-js-and-md | |
| id: lint | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| lint-js-and-md-fallback: | |
| needs: lint-js-and-md-slim | |
| if: needs.lint-js-and-md-slim.outputs.cache-restored == 'false' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - uses: ./.github/actions/lint-js-and-md | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| run-on-cache-miss: 'true' | |
| lint-js-and-md: | |
| needs: [lint-js-and-md-slim, lint-js-and-md-fallback] | |
| if: ${{ always() && github.event.pull_request.draft == false }} | |
| runs-on: ubuntu-slim | |
| steps: | |
| - name: Check lint results | |
| env: | |
| SLIM_RESULT: ${{ needs.lint-js-and-md-slim.result }} | |
| CACHE_RESTORED: ${{ needs.lint-js-and-md-slim.outputs.cache-restored }} | |
| FALLBACK_RESULT: ${{ needs.lint-js-and-md-fallback.result }} | |
| run: | | |
| test "$SLIM_RESULT" = success | |
| if [ "$CACHE_RESTORED" = true ]; then | |
| test "$FALLBACK_RESULT" = skipped | |
| else | |
| test "$CACHE_RESTORED" = false | |
| test "$FALLBACK_RESULT" = success | |
| fi | |
| lint-py: | |
| if: github.event.pull_request.draft == false | |
| runs-on: ubuntu-slim | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| sparse-checkout: | | |
| /Makefile | |
| /benchmark/ | |
| /doc/ | |
| /lib/ | |
| /src/node_version.h | |
| /tools/ | |
| pyproject.toml | |
| *.py | |
| sparse-checkout-cone-mode: false | |
| - name: Set up Python ${{ env.PYTHON_VERSION }} | |
| uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| allow-prereleases: true | |
| - name: Lint Python | |
| run: | | |
| make lint-py-build | |
| make lint-py | |
| lint-yaml: | |
| if: github.event.pull_request.draft == false | |
| runs-on: ubuntu-slim | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| sparse-checkout: | | |
| /Makefile | |
| /tools/pip/ | |
| *.yml | |
| *.yaml | |
| sparse-checkout-cone-mode: false | |
| - name: Use Python ${{ env.PYTHON_VERSION }} | |
| uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| allow-prereleases: true | |
| - name: Lint YAML | |
| run: | | |
| make lint-yaml-build || true | |
| make lint-yaml | |
| lint-sh: | |
| if: github.event.pull_request.draft == false | |
| runs-on: ubuntu-slim | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| sparse-checkout: | | |
| /tools/lint-sh.mjs | |
| *.sh | |
| sparse-checkout-cone-mode: false | |
| - run: shellcheck -V | |
| - name: Lint Shell scripts | |
| run: tools/lint-sh.mjs . | |
| lint-codeowners: | |
| if: github.event.pull_request.draft == false | |
| # cannot use ubuntu-slim here because mszostok/codeowners-validator is dockerized | |
| # cannot use ubuntu-24.04-arm here because the docker image is x86 only | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - uses: mszostok/codeowners-validator@7f3f5e28c6d7b8dfae5731e54ce2272ca384592f | |
| with: | |
| checks: files,duppatterns | |
| lint-pr-url: | |
| if: ${{ github.event.pull_request }} | |
| runs-on: ubuntu-slim | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| fetch-depth: 2 | |
| persist-credentials: false | |
| sparse-checkout: | | |
| /tools/lint-pr-url.mjs | |
| /doc/api/ | |
| sparse-checkout-cone-mode: false | |
| # We've checked out a merge commit, HEAD^ refers to the base branch. | |
| - run: git diff HEAD^ HEAD -G"pr-url:" -- "*.md" | ./tools/lint-pr-url.mjs "$PR_URL" | |
| env: | |
| PR_URL: ${{ github.event.pull_request.html_url }} | |
| lint-readme: | |
| runs-on: ubuntu-slim | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| sparse-checkout: | | |
| README.md | |
| /tools/lint-readme-lists.mjs | |
| sparse-checkout-cone-mode: false | |
| - name: Get team members if possible | |
| if: ${{ (github.event.pull_request && github.event.pull_request.base.ref == github.event.pull_request.base.repo.default_branch) || github.event.ref == github.event.repository.default_branch }} | |
| id: team_members | |
| run: | | |
| get_list_members() { | |
| TEAM="$1" | |
| QUOTE='"' | |
| gh api "/orgs/nodejs/teams/$TEAM/members" -X GET -f per_page=100 --jq "map(.login) | ${QUOTE}${TEAM}=\(tojson)${QUOTE}" | |
| } | |
| [ -z "$GITHUB_TOKEN" ] || ( | |
| get_list_members "collaborators" | |
| get_list_members "issue-triage" | |
| get_list_members "tsc" | |
| ) >> "$GITHUB_OUTPUT" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GH_USER_TOKEN }} | |
| - run: tools/lint-readme-lists.mjs "$TEAMS" | |
| env: | |
| TEAMS: ${{ tojson(steps.team_members.outputs) }} |