-
Notifications
You must be signed in to change notification settings - Fork 6
/
config.yml
105 lines (101 loc) · 3.1 KB
/
config.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
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
version: 2
defaults: &defaults
working_directory: ~/repo
docker:
- image: cimg/ruby:2.7.4-browsers
environment:
JOBS: 2
RAILS_ENV: test
PGHOST: 127.0.0.1
PGUSER: root
LOCAL_TEST_DB_NAME: circle-ci_test
DATABASE_URL: "postgres://root@localhost:5432/circle-ci_test"
- image: cimg/postgres:10.18
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: password
POSTGRES_DB: circle-ci_test
jobs:
setup-code-coverage:
<<: *defaults
steps:
- run:
name: Download CodeClimate Reporter
command: |
mkdir -p tmp/
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./tmp/cc-test-reporter
chmod +x ./tmp/cc-test-reporter
- persist_to_workspace:
root: tmp
paths:
- cc-test-reporter
rails:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: ~/repo/tmp
- restore_cache:
keys:
- rails-template-{{ checksum "Gemfile.lock" }}
- rails-template-
- run:
name: Install dependencies
command: |
gem install bundler -v $(cat Gemfile.lock | tail -1 | tr -d ' ')
bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs 4 --retry 3
- save_cache:
key: rails-template-{{ checksum "Gemfile.lock" }}
paths:
- ./vendor/bundle
- run:
name: Database Setup
command: |
bundle exec rails db:create db:schema:load --trace
bundle exec rake db:migrate
- run:
name: Run Brakeman
command: |
sudo mkdir /brakeman && bundle update brakeman --quiet
mkdir -p $CIRCLE_TEST_REPORTS/brakeman
bundle exec brakeman --exit-on-warn
- run:
name: Run Rubopcop
command: |
sudo mkdir /rubocop && bundle update rubocop --quiet
mkdir -p $CIRCLE_TEST_REPORTS/rubocop
bundle exec rubocop --fail-fast --fail-level E
- run:
name: Run Tests
command: |
bundle exec rspec
- run:
name: Format Coverage Data
command: |
./tmp/cc-test-reporter format-coverage --debug -t simplecov -o tmp/codeclimate.rails-template.json ./rails-template/coverage/.resultset.json
- persist_to_workspace:
root: tmp
paths:
- codeclimate.rails-template.json
send-code-coverage:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: ~/repo/tmp
- run:
name: Send to CodeClimate
command: |
./tmp/cc-test-reporter sum-coverage tmp/codeclimate.*.json -o tmp/codeclimate.total.json
./tmp/cc-test-reporter upload-coverage -i tmp/codeclimate.total.json
workflows:
version: 2
run_tests:
jobs:
- setup-code-coverage
- rails:
requires:
- setup-code-coverage
- send-code-coverage:
requires:
- rails