-
Notifications
You must be signed in to change notification settings - Fork 0
179 lines (149 loc) · 4.71 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: CI
on:
push:
permissions:
contents: read
pull-requests: write
jobs:
rspec:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
ports: ["3306:3306"]
options: --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 10
env:
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
steps:
- uses: actions/checkout@v4
- name: Use ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: use-chromedriver
uses: nanasess/setup-chromedriver@v2
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version-file: "ember/todo-app/package.json"
- name: Setup Rails
env:
RAILS_ENV: test
run: |
gem install bundler --no-document
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
cp config/.ci.database.yml config/database.yml
bin/rails db:setup
- name: Setup Ember.js App
env:
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
run: |
cd ember/todo-app
yarn
yarn run ember build
- name: Setup Code Climate 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: CodeClimate prebuild
env:
CC_TEST_REPORTER_ID: ${{ secrets.CODE_CLIMATE_REPORTER_ID }}
run: ./cc-test-reporter before-build
- name: Run RSpec
env:
RAILS_ENV: test
TZ: Asia/Tokyo
CI: true
CC_TEST_REPORTER_ID: ${{ secrets.CODE_CLIMATE_REPORTER_ID }}
DISPLAY: ':99'
run: |
bundle exec rspec -f j -o tmp/rspec_results.json -f p
- name: Format rspec result
run: ./cc-test-reporter format-coverage -o tmp/cc.rspec.json
- name: 'Upload cc.rspec.json'
uses: actions/upload-artifact@v3
with:
name: cc-rspec
path: tmp/cc.rspec.json
retention-days: 1
- name: Report RSpec result
uses: SonicGarden/rspec-report-action@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
json-path: tmp/rspec_results.json
if: always()
ember-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version-file: "ember/todo-app/package.json"
- name: Setup Ember.js App
env:
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
run: |
cd ember/todo-app
yarn
yarn run ember build
- name: Setup Code Climate 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: CodeClimate prebuild
env:
CC_TEST_REPORTER_ID: ${{ secrets.CODE_CLIMATE_REPORTER_ID }}
run: ./cc-test-reporter before-build
- name: Run Ember test
env:
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
run: |
cd ember/todo-app && COVERAGE=true yarn run ember test
sleep 3
- name: Format ember test result
run: cd ember/todo-app && ../../cc-test-reporter format-coverage -o ../../tmp/cc.ember.json --add-prefix ember/todo-app -t lcov
- name: 'Upload cc.ember.json'
uses: actions/upload-artifact@v3
with:
name: cc-ember
path: tmp/cc.ember.json
retention-days: 1
after-build:
needs: [rspec, ember-test]
runs-on: ubuntu-latest
steps:
- name: Download rspec artifact
uses: actions/download-artifact@v3
with:
name: cc-rspec
path: tmp
- name: Download ember artifact
uses: actions/download-artifact@v3
with:
name: cc-ember
path: tmp
- name: Setup Code Climate 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: Upload test results to CodeClimate
env:
CC_TEST_REPORTER_ID: ${{ secrets.CODE_CLIMATE_REPORTER_ID }}
run: |
./cc-test-reporter sum-coverage tmp/cc.*.json -p 2 -o tmp/cc.total.json
./cc-test-reporter upload-coverage -i tmp/cc.total.json
- name: Notify slack build result
uses: lazy-actions/slatify@master
if: always()
with:
type: ${{ job.status }}
job_name: '*after-build*'
mention: 'here'
username: 'GitHub Actions'
mention_if: 'failure'
channel: '#ember-rails-todo-app'
url: ${{ secrets.SLACK_WEBHOOK }}
commit: true
token: ${{ secrets.GITHUB_TOKEN }}