diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index a8248425..fb8f44b3 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -10,7 +10,7 @@ jobs: update_release_draft: runs-on: ubuntu-latest steps: - # Drafts your next Release notes as Pull Requests are merged into the default branch - - uses: release-drafter/release-drafter@v5 + # Draft your next Release notes as Pull Requests are merged into the default branch + - uses: release-drafter/release-drafter@v6 env: - GITHUB_TOKEN: ${{ secrets.CPP_LINTER_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 62388954..67cbe80d 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,12 @@ Refer [here](https://github.com/cpp-linter/cpp-linter-action/tree/v1) for previo ## Usage +> [!NOTE] +> Python 3.10 needs to be installed in the docker image if your workflow is +> [running jobs in a container](https://docs.github.com/en/actions/using-jobs/running-jobs-in-a-container) +> (see discussion in [#185](https://github.com/cpp-linter/cpp-linter-action/issues/185)). +> Our intention is to synchronize with the default python version included with Ubuntu latest LTS releases. + Create a new GitHub Actions workflow in your project, e.g. at [.github/workflows/cpp-linter.yml](https://github.com/cpp-linter/cpp-linter-action/blob/main/.github/workflows/cpp-linter.yml) The content of the file should be in the following format. @@ -98,8 +104,9 @@ jobs: #### `verbosity` -- **Description**: This controls the action's verbosity in the workflow's logs. Supported options are defined by the [python logging library's log levels](https://docs.python.org/3/library/logging.html#logging-levels). This option does not affect the verbosity of resulting thread comments or file annotations. -- Default: '10' +- **Description**: This controls the action's verbosity in the workflow's logs. Supported options are `info` or `debug`. This option does not affect the verbosity of resulting thread comments or file annotations. + - The verbosity can also be engaged by enabling debug logs when [re-running jobs or workflows](https://docs.github.com/en/actions/managing-workflow-runs/re-running-workflows-and-jobs). +- Default: 'info' #### `lines-changed-only` @@ -168,6 +175,24 @@ jobs: - **Description**: A string of extra arguments passed to clang-tidy for use as compiler arguments (like `-std=c++14 -Wall`). - Default: '' +#### `tidy-review` + +**Beta feature** 🚧 + +- **Description**: Set this option to true to enable pull request reviews from clang-tidy. + - To use Pull Request reviews, the `GITHUB_TOKEN` (provided by Github to each repository) must be declared as an environment + variable. See [Authenticating with the GITHUB_TOKEN](https://docs.github.com/en/actions/reference/authentication-in-a-workflow) + - See also [the PR review feature caveats](https://cpp-linter.github.io/cpp-linter/pr_review_caveats.html) +- Default: false + +#### `format-review` + +- **Description**: Set this option to true to enable pull request reviews from clang-format. + - To use Pull Request reviews, the `GITHUB_TOKEN` (provided by Github to each repository) must be declared as an environment + variable. See [Authenticating with the GITHUB_TOKEN](https://docs.github.com/en/actions/reference/authentication-in-a-workflow) + - See also [the PR review feature caveats](https://cpp-linter.github.io/cpp-linter/pr_review_caveats.html) +- Default: false + ### Outputs This action creates 3 output variables. Even if the linting checks fail for source files this action will still pass, but users' CI workflows can use this action's outputs to exit the workflow early if that is desired. @@ -202,6 +227,18 @@ The total number of concerns raised by clang-format only. ![step summary](https://raw.githubusercontent.com/cpp-linter/cpp-linter-action/main/docs/images/step-summary.png) +### Pull Request Review + +Using only clang-tidy (`tidy-review`): + +![sample tidy-review](https://raw.githubusercontent.com/cpp-linter/cpp-linter-action/main/docs/images/tidy-review.png) + +Using only clang-format (`format-review`): + +![sample format-review](https://raw.githubusercontent.com/cpp-linter/cpp-linter-action/main/docs/images/format-review.png) + +![sample tidy-review](https://raw.githubusercontent.com/cpp-linter/cpp-linter-action/main/docs/images/format-suggestion.png) + ## Add C/C++ Linter Action badge in README diff --git a/action.yml b/action.yml index 700e1d2b..e95d6e16 100644 --- a/action.yml +++ b/action.yml @@ -62,9 +62,9 @@ inputs: required: false default: "12" verbosity: - description: A hidden option to control the action's log verbosity. This is the `logging` level (defaults to DEBUG). + description: A hidden option to control the action's log verbosity. This is the `logging` level (defaults to `info`). required: false - default: "10" + default: info lines-changed-only: description: Set this option to 'true' to only analyze changes in the event's diff. Defaults to 'false'. required: false @@ -99,6 +99,14 @@ inputs: description: A string of extra arguments passed to clang-tidy for use as compiler arguments. Multiple arguments are separated by spaces so the argument name and value should use an '=' sign instead of a space. required: false default: "" + tidy-review: + description: Set this to true to enable PR reviews from clang-tidy. See also https://cpp-linter.github.io/cpp-linter/pr_review_caveats.html + required: false + default: false + format-review: + description: Set this to true to enable PR reviews from clang-format.See also https://cpp-linter.github.io/cpp-linter/pr_review_caveats.html + required: false + default: false outputs: checks-failed: description: An integer that can be used as a boolean value to indicate if any checks failed by clang-tidy and clang-format. @@ -116,7 +124,8 @@ runs: uses: actions/setup-python@v5 id: setup-python with: - python-version: '3.11' + # use python version shipped with latest Ubuntu LTS + python-version: '3.10' update-environment: false - name: Install Linux clang dependencies @@ -165,7 +174,9 @@ runs: --ignore="${{ inputs.ignore }}" \ --database=${{ inputs.database }} \ --file-annotations=${{ inputs.file-annotations }} \ - --extra-arg="${{ inputs.extra-args }}" + --extra-arg="${{ inputs.extra-args }}" \ + --tidy-review="${{ inputs.tidy-review }}" \ + --format-review="${{ inputs.format-review }}" - name: Setup python venv (Windows) if: runner.os == 'Windows' @@ -198,6 +209,8 @@ runs: ' --ignore="${{ inputs.ignore }}"' + ' --database=${{ inputs.database }}' + ' --file-annotations=${{ inputs.file-annotations }}' + - ' --extra-arg="${{ inputs.extra-args }}"' + ' --extra-arg="${{ inputs.extra-args }}"' + + ' --tidy-review="${{ inputs.tidy-review }}"' + + ' --format-review="${{ inputs.format-review }}"' Invoke-Expression -Command $app diff --git a/docs/images/format-review.png b/docs/images/format-review.png new file mode 100644 index 00000000..30be6b30 Binary files /dev/null and b/docs/images/format-review.png differ diff --git a/docs/images/format-suggestion.png b/docs/images/format-suggestion.png new file mode 100644 index 00000000..02168619 Binary files /dev/null and b/docs/images/format-suggestion.png differ diff --git a/docs/images/tidy-review.png b/docs/images/tidy-review.png new file mode 100644 index 00000000..8b58a41d Binary files /dev/null and b/docs/images/tidy-review.png differ diff --git a/requirements.txt b/requirements.txt index d564c348..5aab7810 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ # Install clang-tools binaries (clang-format, clang-tidy) # For details please see: https://github.com/cpp-linter/clang-tools-pip -clang-tools==0.11.0 +clang-tools==0.11.1 # cpp-linter core Python executable package # For details please see: https://github.com/cpp-linter/cpp-linter -cpp-linter==1.6.5 +cpp-linter==1.7.1