openaustralia/planningalerts

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, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    services:
      # We're using postgres 15.2 in production currently
      postgres:
        image: postgis/postgis:15-3.3
        ports:
          - 5432:5432
        env:
          POSTGRES_PASSWORD: postgres
        # Set health checks to wait until postgres has started
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
      redis:
        image: redis
        ports:
          - 6379:6379
         # Set health checks to wait until redis has started
        options: >-
          --health-cmd "redis-cli ping"
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5       
    env:
      RAILS_ENV: test
      DATABASE_URL: "postgis://postgres:postgres@localhost:5432/rails_test"
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      - uses: actions/setup-node@v3
        with:
          node-version: '14'
      - run: npm install --save-dev @percy/cli
      # Add or replace dependency steps here
      - name: Install Ruby and gems
        uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true
      # Add or replace database setup steps here
      - name: Create database
        run: bin/rails db:create
      - name: Set up database schema
        run: bin/rails db:schema:load
      # Add or replace test runners here
      - name: Run tests
        run: npx percy exec -- bin/rake
        env:
          PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
  type_check:
    runs-on: ubuntu-latest
    services:
      # We're using postgres 15.2 in production currently
      postgres:
        image: postgis/postgis:15-3.3
        ports:
          - 5432:5432
        env:
          POSTGRES_PASSWORD: postgres
        # Set health checks to wait until postgres has started
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
    env:
      # TODO: Don't run in test environment so we don't need --environment=test below
      RAILS_ENV: test
      DATABASE_URL: "postgis://postgres:postgres@localhost:5432/rails_test"
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      - name: Install Ruby and gems
        uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true
      - name: Create database
        run: bin/rails db:create
      - name: Set up database schema
        run: bin/rails db:schema:load
      - name: Type check rake task
        run: bin/rake ci:type

  lint:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      - name: Install Ruby and gems
        uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true
      - name: Lint rake task
        run: bin/rake ci:lint