-
Notifications
You must be signed in to change notification settings - Fork 3
133 lines (104 loc) · 3.56 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
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
name: CI
on:
push:
branches: [master]
env:
# CodeClimate only shows coverage for the default branch
# As this action is only triggered by tags, assume the branch is 'master'
GIT_BRANCH: master
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
jobs:
setup:
name: Setup test coverage reporting
runs-on: ubuntu-latest
steps:
- name: Download CodeClimate test reporter
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
- name: Notify CodeClimate of a pending report
run: ./cc-test-reporter before-build
frontend:
name: Test and lint frontend
needs: setup
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v4
with:
node-version-file: .tool-versions
cache: npm
- name: Install dependencies
run: npm ci
- name: Lint and test
run: npm test
- name: Upload test coverage artifact
uses: actions/upload-artifact@v4
with:
name: lcov.info
path: coverage/frontend/lcov.info
backend:
name: Lint and test backend
needs: setup
runs-on: ubuntu-latest
env:
RAILS_ENV: test
DATABASE_URL: postgresql://postgres@localhost
BUNDLE_WITHOUT: production
services:
postgres:
image: postgres:11.3
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install ruby and gem dependencies
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Setup database
run: bundle exec rake db:create db:migrate
- name: Lint
run: bundle exec rubocop
- name: Scan
run: bundle exec brakeman
- name: Test
run: bundle exec rake
- name: Upload test coverage artifact
uses: actions/upload-artifact@v4
with:
name: coverage.json
path: coverage/backend/coverage.json
report:
name: Send coverage report to CodeClimate
needs: [frontend, backend]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download CodeClimate test reporter
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
- name: Download frontend test coverage artifact
uses: actions/download-artifact@v4
with:
name: lcov.info
path: coverage/frontend
- name: Download backend test coverage artifact
uses: actions/download-artifact@v4
with:
name: coverage.json
path: coverage/backend
- name: Format backend coverage
run: ./cc-test-reporter format-coverage --input-type simplecov --output coverage/codeclimate.backend.json coverage/backend/coverage.json
- name: Format frontend coverage
run: ./cc-test-reporter format-coverage --input-type lcov --output coverage/codeclimate.frontend.json coverage/frontend/lcov.info
- name: Merge backend and frontend coverage
run: ./cc-test-reporter sum-coverage --parts 2 coverage/codeclimate.*.json
- name: Upload coverage report
run: ./cc-test-reporter upload-coverage