mmcs-ruby/silicium

View on GitHub
.github/workflows/workflow.yaml

Summary

Maintainability
Test Coverage
name: Silicium Workflow

on:
  push:
  pull_request:
    branches:
      - main
      - master

jobs:
  run_tests:
    runs-on: ubuntu-20.04
    env:
      CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-ruby@v1
        with:
          ruby-version: 2.6
      - name: Install Environment Dependencies
        run: |
          gem install bundler -v 2.0.2
          sudo apt-get update
          sudo apt-get -y install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev
      - name: Install Codeclimate
        run: |
          curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
          chmod +x ./cc-test-reporter
      - name: Before-build Codeclimate
        run: ./cc-test-reporter before-build
      - uses: actions/cache@v2
        with:
          path: vendor/bundle
          key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
          restore-keys: |
            ${{ runner.os }}-gems-
      - name: Bundle Install
        run: |
          bundle config path vendor/bundle
          bundle install --jobs 4 --retry 3
      - name: Run Tests
        run: bundle exec rake test
      - name: After-build Codeclimate
        run: ./cc-test-reporter after-build

  deploy_gem:
    needs: run_tests
    runs-on: ubuntu-20.04
    if: startsWith(github.ref, 'refs/tags/v')
    env:
      GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-ruby@v1
        with:
          ruby-version: 2.6.3
      - name: Publish to rubygems
        # we only need what comes after "refs/tags/v" part as version
        run: |
          export SILICIUM_VERSION=${GITHUB_REF:11}
          gem push silicium-$SILICIUM_VERSION.gem