Flockingbird/roost

View on GitHub
.github/workflows/test.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: Test

on:
  push:
    branches: [ main, develop ]
  pull_request_target:
    types: [labeled]

jobs:
  test:

    runs-on: ubuntu-latest
    if: contains(github.event.pull_request.labels.*.name, 'safe to test')

    ## We don't need encrypted secrets yet for booting a temp database container.
    env:
      APP_ENV: test
      MAIL_METHOD: test
      JWT_SECRET: 's3cr37'
      PORT: 3000
      DB_USER: postgres
      DB_HOST: localhost
      DB_PASSWORD: 'postgres'
      DB_NAME: roost_test
      DB_PORT: 5432
      DATABASE_URL: postgres://postgres:postgres@localhost:5432/roost_test

    services:
      postgres:
        image: postgres
        env:
          POSTGRES_PASSWORD: 'postgres'
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
        ports:
          - 5432:5432

    steps:
    - uses: actions/checkout@v2
      # Please refer to https://securitylab.github.com/research/github-actions-preventing-pwn-requests
      # for issues this can cause. We mitigate it with requiring a tag to be set. Which only maintainers can add.
      with:
        ref: ${{ github.event.pull_request.head.sha }}
    - name: Set up Ruby
      uses: ruby/setup-ruby@v1
      with:
        ruby-version: 2.6
    - name: Install Dependencies
      run: bundle install
    - name: Setup Database
      run: make _db-setup
    - name: Run tests and upload coverage results
      uses: paambaati/codeclimate-action@v2.7.4
      with:
        coverageCommand: make
      env:
        CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}