name: Ruby

on:
  push:
    branches: [ master ]
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        ruby-version: ['2.7', '3.0']

    steps:
    - uses: actions/checkout@v2
    - name: Set up Ruby
      uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
      with:
        ruby-version: ${{ matrix.ruby-version }}
        bundler-cache: true # runs 'bundle install' and caches installed gems automatically
    - name: Remove test outputs for tests to generate
      run: rm -fr spec/output
    - name: Run Rspec tests
      run: bundle exec rspec
    - name: Check test outputs contain no diffs
      run: git add spec/output && git status && git diff --staged --exit-code -- spec/output || (echo "Test outputs contain changes. Run 'make' locally and check that the changes are desired. If they're desired, commit them as part of the change." && exit 1)

name: Ruby

on:
  push:
    branches: [ master ]
  pull_request:

jobs:

  complete:
    if: always()
    needs: [test]
    runs-on: ubuntu-latest
    steps:
    - if: contains(needs.*.result, 'failure')
      run: exit 1

  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        ruby-version: ['2.7', '3.0']

    steps:
    - uses: actions/checkout@v2
    - name: Set up Ruby
      uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
      with:
        ruby-version: ${{ matrix.ruby-version }}
        bundler-cache: true # runs 'bundle install' and caches installed gems automatically
    - name: Remove test outputs for tests to generate
      run: rm -fr spec/output
    - name: Run Rspec tests
      run: bundle exec rspec
    - name: Check test outputs contain no diffs
      run: git add spec/output && git status && git diff --staged --exit-code -- spec/output || (echo "Test outputs contain changes. Run 'make' locally and check that the changes are desired. If they're desired, commit them as part of the change." && exit 1)

Add complete CI job that acts as the signal all jobs are complete
Add complete CI job that acts as the signal all jobs are complete