autolab/Autolab

View on GitHub
.github/workflows/rubyonrails.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 install a prebuilt Ruby version, install dependencies, and
# run tests and linters.
name: "Ruby on Rails CI"
on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]
  merge_group:
    branches: [ master ]
jobs:
  lint:
    runs-on: ubuntu-latest
    
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      
      - name: Install Ruby
        uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true
          cache-version: 3
          
      - name: Rubocop
        run: bundle exec rubocop

      - name: Erblint
        run: bundle exec erblint --lint-all

  test:
    runs-on: ubuntu-latest

    env:
      RESTFUL_HOST: localhost
      RESTFUL_PORT: 3000
      RESTFUL_KEY: test_key

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Install Ruby
        uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true
          cache-version: 3

      - name: Set up Autolab
        run: |
          cp config/database.github.yml config/database.yml
          cp config/school.yml.template config/school.yml
          cp config/autogradeConfig.rb.template config/autogradeConfig.rb
          cp .env.template .env
          mkdir tmp/

      - name: Set up database
        run: |
          sudo /etc/init.d/mysql start
          RAILS_ENV=development bundle exec rails db:create
          ./bin/initialize_secrets.sh
          RAILS_ENV=test bundle exec rails autolab:setup_test_env

      - name: Run tests
        run: bundle exec rails spec