7
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

GitHub Actionsでreviewdogにpylintしてもらってみた

Last updated at Posted at 2020-09-30

この記事について

GitHub Actionsでreviewdog + pylintを連携してみたので、その記録です。
やってみた系記事ですのであまり詳しい説明などはありませんが、どなたかの参考になれば幸いです。

この記事には書いていないこと

GitHub Actionsやreviewdogそのものの説明はこの記事では行いません。
リンクを貼っておきますので、詳しく知りたい方はお手数ですがそちらをご確認ください。

ちなみに、linterによってはMarketplaceに既に用意があったりするので、覗いてみるのも良いと思います!

コード

とりあえずコードが見たい、というあなたにはこちらをどうぞ!
このコードでは、functions/ディレクトリにpylintしたいコードが「ぺけぺけ.py」なファイル名で置いてあることになっています。ディレクトリ構成やnamebranches、もろもろのバージョンなんかは適宜お使いの環境に合わせて変更してくださいね。
コードがイイ感じに書けたら、.github/workflows/配下に格納しましょう。

.github/workflows/reviewdog.yml

name: reviewdog
on: 
  pull_request:
    branches:
      - develop
jobs:
  reviewdog:
    name: reviewdog
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1

      - name: Set up Python 3.8
        uses: actions/setup-python@v1
        with:
          python-version: 3.8

      - name: Setup pylint
        run: |
          python -m pip install --upgrade pip
          pip install pylint
          pylint --generate-rcfile > ~/.pylintrc

      - name: Setup reviewdog
        run: |
          mkdir -p $HOME/bin && curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s -- -b $HOME/bin
          echo ::add-path::$HOME/bin

      - name: Run reviewdog
        env:
          REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          pylint --rcfile=~/.pylintrc functions/*.py | reviewdog -efm="%f:%l:%c: %m" -reporter=github-pr-review

何が起きるの?

functions/配下にhello.pyを格納して、developブランチにプルリクを出してみました。
さて、どうなるかな...?

pylint_reviewdog_pr01.png

おっ、何か動いてますね!
少し待っていると...

pylint_reviewdog_pr02.png

じゃん!
こんな感じで、pylintで引っかかった部分をコメントとして表示してくれます。
ワンちゃんがとってもかわいいですね🐶 引っかかった悲しみも癒してくれそうな気がします。

終わりに

いかがでしたでしょうか。
今回はGitHub Actionsで動かしてみましたが、reviewdogはローカルでも動作しますので、興味のある方は試してみてくださいね。

それでは!

7
2
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
7
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?