mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
According to the logs in https://github.com/nodejs/node/pull/42681#issuecomment-1100856089, `make format-cpp` exits with an NZEC. This change intentionally ignores the error code because it is irrelevant. We already check if the formatter produced a diff in the next line. Refs: https://github.com/nodejs/node/pull/42681#issuecomment-1100856089 Signed-off-by: Darshan Sen <raisinten@gmail.com> PR-URL: https://github.com/nodejs/node/pull/42764 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Mestery <mestery@protonmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
180 lines
5.7 KiB
YAML
180 lines
5.7 KiB
YAML
name: Linters
|
|
|
|
on:
|
|
pull_request:
|
|
types: [opened, synchronize, reopened, ready_for_review]
|
|
push:
|
|
branches:
|
|
- master
|
|
- 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.10'
|
|
NODE_VERSION: lts/*
|
|
|
|
jobs:
|
|
lint-addon-docs:
|
|
if: github.event.pull_request.draft == false
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
persist-credentials: false
|
|
- name: Use Node.js ${{ env.NODE_VERSION }}
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
- name: Environment Information
|
|
run: npx envinfo
|
|
- 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-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
persist-credentials: false
|
|
- name: Set up Python ${{ env.PYTHON_VERSION }}
|
|
uses: actions/setup-python@v3
|
|
with:
|
|
python-version: ${{ env.PYTHON_VERSION }}
|
|
- name: Environment Information
|
|
run: npx envinfo
|
|
- name: Lint C/C++ files
|
|
run: make lint-cpp
|
|
format-cpp:
|
|
if: ${{ github.event.pull_request.draft == false && github.base_ref == 'master' }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
persist-credentials: false
|
|
- name: Use Node.js ${{ env.NODE_VERSION }}
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
- name: Set up Python ${{ env.PYTHON_VERSION }}
|
|
uses: actions/setup-python@v3
|
|
with:
|
|
python-version: ${{ env.PYTHON_VERSION }}
|
|
- name: Environment Information
|
|
run: npx envinfo
|
|
- 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="$(git merge-base HEAD refs/remotes/origin/$GITHUB_BASE_REF)" \
|
|
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:
|
|
if: github.event.pull_request.draft == false
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
persist-credentials: false
|
|
- name: Use Node.js ${{ env.NODE_VERSION }}
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
- name: Environment Information
|
|
run: npx envinfo
|
|
- name: Lint JavaScript files
|
|
run: NODE=$(command -v node) make lint-js
|
|
- name: Get release version numbers
|
|
if: ${{ github.event.pull_request && github.event.pull_request.base.ref == github.event.pull_request.base.repo.default_branch }}
|
|
id: get-released-versions
|
|
run: ./tools/lint-md/list-released-versions-from-changelogs.mjs
|
|
- name: Lint markdown files
|
|
run: |
|
|
echo "::add-matcher::.github/workflows/remark-lint-problem-matcher.json"
|
|
NODE=$(command -v node) make lint-md
|
|
env:
|
|
NODE_RELEASED_VERSIONS: ${{ steps.get-released-versions.outputs.NODE_RELEASED_VERSIONS }}
|
|
lint-py:
|
|
if: github.event.pull_request.draft == false
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
persist-credentials: false
|
|
- name: Set up Python ${{ env.PYTHON_VERSION }}
|
|
uses: actions/setup-python@v3
|
|
with:
|
|
python-version: ${{ env.PYTHON_VERSION }}
|
|
- name: Environment Information
|
|
run: npx envinfo
|
|
- name: Lint Python
|
|
run: |
|
|
make lint-py-build || true
|
|
make lint-py
|
|
lint-yaml:
|
|
if: github.event.pull_request.draft == false
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
persist-credentials: false
|
|
- name: Use Python ${{ env.PYTHON_VERSION }}
|
|
uses: actions/setup-python@v3
|
|
with:
|
|
python-version: ${{ env.PYTHON_VERSION }}
|
|
- name: Environment Information
|
|
run: npx envinfo
|
|
- name: Lint YAML
|
|
run: |
|
|
make lint-yaml-build || true
|
|
make lint-yaml
|
|
|
|
lint-sh:
|
|
if: github.event.pull_request.draft == false
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
persist-credentials: false
|
|
- run: shellcheck -V
|
|
- name: Lint Shell scripts
|
|
run: tools/lint-sh.js .
|
|
lint-codeowners:
|
|
if: github.event.pull_request.draft == false
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
persist-credentials: false
|
|
- uses: mszostok/codeowners-validator@v0.6.0
|
|
with:
|
|
checks: files,duppatterns
|
|
lint-pr-url:
|
|
if: ${{ github.event.pull_request }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 2
|
|
persist-credentials: false
|
|
# GH Actions squashes all PR commits, HEAD^ refers to the base branch.
|
|
- run: git diff HEAD^ HEAD -G"pr-url:" -- "*.md" | ./tools/lint-pr-url.mjs ${{ github.event.pull_request.html_url }}
|