Repository navigation
150 lines (146 loc) · 4.98 KB
/
Copy pathruby.yml
File metadata and controls
150 lines (146 loc) · 4.98 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# 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: CI
on: [pull_request]
jobs:
linters:
name: Linters
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Ruby
uses: ruby/setup-ruby@v1
- name: Ruby gem cache
uses: actions/cache@v4
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Install gems
run: |
bundle config path vendor/bundle --local build.sassc --disable-march-tune-native
bundle install --jobs 4 --retry 3
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 15.5.0
- name: Find yarn cache location
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: JS package cache
uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install packages
run: |
yarn install --pure-lockfile
- name: Copy database.yml
run: cp config/database.yml.example config/database.yml
- name: Run Code Quality checks
run: |
bundle exec rake code_analysis
yarn lint
tests:
name: Tests
runs-on: ubuntu-latest
services:
db:
image: postgres:12
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: github_analyzer_test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
CODE_CLIMATE_API_URL: https://api.codeclimate.com/v1
CODE_CLIMATE_API_ORG_NAME: rootstrap
GITHUB_ORGANIZATION: rootstrap
SLACK_WEBHOOK_URL: https://hooks.slack.com/services/abc
PGHOST: localhost
PGUSER: postgres
PGPASSWORD: postgres
RAILS_ENV: test
JIRA_ENVIRONMENT_FIELD: customfield_10000
SENDGRID_USERNAME: metrics@example.com
ENGINEERING_METRICS_URL: http://engineering-metrics.com/
SONAR_PROJECT_KEY: ${{ secrets.SONAR_PROJECT_KEY }}
SONAR_URL: ${{ secrets.SONAR_URL }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Ruby
uses: ruby/setup-ruby@v1
- name: Ruby gem cache
uses: actions/cache@v4
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Install gems
run: |
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 15.5.0
- name: Find yarn cache location
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: JS package cache
uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install packages
run: |
yarn install --pure-lockfile
- name: Install PostgreSQL 12 client
run: |
sudo apt-get -yqq install libpq-dev
- name: Install dependencies
run: bundle install
- name: Copy database.yml
run: cp config/database.yml.example config/database.yml
- name: Setup Database
run: |
bundle exec rails db:setup
- name: Run tests
run: |
bundle exec rspec
- name: Run Sonarqube analysis
uses: SonarSource/sonarqube-scan-action@v4
env:
SONAR_HOST_URL: ${{ secrets.SONAR_URL }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dsonar.qualitygate.wait=true
-Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY }}
-Dsonar.scm.provider=git
-Dsonar.projectVersion=${{ github.sha }}
-Dsonar.sources=app/controllers,app/jobs,app/mailers,app/models,app/views
-Dsonar.tests=spec
-Dsonar.test.inclusions=**/*_spec.rb
-Dsonar.test.exclusions=bin,config,db,app/javascript,app/assets
-Dsonar.projectBaseDir=.
-Dsonar.ruby.coverage.reportPaths=coverage/coverage.json