ryancyq/rodiff

View on GitHub
.github/workflows/coverage.yml

Summary

Maintainability
Test Coverage
name: Code Coverage
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
  schedule:
    - cron: '0 12 * * 5'

jobs:
  coverage:
    name: "Ruby ${{ matrix.ruby-version }}"
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        ruby-version: 
          - "2.7"
          - "3.0"
          - "3.1"
          - "3.2"
          - "3.3"
          - "head"
    timeout-minutes: 3
    
    steps:
      - uses: actions/checkout@v4

        # https://bundler.io/blog/2018/01/17/making-gem-development-a-little-better.html
      - run: rm Gemfile.lock

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: ${{ matrix.ruby-version }}
          rubygems: 3.4.22 # last version to support Ruby 2.7
          bundler-cache: true

      - run: bundle exec rake coverage:run

      - run: sudo apt install tree
      - run: tree -a coverage

      - uses: actions/upload-artifact@v4
        with:
          name: "coverage-ruby-${{ matrix.ruby-version }}"
          path: coverage/ruby-*
          include-hidden-files: true
          retention-days: 1

  report:
    name: "CodeCov (Ruby ${{ matrix.ruby-version }})"
    needs: [coverage]
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        ruby-version: 
          - "2.7"
          - "3.0"
          - "3.1"
          - "3.2"
          - "3.3"
          - "head"
    timeout-minutes: 3

    steps:
      - uses: actions/checkout@v4

      - uses: actions/download-artifact@v4
        with:
          pattern: "coverage-ruby-${{ matrix.ruby-version }}*"
          path: coverage

      - run: sudo apt install tree
      - run: tree -a coverage

      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v4
        with:
          directory: coverage
          token: ${{ secrets.CODECOV_TOKEN }}
          flags: "ruby-${{ matrix.ruby-version }}"
          fail_ci_if_error: true