-
Notifications
You must be signed in to change notification settings - Fork 1
62 lines (52 loc) · 2.13 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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
- name: Update coverage output
run: |
sed -i "s@/home/runner/work/DEFRA/pafs_core@/github/workspace@g" coverage/coverage.json
- name: Analyze with SonarCloud
uses: sonarsource/sonarqube-scan-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