diff options
author | Darshan Sen <raisinten@gmail.com> | 2022-04-13 20:22:00 +0300 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2022-07-31 10:43:45 +0300 |
commit | fc55a6798f883f39c743862bab3a52dc74cfaf1f (patch) | |
tree | 3e78c9f28477bb46867d55854737e640bffce027 /.github | |
parent | 654e71c29c389a0f160d4c38e9198f4abbbfae28 (diff) |
build: run clang-format on CI
We already include the tool inside tools/clang-format, so we should
start using it on CI. This attempts to run the linter only on the
commits present in an opened PR.
Signed-off-by: Darshan Sen <raisinten@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/42681
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to '.github')
-rw-r--r-- | .github/workflows/linters.yml | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index e5eff5ee447..312ba0b3c97 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -49,6 +49,40 @@ jobs: 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 + CLANG_FORMAT_START="$(git merge-base HEAD refs/remotes/origin/$GITHUB_BASE_REF)" \ + make format-cpp + 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 <target-branch-name>)" 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 |