rootstrap/rsgem

View on GitHub
lib/rsgem/support/github_actions.yml

Summary

Maintainability
Test Coverage
name: ci

on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        ruby_version: [2.5.x, 2.6.x, 2.7.x]

    steps:
    - uses: actions/checkout@v2
    - name: Set up Ruby
      uses: actions/setup-ruby@v1
      with:
        ruby-version: ${{ matrix.ruby_version }}
    - name: Calculate variable dynamic values
      id: dynamic_values
      run: |
        echo "::set-output name=installed_ruby_version::$(ruby -e 'print RUBY_VERSION')"
        echo "::set-output name=cacheTimeAnchor::$(ruby -e 'require %Q{date}; cacheExpirationSeconds = 60*60*24; print (Time.now.to_i / cacheExpirationSeconds)')"
    - name: Download CodeClimate reporter
      run: |
        curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
        chmod +x ./cc-test-reporter
        ./cc-test-reporter before-build
      env:
        CC_TEST_REPORTER_ID: get_a_test_reporter_id_from_code_climate
    - name: Install and config bundler
      run: |
        gem install bundler:2.1.4
    - name: Generate 'Gemfile.lock' before caching gems
      run: |
        bundle lock --update
    - uses: actions/cache@v2
      with:
        path: vendor/bundle
        key: ${{ runner.os }}-ruby_v${{ steps.dynamic_values.outputs.installed_ruby_version }}-time_${{steps.dynamic_values.outputs.cacheTimeAnchor}}-gems-${{ hashFiles('**/Gemfile.lock') }}
    - name: Install dependencies
      run: |
        bundle config set path 'vendor/bundle'
        bundle install --jobs 4 --retry 3
    - name: Run code analysis
      run: |
        bundle exec rake code_analysis
    - name: Run tests
      run: |
        bundle exec rspec
    - name: Report to CodeClimate
      run: |
        ./cc-test-reporter after-build --exit-code 0
      env:
        CC_TEST_REPORTER_ID: get_a_test_reporter_id_from_code_climate