BathHacked/energy-sparks

View on GitHub
.github/workflows/rubyonrails.yml

Summary

Maintainability
Test Coverage
name: "Ruby on Rails CI"
on:
  push:
    branches: [ master, aws-eb-test, aws-eb-master ]
  pull_request:
jobs:
  rspec:
    runs-on: ubuntu-latest
    services:
      postgres:
        image: postgres:14
        ports:
          - "5432:5432"
        env:
          POSTGRES_DB: rails_test
          POSTGRES_USER: rails
          POSTGRES_PASSWORD: password
    strategy:
      fail-fast: false
      matrix:
        # limited to 20
        # https://docs.github.com/en/actions/learn-github-actions/usage-limits-billing-and-administration#usage-limits
        ci_node_total: [19] # leave 1 spare for overcommit
        ci_node_index: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
    env:
      RAILS_ENV: test
      DATABASE_URL: "postgres://rails:password@localhost:5432/rails_test"
      CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
      CI_NODE_INDEX: ${{ matrix.ci_node_index }}
    steps:
      - uses: actions/checkout@v3
      - uses: ./.github/actions/setup
      # https://github.com/actions/download-artifact/issues/3
      - run: gh run download --name knapsack_rspec_report --dir ${{ github.workspace }}
        env:
          GH_TOKEN: ${{ github.token }}
      # https://docs.knapsackpro.com/ruby/knapsack
      # run this locally to update timing file - KNAPSACK_GENERATE_REPORT=true bundle exec rspec
      - run: bundle exec rake knapsack:rspec
  overcommit:
    runs-on: ubuntu-latest
    env:
      BUNDLE_GEMFILE: .overcommit_gems.rb
    steps:
      - uses: actions/checkout@v3
      - uses: ./.github/actions/setup
        with:
          ruby-only: true
      # Fail early if we have issues with translation keys
      - run: bundle exec i18n-tasks health
      - run: bundle exec overcommit --sign && bundle exec overcommit --run
        env:
          GIT_AUTHOR_NAME: Over Commit
          GIT_AUTHOR_EMAIL: overcommit@localhost
          # ForbiddenBranches fails when triggered by master push
          # ErbLint has too many failures right now
          SKIP: ForbiddenBranches,ErbLint
      - run: bundle exec brakeman . --no-progress --no-exit-on-warn -o /dev/stdout -o tmp/brakeman.txt
      - run: "grep 'Security Warnings: 20' tmp/brakeman.txt"