Skip to content

Merge pull request #703 from DEFRA/feature/RUBY-2445-pafs-bau-back-of… #795

Merge pull request #703 from DEFRA/feature/RUBY-2445-pafs-bau-back-of…

Merge pull request #703 from DEFRA/feature/RUBY-2445-pafs-bau-back-of… #795

Workflow file for this run

name: CI
on: push
jobs:
build:
runs-on: ubuntu-latest
env:
PG_HOST: localhost
PG_USERNAME: postgres
PG_PASSWORD: postgres
PG_PORT: 5432
SECRET_KEY_BASE: somescarylongvaluefullofnumbersandlettersi
services:
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: pafs_core_dummy_test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
# Run linting first. No point running the tests if there is a linting issue
- name: Run lint check
run: |
bundle exec rubocop --format progress --format json --out rubocop-result.json
- name: Database setup
run: |
RAILS_ENV=test bundle exec rake db:create --trace --trace
RAILS_ENV=test bundle exec rake db:schema:load --trace --trace
# This includes an extra run step. The sonarcloud analysis will be run in a docker container with the current
# folder mounted as `/github/workspace`. The problem is when the coverage.json file is generated it will
# reference the code in the current folder. So to enable sonarcloud to matchup code coverage with the files we use
# sed to update the references in coverage.json
# https://community.sonarsource.com/t/code-coverage-doesnt-work-with-github-action/16747/6
- name: Run unit tests
run: |
bundle exec rspec
sed -i 's/\/home\/runner\/work\/pafs_core\/pafs_core\//\/github\/workspace\//g' coverage/coverage.json
- name: Analyze with SonarCloud
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This is provided automatically by GitHub
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # This needs to be set in your repo; settings -> secrets