From a030694f35c60eb0b0d478f6ad97fad1a4395b0e Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Thu, 11 Aug 2022 18:43:11 +0800 Subject: [PATCH 01/27] Change action from docker to composite --- action.yml | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/action.yml b/action.yml index cdc7dc2a..095b3465 100644 --- a/action.yml +++ b/action.yml @@ -77,19 +77,33 @@ inputs: outputs: checks-failed: description: An integer that can be used as a boolean value to indicate if all checks failed. + value: ${{ steps.set-checks-failed.outputs.checks-failed }} runs: - using: "docker" - image: "Dockerfile" - args: - - --style=${{ inputs.style }} - - --extensions=${{ inputs.extensions }} - - --tidy-checks=${{ inputs.tidy-checks }} - - --repo-root=${{ inputs.repo-root }} - - --version=${{ inputs.version }} - - --verbosity=${{ inputs.verbosity }} - - --lines-changed-only=${{ inputs.lines-changed-only }} - - --files-changed-only=${{ inputs.files-changed-only }} - - --thread-comments=${{ inputs.thread-comments }} - - --ignore=${{ inputs.ignore }} - - --database=${{ inputs.database }} - - --file-annotations=${{ inputs.file-annotations }} + using: "composite" + steps: + - run: | + echo "Install clang-tools" + pip install clang-tools + clang-tools -i ${{ inputs.version }} + echo "Install cpp-linter" + # FIXME: when cpp-linter released to pypi. + python3 -m pip install git+https://github.com/cpp-linter/cpp-linter-action@v1 + + cpp-linter \ + --style=${{ inputs.style }} \ + --extensions=${{ inputs.extensions }} \ + --tidy-checks=${{ inputs.tidy-checks }} \ + --repo-root=${{ inputs.repo-root }} \ + --version=${{ inputs.version }} \ + --verbosity=${{ inputs.verbosity }} \ + --lines-changed-only=${{ inputs.lines-changed-only }} \ + --files-changed-only=${{ inputs.files-changed-only }} \ + --thread-comments=${{ inputs.thread-comments }} \ + --ignore=${{ inputs.ignore }} \ + --database=${{ inputs.database }} \ + --file-annotations=${{ inputs.file-annotations }} + + shell: bash + - id: set-checks-failed + run: echo "::set-output name=checks-failed::" + shell: bash From c027b35b7a794b20a13b2a5b1524e27b486a36d7 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Thu, 11 Aug 2022 18:56:36 +0800 Subject: [PATCH 02/27] Change action from docker to composite --- .github/workflows/cpp-linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index 83341576..6714547c 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: cpp-linter/cpp-linter-action@master + - uses: cpp-linter/cpp-linter-action@composite-action id: linter env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 061825aa81371b55ac796cc555305cddaba42ab3 Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Fri, 12 Aug 2022 03:38:31 -0700 Subject: [PATCH 03/27] re-organize action steps --- action.yml | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/action.yml b/action.yml index 095b3465..678ad5bf 100644 --- a/action.yml +++ b/action.yml @@ -81,14 +81,14 @@ outputs: runs: using: "composite" steps: - - run: | - echo "Install clang-tools" - pip install clang-tools - clang-tools -i ${{ inputs.version }} - echo "Install cpp-linter" - # FIXME: when cpp-linter released to pypi. - python3 -m pip install git+https://github.com/cpp-linter/cpp-linter-action@v1 - + - name: Install action dependencies + # FIXME: when cpp-linter released to pypi, use that. + run: python3 -m pip install clang-tools git+https://github.com/cpp-linter/cpp-linter-action@v1 + - name: Install clang-tools binary executables + run: clang-tools -i ${{ inputs.version }} + - name: Run cpp-linter + id: cpp-linter + run: | cpp-linter \ --style=${{ inputs.style }} \ --extensions=${{ inputs.extensions }} \ @@ -102,8 +102,5 @@ runs: --ignore=${{ inputs.ignore }} \ --database=${{ inputs.database }} \ --file-annotations=${{ inputs.file-annotations }} - - shell: bash - - id: set-checks-failed + - name: set output variable run: echo "::set-output name=checks-failed::" - shell: bash From d88abcc79b11adcf2c3e4abdbffda2903a440bbc Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Fri, 12 Aug 2022 03:48:32 -0700 Subject: [PATCH 04/27] shell is required for a composite action :-1: --- action.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 678ad5bf..dc3f27f7 100644 --- a/action.yml +++ b/action.yml @@ -83,13 +83,16 @@ runs: steps: - name: Install action dependencies # FIXME: when cpp-linter released to pypi, use that. - run: python3 -m pip install clang-tools git+https://github.com/cpp-linter/cpp-linter-action@v1 + shell: python + run: -m pip install clang-tools git+https://github.com/cpp-linter/cpp-linter-action@v1 - name: Install clang-tools binary executables - run: clang-tools -i ${{ inputs.version }} + shell: python + run: -m clang_tools.main -i ${{ inputs.version }} - name: Run cpp-linter id: cpp-linter + shell: python run: | - cpp-linter \ + -m cpp_linter.run \ --style=${{ inputs.style }} \ --extensions=${{ inputs.extensions }} \ --tidy-checks=${{ inputs.tidy-checks }} \ @@ -103,4 +106,5 @@ runs: --database=${{ inputs.database }} \ --file-annotations=${{ inputs.file-annotations }} - name: set output variable + shell: bash run: echo "::set-output name=checks-failed::" From f1de7398b8a29fea66c99a5d5b1335a793c2c3f4 Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Fri, 12 Aug 2022 03:51:44 -0700 Subject: [PATCH 05/27] the python "shell" is an interactive REPL --- action.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/action.yml b/action.yml index dc3f27f7..e96070f6 100644 --- a/action.yml +++ b/action.yml @@ -83,16 +83,16 @@ runs: steps: - name: Install action dependencies # FIXME: when cpp-linter released to pypi, use that. - shell: python - run: -m pip install clang-tools git+https://github.com/cpp-linter/cpp-linter-action@v1 + shell: bash + run: python3 -m pip install clang-tools git+https://github.com/cpp-linter/cpp-linter-action@v1 - name: Install clang-tools binary executables - shell: python - run: -m clang_tools.main -i ${{ inputs.version }} + shell: bash + run: clang-tools -i ${{ inputs.version }} - name: Run cpp-linter id: cpp-linter - shell: python + shell: bash run: | - -m cpp_linter.run \ + cpp-linter \ --style=${{ inputs.style }} \ --extensions=${{ inputs.extensions }} \ --tidy-checks=${{ inputs.tidy-checks }} \ From 15870fac04b8cb2cfd0a872bb647b27d0efcd047 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Fri, 12 Aug 2022 14:29:31 +0800 Subject: [PATCH 06/27] Add quotes to avoid misinterpret --- action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index e96070f6..9cf45ab1 100644 --- a/action.yml +++ b/action.yml @@ -93,16 +93,16 @@ runs: shell: bash run: | cpp-linter \ - --style=${{ inputs.style }} \ + --style="${{ inputs.style }}" \ --extensions=${{ inputs.extensions }} \ - --tidy-checks=${{ inputs.tidy-checks }} \ + --tidy-checks="${{ inputs.tidy-checks }}" \ --repo-root=${{ inputs.repo-root }} \ --version=${{ inputs.version }} \ --verbosity=${{ inputs.verbosity }} \ --lines-changed-only=${{ inputs.lines-changed-only }} \ --files-changed-only=${{ inputs.files-changed-only }} \ --thread-comments=${{ inputs.thread-comments }} \ - --ignore=${{ inputs.ignore }} \ + --ignore="${{ inputs.ignore }}" \ --database=${{ inputs.database }} \ --file-annotations=${{ inputs.file-annotations }} - name: set output variable From a37e9ff345154f0ddba99205c1580e03706236e5 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Sat, 13 Aug 2022 18:07:27 +0800 Subject: [PATCH 07/27] Remove Dockerfile --- Dockerfile | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 2ac40d28..00000000 --- a/Dockerfile +++ /dev/null @@ -1,24 +0,0 @@ -FROM xianpengshen/clang-tools:all - -# WORKDIR option is set by the github action to the environment variable GITHUB_WORKSPACE. -# See https://docs.github.com/en/actions/creating-actions/dockerfile-support-for-github-actions#workdir - - -LABEL com.github.actions.name="cpp-linter check" -LABEL com.github.actions.description="Lint your code with clang-tidy in parallel to your builds" -LABEL com.github.actions.icon="code" -LABEL com.github.actions.color="gray-dark" - -LABEL repository="https://github.com/cpp-linter/cpp-linter-action" -LABEL maintainer="shenxianpeng <20297606+shenxianpeng@users.noreply.github.com>" - -RUN apt-get update && apt-get -y install python3-pip - -COPY cpp_linter/ pkg/cpp_linter/ -COPY setup.py pkg/setup.py -RUN python3 -m pip install pkg/ - -# github action args use the CMD option -# See https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runsargs -# also https://docs.docker.com/engine/reference/builder/#cmd -ENTRYPOINT [ "python3", "-m", "cpp_linter.run" ] From 38314c98f4b0bf44f89be2907e6dea3b7a0acb2e Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Wed, 24 Aug 2022 00:17:54 -0700 Subject: [PATCH 08/27] install cpp-linter pkg from PyPI --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index a1b412c2..36600745 100644 --- a/action.yml +++ b/action.yml @@ -84,7 +84,7 @@ runs: - name: Install action dependencies # FIXME: when cpp-linter released to pypi, use that. shell: bash - run: python3 -m pip install clang-tools git+https://github.com/cpp-linter/cpp-linter-action@v1 + run: python3 -m pip install clang-tools cpp-linter - name: Install clang-tools binary executables shell: bash run: clang-tools -i ${{ inputs.version }} From ff9b9e1a5c29ef39bd7731ad5f0c2b111e951288 Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Wed, 24 Aug 2022 00:29:37 -0700 Subject: [PATCH 09/27] run test with files-changed-only = false --- .github/workflows/cpp-linter.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index 6714547c..821006b6 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -17,6 +17,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: style: file + files-changed-only: false - name: Fail fast?! if: steps.linter.outputs.checks-failed > 0 From e2e66e110d248b78b90fc649457b7e5e47ff309c Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Wed, 24 Aug 2022 01:14:03 -0700 Subject: [PATCH 10/27] remove composite step about action's output var --- action.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/action.yml b/action.yml index 36600745..0676eb4b 100644 --- a/action.yml +++ b/action.yml @@ -105,6 +105,3 @@ runs: --ignore="${{ inputs.ignore }}" \ --database=${{ inputs.database }} \ --file-annotations=${{ inputs.file-annotations }} - - name: set output variable - shell: bash - run: echo "::set-output name=checks-failed::" From 2c09969c6d2f42e4bad4608948cb04e07b9a6ab5 Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Wed, 24 Aug 2022 03:04:34 -0700 Subject: [PATCH 11/27] reflect output var as exit code --- .github/workflows/cpp-linter.yml | 4 +++- action.yml | 12 ++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index 821006b6..48dc36a5 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -13,14 +13,16 @@ jobs: - uses: actions/checkout@v3 - uses: cpp-linter/cpp-linter-action@composite-action id: linter + continue-on-error: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: style: file files-changed-only: false + quiet-fail: false - name: Fail fast?! - if: steps.linter.outputs.checks-failed > 0 + if: steps.linter.outcome == 'failure' run: | echo "Some files failed the linting checks!" # for actual deployment diff --git a/action.yml b/action.yml index 0676eb4b..67197321 100644 --- a/action.yml +++ b/action.yml @@ -74,10 +74,10 @@ inputs: description: The directory containing compile_commands.json file. required: false default: "" -outputs: - checks-failed: - description: An integer that can be used as a boolean value to indicate if all checks failed. - value: ${{ steps.set-checks-failed.outputs.checks-failed }} + quiet-fail: + description: A flag that can be used to exit with a non-successfull error code (not '0') if any checks failed. + required: false + default: true runs: using: "composite" steps: @@ -105,3 +105,7 @@ runs: --ignore="${{ inputs.ignore }}" \ --database=${{ inputs.database }} \ --file-annotations=${{ inputs.file-annotations }} + - name: set output variable + if: steps.cpp-linter.outputs.checks-failed != 0 && inputs.quiet-fail != 'true' + shell: bash + run: exit 1 From 33c9f677b81ba09fff0c30cc270aadba7418ab11 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Sat, 27 Aug 2022 09:02:07 +0800 Subject: [PATCH 12/27] remove FIXME comment --- action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/action.yml b/action.yml index 67197321..6d4d177d 100644 --- a/action.yml +++ b/action.yml @@ -82,7 +82,6 @@ runs: using: "composite" steps: - name: Install action dependencies - # FIXME: when cpp-linter released to pypi, use that. shell: bash run: python3 -m pip install clang-tools cpp-linter - name: Install clang-tools binary executables From 4ba7b1a45b3154a2a9bf0485f2bc617da3714ad8 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Sat, 27 Aug 2022 14:07:32 +0800 Subject: [PATCH 13/27] update for testing --- .github/workflows/cpp-linter.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index 48dc36a5..5b4e3cab 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -19,11 +19,10 @@ jobs: with: style: file files-changed-only: false - quiet-fail: false + # quiet-fail: false - name: Fail fast?! - if: steps.linter.outcome == 'failure' - run: | - echo "Some files failed the linting checks!" + if: steps.linter.outputs.checks-failed > 0 + run: echo "some linter checks failed" # for actual deployment # run: exit 1 From afb3400b2091cc0449c43b3b6f608439d557e766 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Sat, 27 Aug 2022 14:40:17 +0800 Subject: [PATCH 14/27] update for testing --- .github/workflows/cpp-linter.yml | 2 +- action.yml | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index 5b4e3cab..56290afa 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -22,7 +22,7 @@ jobs: # quiet-fail: false - name: Fail fast?! - if: steps.linter.outputs.checks-failed > 0 + if: steps.linter.outputs.checks-failed != 0 run: echo "some linter checks failed" # for actual deployment # run: exit 1 diff --git a/action.yml b/action.yml index 6d4d177d..cf6fca16 100644 --- a/action.yml +++ b/action.yml @@ -74,10 +74,10 @@ inputs: description: The directory containing compile_commands.json file. required: false default: "" - quiet-fail: - description: A flag that can be used to exit with a non-successfull error code (not '0') if any checks failed. - required: false - default: true +outputs: + checks-failed: + description: An integer that can be used as a boolean value to indicate if all checks failed. + value: ${{ steps.set-variable.outputs.checks-failed }} runs: using: "composite" steps: @@ -105,6 +105,8 @@ runs: --database=${{ inputs.database }} \ --file-annotations=${{ inputs.file-annotations }} - name: set output variable - if: steps.cpp-linter.outputs.checks-failed != 0 && inputs.quiet-fail != 'true' + id: set-variable + if: steps.cpp-linter.outputs.checks-failed != 0 shell: bash - run: exit 1 + run: | + echo "::set-output name=checks-failed::1" From 34c2386d768deccf2375383b00dd284f835e11a6 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Sat, 27 Aug 2022 15:02:00 +0800 Subject: [PATCH 15/27] change variable output value --- .github/workflows/cpp-linter.yml | 4 +++- action.yml | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index 56290afa..23f85b1c 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -23,6 +23,8 @@ jobs: - name: Fail fast?! if: steps.linter.outputs.checks-failed != 0 - run: echo "some linter checks failed" + run: | + echo "some linter checks failed" + echo ${{ steps.linter.outputs.checks-failed }} # for actual deployment # run: exit 1 diff --git a/action.yml b/action.yml index cf6fca16..eaa20ebe 100644 --- a/action.yml +++ b/action.yml @@ -108,5 +108,4 @@ runs: id: set-variable if: steps.cpp-linter.outputs.checks-failed != 0 shell: bash - run: | - echo "::set-output name=checks-failed::1" + run: echo "::set-output name=checks-failed::12345" From 31438dbcea13fcd73d0b962ecb9a9a8460a9e2da Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Sat, 27 Aug 2022 15:11:05 +0800 Subject: [PATCH 16/27] update variable output value --- .github/workflows/cpp-linter.yml | 3 +-- action.yml | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index 23f85b1c..debbfc39 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -24,7 +24,6 @@ jobs: - name: Fail fast?! if: steps.linter.outputs.checks-failed != 0 run: | - echo "some linter checks failed" - echo ${{ steps.linter.outputs.checks-failed }} + echo "some linter checks failed. ${{ steps.linter.outputs.checks-failed }}" # for actual deployment # run: exit 1 diff --git a/action.yml b/action.yml index eaa20ebe..d45888cc 100644 --- a/action.yml +++ b/action.yml @@ -108,4 +108,4 @@ runs: id: set-variable if: steps.cpp-linter.outputs.checks-failed != 0 shell: bash - run: echo "::set-output name=checks-failed::12345" + run: echo "::set-output name=checks-failed::1" From 5302ca97d299822704ccbb06b167e78921165787 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Sat, 27 Aug 2022 15:18:20 +0800 Subject: [PATCH 17/27] change output variable --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index d45888cc..0fad9e1f 100644 --- a/action.yml +++ b/action.yml @@ -106,6 +106,6 @@ runs: --file-annotations=${{ inputs.file-annotations }} - name: set output variable id: set-variable - if: steps.cpp-linter.outputs.checks-failed != 0 + # if: steps.cpp-linter.outputs.checks-failed != 0 shell: bash - run: echo "::set-output name=checks-failed::1" + run: echo "::set-output name=checks-failed::${{ steps.cpp-linter.outputs.checks-failed }}" From 15fdf2f801408ebaa44854dd390f35ecf68cce0d Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Sat, 27 Aug 2022 15:34:19 +0800 Subject: [PATCH 18/27] remove set variable step --- action.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/action.yml b/action.yml index 0fad9e1f..44fb7cda 100644 --- a/action.yml +++ b/action.yml @@ -77,7 +77,7 @@ inputs: outputs: checks-failed: description: An integer that can be used as a boolean value to indicate if all checks failed. - value: ${{ steps.set-variable.outputs.checks-failed }} + value: ${{ steps.cpp-linter.outputs.checks-failed }} runs: using: "composite" steps: @@ -104,8 +104,3 @@ runs: --ignore="${{ inputs.ignore }}" \ --database=${{ inputs.database }} \ --file-annotations=${{ inputs.file-annotations }} - - name: set output variable - id: set-variable - # if: steps.cpp-linter.outputs.checks-failed != 0 - shell: bash - run: echo "::set-output name=checks-failed::${{ steps.cpp-linter.outputs.checks-failed }}" From f564202dd56f41d6ae373d800e1f451714667386 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Sat, 27 Aug 2022 16:22:27 +0800 Subject: [PATCH 19/27] remove use as pkg from README --- README.md | 98 ++----------------------------------------------------- 1 file changed, 2 insertions(+), 96 deletions(-) diff --git a/README.md b/README.md index b854411e..ac2130d0 100644 --- a/README.md +++ b/README.md @@ -74,9 +74,9 @@ jobs: #### `version` -- **Description**: The desired version of the [clang-tools](https://hub.docker.com/r/xianpengshen/clang-tools) to use. Accepted options are strings which can be 14, 13, 12, 11, 10, 9, or 8. +- **Description**: The desired version of the [clang-tools](https://github.com/cpp-linter/clang-tools-pip) to use. Accepted options are strings which can be 14, 13, 12, 11, 10, 9, 8,7, 6, 5, 4 or 3.9. - Set this option to a blank string (`''`) to use the platform's default installed version. - - This value can also be a path to where the clang tools are installed (if using a custom install location). Because all paths specified here are converted to absolute, using a relative path as a value may not be compatible when using the docker environment (see [Running without the docker container](#running-without-the-docker-container)). + - This value can also be a path to where the clang tools are installed (if using a custom install location). - Default: '12' #### `verbosity` @@ -130,106 +130,12 @@ jobs: #### `database` - **Description**: The directory containing compilation database (like compile_commands.json) file. - - This option doesn't seems to work properly from the docker environment. Instead we recommend using this option when see [running without the docker container](#running-without-the-docker-container). - Default: '' ### Outputs This action creates 1 output variable named `checks-failed`. Even if the linting checks fail for source files this action will still pass, but users' CI workflows can use this action's output to exit the workflow early if that is desired. -## Running without the docker container - -Some Continuous Integration environments require access to non-default compilers -and/or non-standard libraries. To do this properly, the docker container should -not be used due to it's isolated file system. Instead, you should use this action's -python source code as an installed python package (see below). - -### Using the python source code - -This action was originally designed to only be used on a runner with the Ubuntu -Operating System. However, this action's source code (essentially a python package) -can be used on any runner using the Windows, Ubuntu, or possibly even MacOS (untested) -virtual environments. - -Note, some runners already ship with clang-format and/or clang-tidy. As of this writing, the following versions of clang-format and clang-tidy are already available: - -- `ubuntu-latest` ships with v10, v11, and v12. [More details](https://github.com/actions/virtual-environments/blob/ubuntu20/20220508.1/images/linux/Ubuntu2004-Readme.md). -- `windows-latest` ships with v13. [More details](https://github.com/actions/virtual-environments/blob/win22/20220511.2/images/win/Windows2022-Readme.md). -- `macos-latest` ships with v13. [More details](https://github.com/actions/virtual-environments/blob/main/images/macos/macos-11-Readme.md). - -This example makes use of another action -([KyleMayes/install-llvm-action](https://github.com/KyleMayes/install-llvm-action)) -to install a certain version of clang-tidy and clang-format. - -```yml -on: - pull_request: - types: [opened, reopened] # let PR-synchronize events be handled by push events - push: - -jobs: - cpp-linter: - runs-on: windows-latest - - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - - # this step can be skipped if the desired - # version already comes with the runner's OS - - name: Install clang-tools - uses: KyleMayes/install-llvm-action@v1 - with: - # v13 is the recommended minimum for the Visual Studio compiler (on Windows) - version: 14 - # specifying an install path is required (on Windows) because installing - # multiple versions on Windows runners needs non-default install paths. - directory: ${{ runner.temp }}/llvm - - - name: Install linter python package - run: python3 -m pip install git+https://github.com/cpp-linter/cpp-linter-action@v1 - - - name: run linter as a python package - id: linter - # Pass the installed path to the '--version' argument. - # Alternatively, pass the version number. - # Example. run: cpp-linter --version=14 - # Omit the version option if using the default version available in the OS. - run: cpp-linter --version=${{ runner.temp }}/llvm - - - name: Fail fast?! - if: steps.linter.outputs.checks-failed > 0 - run: echo "Some files failed the linting checks!" - # for actual deployment - # run: exit 1 -``` - -All input options listed above are specified by pre-pending a `--`. You can also install this repo locally and run `cpp-linter -h` for more detail. For example: - -```yaml - - uses: cpp-linter/cpp-linter-action@v1 - with: - style: file - tidy-checks: '-*' - files-changed-only: false - ignore: 'dist/third-party-lib' -``` - -is equivalent to - -```yaml - - name: Install linter python package - run: python3 -m pip install git+https://github.com/cpp-linter/cpp-linter-action@v1 - - - name: run linter as a python package - run: | - cpp-linter \ - --style=file \ - --tidy-checks='-*' \ - --files-changed-only=false \ - --ignore='dist/third-party-lib' -``` - ## Example From 0070d02e71196fa06a5187da8d4847945749f20d Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Sat, 27 Aug 2022 17:46:46 +0800 Subject: [PATCH 20/27] add what is new to README --- README.md | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ac2130d0..7f46f9db 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,19 @@ A Github Action for linting C/C++ code integrating clang-tidy and clang-format to collect feedback provided in the form of thread comments and/or annotations. +## What's New + +v2 + +* Change action from using docker to composite steps + * improve workflow runs times from 1m 24s (currently) to 6-20s. + * better support for the database input option (which is currently broken with the docker env). + * better support cross-compilation + * better support 3rd party libraries +* Includes many issues and enhancements. See [#87](https://github.com/cpp-linter/cpp-linter-action/issues/87) for details. + +Refer [here](https://github.com/cpp-linter/cpp-linter-action/tree/v1) for previous versions. + ## Usage 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/master/.github/workflows/cpp-linter.yml) @@ -18,21 +31,16 @@ Create a new GitHub Actions workflow in your project, e.g. at [.github/workflows The content of the file should be in the following format. ```yaml -# Workflow syntax: -# https://help.github.com/en/articles/workflow-syntax-for-github-actions name: cpp-linter -on: - pull_request: - types: [opened, reopened] # let PR-synchronize events be handled by push events - push: +on: pull_request jobs: cpp-linter: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: cpp-linter/cpp-linter-action@v1 + - uses: cpp-linter/cpp-linter-action@v2 id: linter env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From d7e93a3a37e5c2b414212a85953aeed45cfe4e6b Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Mon, 29 Aug 2022 16:04:26 -0700 Subject: [PATCH 21/27] don't show progress bars in clang-tools install --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 44fb7cda..ce226644 100644 --- a/action.yml +++ b/action.yml @@ -86,7 +86,7 @@ runs: run: python3 -m pip install clang-tools cpp-linter - name: Install clang-tools binary executables shell: bash - run: clang-tools -i ${{ inputs.version }} + run: clang-tools -i ${{ inputs.version }} -b - name: Run cpp-linter id: cpp-linter shell: bash From 507d5a6e17a802219e1166336a23319ff36adc61 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Wed, 31 Aug 2022 16:04:29 +0800 Subject: [PATCH 22/27] Remove publish-pypi.yml #91 --- .github/workflows/publish-pypi.yml | 51 ------------------------------ 1 file changed, 51 deletions(-) delete mode 100644 .github/workflows/publish-pypi.yml diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml deleted file mode 100644 index 00ad109a..00000000 --- a/.github/workflows/publish-pypi.yml +++ /dev/null @@ -1,51 +0,0 @@ -# This workflow will upload a Python Package using Twine when a release is created -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries - -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -name: Upload Python Package - -on: - release: - branches: [master] - types: [published] - workflow_dispatch: - -permissions: - contents: read - -jobs: - deploy: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - # use fetch --all for setuptools_scm to work - with: - fetch-depth: 0 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - name: Install dependencies - run: python -m pip install --upgrade pip twine - - name: Build wheel - run: python -m pip wheel -w dist --no-deps . - - name: Check distribution - run: twine check dist/* - - name: Publish package (to TestPyPI) - if: github.event_name == 'workflow_dispatch' && github.repository == 'cpp-linter/cpp-linter-action' - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }} - run: twine upload --repository testpypi dist/* - - name: Publish package (to PyPI) - if: github.event_name != 'workflow_dispatch' && github.repository == 'cpp-linter/cpp-linter-action' - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} - run: twine upload dist/* From 1e2ff28a7e850c9323a7899d91dbe32fa123379d Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Wed, 31 Aug 2022 16:43:42 +0800 Subject: [PATCH 23/27] Switch from master to main branch --- .github/workflows/mkdocs-deploy.yml | 4 ++-- .github/workflows/run-dev-tests.yml | 2 +- .../{pre-commit-hooks.yml => run-pre-commit.yml} | 0 .github/workflows/run-test.yml | 4 ++-- README.md | 12 ++++++------ 5 files changed, 11 insertions(+), 11 deletions(-) rename .github/workflows/{pre-commit-hooks.yml => run-pre-commit.yml} (100%) diff --git a/.github/workflows/mkdocs-deploy.yml b/.github/workflows/mkdocs-deploy.yml index 7ca30a6f..8f178fd4 100644 --- a/.github/workflows/mkdocs-deploy.yml +++ b/.github/workflows/mkdocs-deploy.yml @@ -15,10 +15,10 @@ jobs: - name: Install python action for doc extraction run: pip install . -r docs/requirements.txt - name: check mkdocs build - if: github.ref != 'refs/heads/master' + if: github.ref != 'refs/heads/main' run: mkdocs build - name: Build docs and deploy to gh-pages - if: github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/main' run: | git config user.name 'github-actions' git config user.email '41898282+github-actions[bot]@users.noreply.github.com' diff --git a/.github/workflows/run-dev-tests.yml b/.github/workflows/run-dev-tests.yml index ae17ce5d..8edd2839 100644 --- a/.github/workflows/run-dev-tests.yml +++ b/.github/workflows/run-dev-tests.yml @@ -1,4 +1,4 @@ -name: "Check python code" +name: "Test python code" on: push: diff --git a/.github/workflows/pre-commit-hooks.yml b/.github/workflows/run-pre-commit.yml similarity index 100% rename from .github/workflows/pre-commit-hooks.yml rename to .github/workflows/run-pre-commit.yml diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml index a2f7ff7a..17296672 100644 --- a/.github/workflows/run-test.yml +++ b/.github/workflows/run-test.yml @@ -2,10 +2,10 @@ name: "Test action and package" on: push: - branches: master + branches: main paths-ignore: "docs/**" pull_request: - branches: master + branches: main paths-ignore: "docs/**" jobs: diff --git a/README.md b/README.md index 7f46f9db..2b13e00d 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/cpp-linter/cpp-linter-action/cpp-linter?label=cpp-linter&logo=Github&style=flat-square)](https://github.com/cpp-linter/cpp-linter-action/actions/workflows/cpp-linter.yml) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/cpp-linter/cpp-linter-action/MkDocs%20Deploy?label=docs&logo=Github&style=flat-square)](https://github.com/cpp-linter/cpp-linter-action/actions/workflows/mkdocs-deploy.yml) ![GitHub](https://img.shields.io/github/license/cpp-linter/cpp-linter-action?label=license&logo=github&style=flat-square) -[![codecov](https://codecov.io/gh/cpp-linter/cpp-linter-action/branch/master/graph/badge.svg?token=4SF7UEDEZ2)](https://codecov.io/gh/cpp-linter/cpp-linter-action) +[![codecov](https://codecov.io/gh/cpp-linter/cpp-linter-action/branch/main/graph/badge.svg?token=4SF7UEDEZ2)](https://codecov.io/gh/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 thread comments and/or annotations. @@ -26,7 +26,7 @@ Refer [here](https://github.com/cpp-linter/cpp-linter-action/tree/v1) for previo ## Usage -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/master/.github/workflows/cpp-linter.yml) +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. @@ -150,13 +150,13 @@ This action creates 1 output variable named `checks-failed`. Even if the linting ### Annotations -![clang-format annotations](https://raw.githubusercontent.com/cpp-linter/cpp-linter-action/master/docs/images/annotations-clang-format.png) +![clang-format annotations](https://raw.githubusercontent.com/cpp-linter/cpp-linter-action/main/docs/images/annotations-clang-format.png) -![clang-tidy annotations](https://raw.githubusercontent.com/cpp-linter/cpp-linter-action/master/docs/images/annotations-clang-tidy.png) +![clang-tidy annotations](https://raw.githubusercontent.com/cpp-linter/cpp-linter-action/main/docs/images/annotations-clang-tidy.png) ### Thread Comment -![sample comment](https://raw.githubusercontent.com/cpp-linter/cpp-linter-action/master/docs/images/comment.png) +![sample comment](https://raw.githubusercontent.com/cpp-linter/cpp-linter-action/main/docs/images/comment.png) @@ -178,6 +178,6 @@ To provide feedback (requesting a feature or reporting a bug) please post to [is ## License -The scripts and documentation in this project are released under the [MIT License](https://github.com/cpp-linter/cpp-linter-action/blob/master/LICENSE) +The scripts and documentation in this project are released under the [MIT License](https://github.com/cpp-linter/cpp-linter-action/blob/main/LICENSE) From 88eff0cf480365f2102e86a5e4389451d8202162 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Thu, 1 Sep 2022 10:48:56 +0800 Subject: [PATCH 24/27] Add CONTRIBUTING.md --- CONTRIBUTING.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..913a5512 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,19 @@ +# Contributing + +Thank you for investing your time in contributing to our project! We welcome feedback, bug reports, and pull requests! + +## New contributor guide + +Ours develop branch is `main` not `master` (`master` is used to be the develop branch). + +The reason we didn't delete the `master` branch is that there are still users whose workflows point to the `master` branch. + +For pull requests, please stick to the following guidelines + +* Add tests for any new features and bug fixes. +* Put a reasonable amount of comments into the code. +* Fork cpp-linter-action on your GitHub user account, do your changes there and then create a PR against `main` branch of cpp-linter-action repository. +* Separate unrelated changes into multiple pull requests. + + +Please note that by contributing any code or documentation to this repository (by raising pull requests, or otherwise) you explicitly agree to the [License Agreement](LICENSE). From d358972bbfb98f49b9b10c5f4a42f2330965a085 Mon Sep 17 00:00:00 2001 From: Peter Shen Date: Thu, 1 Sep 2022 15:06:50 +0800 Subject: [PATCH 25/27] Update CONTRIBUTING.md Co-authored-by: Brendan <2bndy5@gmail.com> --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 913a5512..afc34da6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,7 @@ Thank you for investing your time in contributing to our project! We welcome fee ## New contributor guide -Ours develop branch is `main` not `master` (`master` is used to be the develop branch). +Ours develop branch is `main` not `master` (`master` used to be the develop branch for v1.x). The reason we didn't delete the `master` branch is that there are still users whose workflows point to the `master` branch. From e4b25d42ed1cd6b7fd0ae607d8f0730adeeda74b Mon Sep 17 00:00:00 2001 From: Peter Shen Date: Thu, 1 Sep 2022 15:07:15 +0800 Subject: [PATCH 26/27] Update CONTRIBUTING.md Co-authored-by: Brendan <2bndy5@gmail.com> --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index afc34da6..a0cbdc8d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,5 +15,6 @@ For pull requests, please stick to the following guidelines * Fork cpp-linter-action on your GitHub user account, do your changes there and then create a PR against `main` branch of cpp-linter-action repository. * Separate unrelated changes into multiple pull requests. +If you wish to contribute to the python source package used by this action, then that has moved to it's own repository named [cpp-linter](https://github.com/cpp-linter/cpp-linter) as of v2 of this action. Please note that by contributing any code or documentation to this repository (by raising pull requests, or otherwise) you explicitly agree to the [License Agreement](LICENSE). From 62eb6039db5dbec75827a1068a531bee393e1abb Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Thu, 1 Sep 2022 02:05:09 -0700 Subject: [PATCH 27/27] requested changes --- .github/workflows/cpp-linter.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index debbfc39..02746ba3 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: cpp-linter/cpp-linter-action@composite-action + - uses: cpp-linter/cpp-linter-action@main id: linter continue-on-error: true env: @@ -19,7 +19,6 @@ jobs: with: style: file files-changed-only: false - # quiet-fail: false - name: Fail fast?! if: steps.linter.outputs.checks-failed != 0