RSpec を GitHub Actions で動かす

.github/workflows/rspec.yml (ファイル名は任意)に以下のような感じで書く。

name: RSpec
on:
  pull_request:
    types: [opened, synchronize]
jobs:
  rspec:
    runs-on: ubuntu-latest

    services:
      db:
        image: mysql:5.7
        ports:
          - "3306:3306"
        env:
          MYSQL_ROOT_PASSWORD: password

    steps:
      - uses: actions/checkout@v1
      - uses: ruby/setup-ruby@v1 # .ruby_version の ruby が使われる
        with:
          bundler-cache: true
      - run: bundle exec rails db:create db:migrate
      - run: COVERAGE=1 bundle exec rspec -f j -o tmp/rspec_results.json -f p
      - uses: SonicGarden/rspec-report-action@v1
        with:
          json-path: tmp/rspec_results.json
          token: ${{ secrets.GITHUB_TOKEN }}
        if: ${{ always() }}
      - uses: aki77/simplecov-report-action@v1
        with:
          failedThreshold: 70
          token: ${{ secrets.GITHUB_TOKEN }}