これはなにか
GitHub に push すると GitHub Actions がブンブン回って、静的コード解析をしてくれるやつ。ついでにキャッシュされるので、毎回 bundle install がまわることがないやつ。はやい、やすい、うまい ... かどうかはわからないが、要はオレによし、オマエによし。
ワークフロー
name: Static Check
on: [push]
jobs:
RuboCop:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-ruby@v1
with:
ruby-version: '2.7'
- uses: actions/checkout@v2
- uses: actions/cache@preview
with:
path: ./web/vendor/bundle
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gem-
- name: Run RuboCop
run: |
cd ./web/
bundle install --jobs 4 --retry 3 --path vendor/bundle
bundle exec rubocop -a
BrakeMan:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-ruby@v1
with:
ruby-version: '2.7'
- uses: actions/checkout@v2
- uses: actions/cache@preview
with:
path: ./web/vendor/bundle
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gem-
- name: Run BrakeMan
run: |
cd ./web/
bundle install --jobs 4 --retry 3 --path vendor/bundle
bundle exec rubocop -a
RubyCritic:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-ruby@v1
with:
ruby-version: '2.7'
- uses: actions/checkout@v2
- uses: actions/cache@preview
with:
path: ./web/vendor/bundle
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gem-
- name: Run BrakeMan
run: |
cd ./web/
bundle install --jobs 4 --retry 3 --path vendor/bundle
bundle exec rubycritic
おわりに
ほんとは Docker 化しているのだから、Docker 上で動かせば良いのだろうけど Docker イメージの置き場所とか考えると、めんどくさくなったのでこうした。次は GitHub Actions で Docker image をロードして CI するやつでもつくろうかな。