cpp-linter / cpp-linter-action

A Github Action for linting C/C++ code integrating clang-tidy and clang-format to collect feedback provided in the form of file-annotations, thread-comments, workflow step-summary, and Pull Request reviews.

Home Page:https://cpp-linter.github.io/cpp-linter-action/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why all checks have passed?

pypygeek opened this issue · comments

hello,

Why all checks have passed?

I want to raise an error if the ansi rule is not met.

name: C Code Convention CI

on: [push]

jobs:
  cpp-linter:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: cpp-linter/cpp-linter-action@v2
        id: linter
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          style: file
          extensions: c,C,h,H
          extra-args: -Wall -Wextra -ansi -c

      - name: Fail fast?!
        if: steps.linter.outputs.checks-failed > 0
        run: echo "Some files failed the linting checks!"

image
Create a.c

You need to change the "Fail fast?!" step in your workflow.

       - name: Fail fast?!
         if: steps.linter.outputs.checks-failed > 0
-        run: echo "Some files failed the linting checks!"
+        run: exit 1

I want to raise an error if the ansi rule is not met.

If you only want to raise an error for a specific rule (and not for other rules), then this might be done in your workflow by running cpp-linter twice -- once for rules that don't raise an error, and once for the ANSI rule(s) that should raise an error. This can be done as 2 separate jobs in the same workflow.

But this is not a problem with the cpp-linter-action because there is no support in clang-tidy to give a higher "rank" to certain rules and a lower "rank" to others.

You need to change the "Fail fast?!" step in your workflow.

       - name: Fail fast?!
         if: steps.linter.outputs.checks-failed > 0
-        run: echo "Some files failed the linting checks!"
+        run: exit 1

Thank you for your valuable time.

Close the issue by solving the problem.