はじめに
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
等のオプションを追加で指定したりします。)
おまけ
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のオプション
参考