Codeminer42/Punchclock

View on GitHub
.github/workflows/ruby.yml

Summary

Maintainability
Test Coverage
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby

name: CI

on:
  push:
    branches: [master]
  pull_request:
    branches: [master]

jobs:
  test:
    runs-on: ubuntu-latest
    env:
      CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
      RAILS_ENV: test
      POSTGRES_PASSWORD: postgres
    services:

      postgres:
        image: postgres:13
        ports:
          - 5432:5432
        env:
          POSTGRES_USER: postgres
          POSTGRES_PASSWORD: postgres
        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

    strategy:
      matrix:
        ruby-version: ["3.1.4"]
    steps:
      - uses: actions/checkout@v2
      - name: Install dependent libraries
        run: sudo apt-get install libpq-dev
      - name: Setup node
        uses: actions/setup-node@v2
        with:
          node-version: 16.13.1
          cache: "yarn"
      - name: Set up Ruby
        uses: ruby/setup-ruby@master
        with:
          ruby-version: ${{ matrix.ruby-version }}
          bundler-cache: true # runs 'bundle install' and caches installed gems automatically
      - name: Setup Database
        run: |
          cp config/database.yml.example config/database.yml
          bundle exec rake db:create
          bundle exec rake db:schema:load
      - name: "Install js packages"
        run: "yarn install"
      - name: "Check the seeds load"
        run: |
          bundle exec rake db:seed
          bundle exec rake db:schema:load
      - name: Precompile assets
        run: bundle exec rake assets:precompile
      - name: Run tests
        run: bundle exec rake
      - name: Test Coverage Report
        uses: paambaati/codeclimate-action@v3.0.0