LoginSignup
6
1

More than 3 years have passed since last update.

GitHub Actionsでcpplintを使ってみた

Posted at

はじめに

GitHub Actionsを試しに使ってみたので備忘録程度に書きます。

GitHub Actions とは

GitHub標準のCI/CD機能。
GitHub上で発生するイベントをトリガーに、任意のアクションを実行できます。

cpplint とは

Google C++ Style Guide にそったコーディングスタイルで書かれているかチェックする静的解析ツール。

とはいえ、全て上記スタイルに適用させたいわけではないと思うのでfilterオプションを使い必要なものだけチェックするのが良いです。

# 例
cpplint --filter=-legal,-runtime/references --recursive .

workflow

https://github.com/cpplint/GitHub-Action-for-cpplint
cpplintで紹介されてたものをそのまま引用させていただきます。

リポジトリに .github/workflows/cpplint.yml ファイルを作成。(ファイル名はなんでもいい)

cpplint.yml
name: cpplint
on: [push, pull_request]
jobs:
  cpplint:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - uses: actions/setup-python@v1
    - run: pip install cpplint
    - run: cpplint --recursive .

上記の場合はpushしたときとプルリクを作成したときをトリガーにcpplintが走ることになります。
(実際には先ほど述べたようにfilter等のオプションを追加で指定したりします。)

実行結果はGitHub上で確認できます。
2020-02-10.png

おまけ

Marketplaceで検索するとすでに用意されたアクションが見つかるので、特に問題なければそれを使用するのが楽です。

cpplint.yml
name: cpplint
on: [push, pull_request]
jobs:
  cpplint:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: action-cpp-lint
      uses: CyberZHG/github-action-cpp-lint@0.0.2
      with:
        args: --recursive . # cpplintのオプション

参考

6
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
1