justinhoward/strudel

View on GitHub
.github/workflows/ci.yml

Summary

Maintainability
Test Coverage
---
name: CI
on:
  push:
    tags: ['v*']
    branches: [master]
  pull_request:
    branches: ['**']
jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        ruby:
          - '2.3'
          - '2.4'
          - '2.5'
          - '2.6'
          - '2.7'
          - '3.0'
          - '3.1'
          - '3.2'
          - jruby-head
          - truffleruby-head
    steps:
      - uses: actions/checkout@v2
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: ${{ matrix.ruby }}
          bundler-cache: true
      - run: bundle exec rspec --format doc
      - uses: codecov/codecov-action@v3
        if: matrix.ruby == '3.2'
        with:
          files: coverage/coverage.xml

  rubocop:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: '3.2'
          bundler-cache: true
      - run: bundle exec rubocop

  yard:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: '3.2'
          bundler-cache: true
      - run: bin/yardoc --fail-on-warning

  check_version:
    runs-on: ubuntu-latest
    if: startsWith(github.ref, 'refs/tags/v')
    steps:
      - uses: actions/checkout@v3
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: '3.2'
          bundler-cache: true
      - run: bin/check-version

  release:
    needs: [test, rubocop, yard, check_version]
    if: startsWith(github.ref, 'refs/tags/v')
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Publish to RubyGems
        run: |
          mkdir -p $HOME/.gem
          touch $HOME/.gem/credentials
          chmod 0600 $HOME/.gem/credentials
          printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
          gem build *.gemspec
          gem push *.gem
        env:
          GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_API_KEY}}"