├── .gitattributes ├── .github └── workflows │ ├── depup.yml │ ├── docker-build.yml │ ├── pr-test.yml │ ├── release.yml │ ├── reviewdog.yml │ └── self-test.yml ├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── action.yml ├── entrypoint.sh ├── renovate.json ├── reviewdog-action-cpplint.code-workspace └── testdata ├── test.cpp ├── test.hpp ├── test2.c └── test2.h /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.gitattributes text eol=lf 3 | *.gitignore text eol=lf 4 | 5 | * text eol=lf 6 | -------------------------------------------------------------------------------- /.github/workflows/depup.yml: -------------------------------------------------------------------------------- 1 | name: depup 2 | on: 3 | schedule: 4 | - cron: "2 1 * * *" # Runs at 01:02 UTC every day 5 | repository_dispatch: 6 | types: [depup] 7 | workflow_dispatch: 8 | 9 | jobs: 10 | reviewdog: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 14 | - uses: reviewdog/action-depup@94a1aaf4e4923064019214b48a43276218af7ad5 # v1.6.4 15 | id: depup 16 | with: 17 | file: Dockerfile 18 | version_name: REVIEWDOG_VERSION 19 | repo: reviewdog/reviewdog 20 | 21 | - name: Create Pull Request 22 | uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8 23 | with: 24 | token: ${{ secrets.GITHUB_TOKEN }} 25 | title: "chore(deps): update reviewdog to ${{ steps.depup.outputs.latest }}" 26 | commit-message: "chore(deps): update reviewdog to ${{ steps.depup.outputs.latest }}" 27 | body: | 28 | Update reviewdog to [v${{ steps.depup.outputs.latest }}](https://github.com/reviewdog/reviewdog/releases/tag/v${{ steps.depup.outputs.latest }}) 29 | Compare [v${{ steps.depup.outputs.current }}...v${{ steps.depup.outputs.latest }}](https://github.com/reviewdog/reviewdog/compare/v${{ steps.depup.outputs.current }}...v${{ steps.depup.outputs.latest }}) 30 | This PR is auto generated by [depup workflow](https://github.com/${{ github.repository }}/actions?query=workflow%3Adepup). 31 | branch: depup/reviewdog 32 | base: master 33 | labels: "bump:minor" 34 | -------------------------------------------------------------------------------- /.github/workflows/docker-build.yml: -------------------------------------------------------------------------------- 1 | name: Docker Image CI 2 | on: [push] 3 | 4 | jobs: 5 | build: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - name: Clone repo 9 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 10 | with: 11 | fetch-depth: 1 12 | - name: Build the Docker image 13 | run: docker build . --file Dockerfile --tag reviewdog-cpplint:$(date +%s) 14 | -------------------------------------------------------------------------------- /.github/workflows/pr-test.yml: -------------------------------------------------------------------------------- 1 | name: PR test 2 | on: [pull_request] 3 | 4 | jobs: 5 | cpplint: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - name: clone 9 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 10 | - uses: ./ 11 | with: 12 | github_token: ${{ secrets.github_token }} 13 | # reporter: github-pr-review 14 | reporter: github-pr-check 15 | flags: --linelength=50 16 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: release 2 | on: 3 | push: 4 | branches: 5 | - master 6 | tags: 7 | - 'v*.*.*' 8 | pull_request: 9 | types: 10 | - labeled 11 | 12 | jobs: 13 | release: 14 | if: github.event.action != 'labeled' 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 18 | 19 | # Bump version on merging Pull Requests with specific labels. 20 | # (bump:major,bump:minor,bump:patch) 21 | - id: bumpr 22 | if: "!startsWith(github.ref, 'refs/tags/')" 23 | uses: haya14busa/action-bumpr@78ab5a104d20896c9c9122c64221b3aecf1a8cbb # v1.10.0 24 | 25 | # Update corresponding major and minor tag. 26 | # e.g. Update v1 and v1.2 when releasing v1.2.3 27 | - uses: haya14busa/action-update-semver@fb48464b2438ae82cc78237be61afb4f461265a1 # v1.2.1 28 | if: "!steps.bumpr.outputs.skip" 29 | with: 30 | tag: ${{ steps.bumpr.outputs.next_version }} 31 | 32 | # Get tag name. 33 | - id: tag 34 | uses: haya14busa/action-cond@94f77f7a80cd666cb3155084e428254fea4281fd # v1.2.1 35 | with: 36 | cond: "${{ startsWith(github.ref, 'refs/tags/') }}" 37 | if_true: ${{ github.ref }} 38 | if_false: ${{ steps.bumpr.outputs.next_version }} 39 | 40 | # Create release 41 | - if: "steps.tag.outputs.value != ''" 42 | env: 43 | TAG_NAME: ${{ steps.tag.outputs.value }} 44 | CURRENT: ${{ steps.bumpr.outputs.current_version }} 45 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 46 | run: | 47 | gh release create "${TAG_NAME}" -t "Release ${TAG_NAME/refs\/tags\//}" --generate-notes --notes-start-tag "${CURRENT}" 48 | 49 | release-check: 50 | if: github.event.action == 'labeled' 51 | runs-on: ubuntu-latest 52 | steps: 53 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 54 | - name: Post bumpr status comment 55 | uses: haya14busa/action-bumpr@78ab5a104d20896c9c9122c64221b3aecf1a8cbb # v1.10.0 56 | -------------------------------------------------------------------------------- /.github/workflows/reviewdog.yml: -------------------------------------------------------------------------------- 1 | name: Reviewdog 2 | on: [pull_request] 3 | 4 | jobs: 5 | cpplint: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 9 | - uses: reviewdog/action-cpplint@master 10 | with: 11 | github_token: ${{ secrets.github_token }} 12 | reporter: github-pr-review 13 | flags: --linelength=50 # Optional 14 | filter: "-readability/braces\ 15 | ,-whitespace/braces\ 16 | ,-whitespace/comments\ 17 | ,-whitespace/indent\ 18 | ,-whitespace/newline\ 19 | ,-whitespace/operators\ 20 | ,-whitespace/parens\ 21 | " # Optional 22 | shellcheck: 23 | name: runner / shellcheck 24 | runs-on: ubuntu-latest 25 | steps: 26 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 27 | - name: shellcheck 28 | uses: reviewdog/action-shellcheck@5ebd09ddbe2ebb471646ce234c6c8dd18663ca7c # v1.30.0 29 | with: 30 | github_token: ${{ secrets.github_token }} 31 | reporter: github-pr-review # Change reporter. 32 | path: "." # Optional. 33 | pattern: "*.sh" # Optional. 34 | exclude: "./.git/*" # Optional. 35 | shellcheck_flags: "--external-sources -e SC2086" 36 | -------------------------------------------------------------------------------- /.github/workflows/self-test.yml: -------------------------------------------------------------------------------- 1 | name: Self test 2 | on: [push] 3 | 4 | jobs: 5 | test: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - name: clone 9 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 10 | with: 11 | fetch-depth: 2 12 | - name: testbuild 13 | run: | 14 | cd testdata 15 | g++ --version 16 | g++ ./test.cpp -o test 17 | ls 18 | ./test 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | cpplint.py 2 | *.exe -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.13-alpine 2 | 3 | SHELL ["/bin/ash", "-eo", "pipefail", "-c"] 4 | 5 | RUN apk --no-cache --update add git \ 6 | && rm -rf /var/cache/apk/* 7 | 8 | # install reviewdog 9 | ENV REVIEWDOG_VERSION=v0.20.3 10 | RUN wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/fd59714416d6d9a1c0692d872e38e7f8448df4fc/install.sh | sh -s -- -b /usr/local/bin/ ${REVIEWDOG_VERSION} 11 | 12 | # install cpplint 13 | RUN pip install cpplint 14 | 15 | COPY entrypoint.sh /entrypoint.sh 16 | 17 | ENTRYPOINT ["/entrypoint.sh"] 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 reviewdog 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GitHub Action: Run cpplint with reviewdog 2 | 3 | [![Docker Image CI Status](https://github.com/reviewdog/action-cpplint/workflows/Docker%20Image%20CI/badge.svg?branch=master)](https://github.com/reviewdog/action-cpplint/actions) 4 | [![Release](https://img.shields.io/github/release/reviewdog/action-cpplint.svg?maxAge=43200)](https://github.com/reviewdog/action-cpplint/releases) 5 | 6 | [![github-pr-check sample](https://user-images.githubusercontent.com/1439172/67361002-68025080-f5a2-11e9-97b7-530d0531edb4.png)](https://github.com/reviewdog/action-cpplint/pull/2) 7 | [![github-pr-review sample](https://user-images.githubusercontent.com/1439172/67361077-9c760c80-f5a2-11e9-98e4-975052cd6fd4.png)](https://github.com/reviewdog/action-cpplint/pull/2) 8 | 9 | 10 | This action runs [cpplint](https://pypi.org/project/cpplint/) with [reviewdog](https://github.com/reviewdog/reviewdog) on pull requests to improve code review experience. 11 | 12 | ## Inputs 13 | 14 | ### `github_token` 15 | 16 | **Required**. Must be in form of `github_token: ${{ secrets.github_token }}`'. 17 | 18 | ### `level` 19 | 20 | Optional. Report level for reviewdog [info,warning,error]. 21 | It's same as `-level` flag of reviewdog. 22 | Default is `error`. 23 | 24 | ### `reporter` 25 | 26 | Reporter of reviewdog command [github-pr-check,github-pr-review]. 27 | Default is `github-pr-check`. 28 | 29 | ### `reviewdog_flags` 30 | Additional reviewdog flags. 31 | Default is `''`. 32 | 33 | ### `flags` 34 | 35 | Optional. List of arguments to send to cpplint. 36 | Default is `--extensions=h,hpp,c,cpp,cc,cu,hh,ipp`. 37 | 38 | ### `filter` 39 | 40 | Optional. List of filter arguments to send to cpplint. 41 | Default is `--filter=""`. 42 | 43 | ### `targets` 44 | 45 | Optional. List of file list arguments to send to cpplint. 46 | Default is `--recursive`. 47 | 48 | ## Example Usage 49 | 50 | ### [.github/workflows/reviewdog.yml](.github/workflows/reviewdog.yml) 51 | 52 | ```yml 53 | name: Reviewdog 54 | on: [pull_request] 55 | 56 | jobs: 57 | cpplint: 58 | runs-on: ubuntu-latest 59 | steps: 60 | - uses: actions/checkout@master 61 | - uses: reviewdog/action-cpplint@master 62 | with: 63 | github_token: ${{ secrets.github_token }} 64 | reporter: github-pr-review 65 | flags: --linelength=50 # Optional 66 | filter: "-readability/braces\ 67 | ,-whitespace/braces\ 68 | ,-whitespace/comments\ 69 | ,-whitespace/indent\ 70 | ,-whitespace/newline\ 71 | ,-whitespace/operators\ 72 | ,-whitespace/parens\ 73 | " # Optional 74 | ``` 75 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'Run cpplint with reviewdog' 2 | description: '🐶 Run cpplint with reviewdog on pull requests to enforce best practices' 3 | author: 'srz-zumix' 4 | 5 | inputs: 6 | github_token: 7 | description: 'GITHUB_TOKEN' 8 | required: true 9 | level: 10 | description: | 11 | Report level for reviewdog [info,warning,error]. 12 | Default is 'error'. 13 | default: 'error' 14 | reporter: 15 | description: | 16 | Reporter of reviewdog command [github-pr-check,github-pr-review]. 17 | Default is 'github-pr-check'. 18 | default: 'github-pr-check' 19 | reviewdog_flags: 20 | description: | 21 | Additional reviewdog flags. 22 | Default is ''. 23 | default: '' 24 | flags: 25 | description: | 26 | List of arguments to send to cpplint. 27 | Default is '--extensions=h,hpp,c,cpp,cc,cu,hh,ipp'. 28 | default: '--extensions=h,hpp,c,cpp,cc,cu,hh,ipp' 29 | filter: 30 | description: | 31 | List of filter arguments to send to cpplint. 32 | Default is ''. 33 | default: '' 34 | targets: 35 | description: | 36 | List of file list arguments to send to cpplint. 37 | Default is '--recursive .'. 38 | default: '--recursive .' 39 | runs: 40 | using: 'docker' 41 | image: 'Dockerfile' 42 | branding: 43 | icon: 'plus-circle' 44 | color: 'blue' 45 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -n "${GITHUB_WORKSPACE}" ] ; then 4 | git config --global --add safe.directory "${GITHUB_WORKSPACE}" || exit 5 | cd "${GITHUB_WORKSPACE}" || exit 6 | fi 7 | 8 | export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" 9 | 10 | [[ -n "${INPUT_FLAGS}" ]] && set -- "$@" ${INPUT_FLAGS} 11 | [[ -n "${INPUT_FILTER}" ]] && set -- "$@" --filter="${INPUT_FILTER}" 12 | 13 | cpplint "$@" ${INPUT_TARGETS} 2>&1 \ 14 | | reviewdog -efm="%f:%l: %m" -name="cpplint" -reporter="${INPUT_REPORTER}" -level="${INPUT_LEVEL}" "${INPUT_REVIEWDOG_FLAGS}" 15 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /reviewdog-action-cpplint.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ], 7 | "settings": { 8 | "editor.rulers": [ 9 | 50, 10 | 80, 11 | 110, 12 | 140 13 | ], 14 | } 15 | } -------------------------------------------------------------------------------- /testdata/test.cpp: -------------------------------------------------------------------------------- 1 | // aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 2 | // 3 | #include "test.hpp" 4 | #include 5 | 6 | class Hoge 7 | { 8 | public: 9 | Hoge(int a) : m_a(a) {} 10 | public: 11 | int getA() const { return m_a; } 12 | private: 13 | int m_a; 14 | }; 15 | 16 | int main(int, const char**) 17 | { 18 | Hoge hoge(42); 19 | std::cout << hoge.getA() << std::endl; 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /testdata/test.hpp: -------------------------------------------------------------------------------- 1 | 2 | int f(); 3 | -------------------------------------------------------------------------------- /testdata/test2.c: -------------------------------------------------------------------------------- 1 | // aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 2 | // 3 | #include "test2.h" 4 | 5 | int foge() 6 | { 7 | return 42; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /testdata/test2.h: -------------------------------------------------------------------------------- 1 | // test2.h 2 | // aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 | 4 | #if(__GNUC__>4 ||(__GNUC__==4 && __GNUC_MINOR__>=3))&&defined(__GXX_EXPERIMENTAL_CXX0X__) 5 | #endif --------------------------------------------------------------------------------