質問編集履歴

5

しゅうせい

2020/09/20 06:56

投稿

keisuke.F
keisuke.F

スコア19

test CHANGED
File without changes
test CHANGED
@@ -12,37 +12,391 @@
12
12
 
13
13
  ```
14
14
 
15
- Config Processing Erorr(Don't rerun)
16
-
17
- #!/bin/sh -eo pipefail
18
-
19
- # Unable to parse YAML
20
-
21
- # while parsing a block mapping
22
-
23
- # in 'string', line 32, column 11:
24
-
25
- # name: install dependencies
26
-
27
- # ^
28
-
29
- # expected <block end>, but found '<scalar>'
30
-
31
- # in 'string', line 35, column 13:
32
-
33
- # gem install bundler -v 1.17.3
34
-
35
- # ^
36
-
37
- #
38
-
39
- # -------
40
-
41
- # Warning: This configuration was auto-generated to show you the message above.
42
-
43
- # Don't rerun this job. Rerunning will have no effect.
44
-
45
- false
15
+ #!/bin/bash -eo pipefail
16
+
17
+ bundle exec rake db:create
18
+
19
+ Unknown MySQL server host 'db' (-2)
20
+
21
+ Couldn't create 'LuggageMGT_test' database. Please check your configuration.
22
+
23
+ rake aborted!
24
+
25
+ ```
26
+
27
+
28
+
29
+ #試した事
30
+
31
+ bundlerのバージョン指定でエラーが出ている様で、bundlerをuninstallし、新たにインストールしました。
32
+
33
+
34
+
35
+ rspecはインストール済みです。
36
+
37
+
38
+
39
+ config.yml
40
+
41
+ ```
42
+
43
+ version: 2
44
+
45
+ jobs:
46
+
47
+ build:
48
+
49
+ docker:
50
+
51
+ - image: circleci/ruby:2.5.3-node-browsers
52
+
53
+ environment:
54
+
55
+ RAILS_ENV: 'test'
56
+
57
+
58
+
59
+ - image: circleci/mysql:5.6.47
60
+
61
+ environment:
62
+
63
+ MYSQL_ROOT_PASSWORD: "password"
64
+
65
+ MYSQL_ROOT_HOST: "%"
66
+
67
+
68
+
69
+ working_directory: ~/app_name
70
+
71
+
72
+
73
+ steps:
74
+
75
+ - checkout
76
+
77
+ - restore_cache: # キャッシュを読み込む
78
+
79
+ keys:
80
+
81
+ - gem-cache-v1-{{ checksum "Gemfile.lock" }}
82
+
83
+ - gem-cache-v1-
84
+
85
+
86
+
87
+ - run:
88
+
89
+ name: Bundle Install
90
+
91
+ command: bundle check --path vendor/bundle || bundle install --deployment
92
+
93
+
94
+
95
+ - save_cache: # キャッシュを保存する
96
+
97
+ key: gem-cache-v1-{{ checksum "Gemfile.lock" }}
98
+
99
+ paths:
100
+
101
+ - vendor/bundle
102
+
103
+
104
+
105
+ - run:
106
+
107
+ name: Wait for DB
108
+
109
+ command: dockerize -wait tcp://127.0.0.1:3306 -timeout 120s
110
+
111
+ - run: bundle exec rake db:create
112
+
113
+ - run: bundle exec rake db:schema:load
114
+
115
+ - run:
116
+
117
+ name: run tests
118
+
119
+ command: |
120
+
121
+ mkdir /tmp/test-results
122
+
123
+ TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
124
+
125
+ bundle exec rspec --format progress \
126
+
127
+ --out /tmp/test-results/rspec.xml \
128
+
129
+ --format progress \
130
+
131
+ $TEST_FILES
132
+
133
+ - store_test_results:
134
+
135
+ path: /tmp/test-results
136
+
137
+ - store_artifacts:
138
+
139
+ path: /tmp/test-results
140
+
141
+ destination: test-results
142
+
143
+
144
+
145
+ - add_ssh_keys:
146
+
147
+ fingerprints:
148
+
149
+ - "1f:d5:4b:1c:ed:c1:92:6e:47:a1:e0:18:a0:ff:27:ca"
150
+
151
+
152
+
153
+ - deploy:
154
+
155
+ name: Capistrano deploy
156
+
157
+ command: |
158
+
159
+ if [ "${CIRCLE_BRANCH}" != "master" ]; then
160
+
161
+ exit 0
162
+
163
+ fi
164
+
165
+ bundle exec cap production deploy unicorn:restart
166
+
167
+ ```
168
+
169
+
170
+
171
+ dockerfile
172
+
173
+ ```
174
+
175
+ FROM ruby:2.5.3
176
+
177
+ RUN apt-get update -qq && \
178
+
179
+ apt-get install -y build-essential \
180
+
181
+ libpq-dev \
182
+
183
+ nodejs
184
+
185
+
186
+
187
+ RUN mkdir /app_name
188
+
189
+ ENV APP_ROOT /app_name
190
+
191
+ WORKDIR $APP_ROOT
192
+
193
+
194
+
195
+ ADD ./Gemfile $APP_ROOT/Gemfile
196
+
197
+ ADD ./Gemfile.lock $APP_ROOT/Gemfile.lock
198
+
199
+
200
+
201
+ RUN bundle install
202
+
203
+ ADD . $APP_ROOT
204
+
205
+ ```
206
+
207
+
208
+
209
+ docker-compose.yml
210
+
211
+ ```
212
+
213
+ version: '3'
214
+
215
+
216
+
217
+ services:
218
+
219
+ web:
220
+
221
+ build: .
222
+
223
+ ports:
224
+
225
+ - "3000:3000"
226
+
227
+ links:
228
+
229
+ - db
230
+
231
+ tty: true
232
+
233
+ command: /bin/sh -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
234
+
235
+ volumes:
236
+
237
+ - .:/app_name
238
+
239
+ depends_on:
240
+
241
+ - db
242
+
243
+
244
+
245
+ db:
246
+
247
+ image: mysql:5.6.47
248
+
249
+ environment:
250
+
251
+ MYSQL_ROOT_PASSWORD: password
252
+
253
+ MYSQL_DATABASE: root
254
+
255
+ ports:
256
+
257
+ - "4306:3306"
258
+
259
+ volumes:
260
+
261
+ - ./tmp/db:/var/lib/mysql/data
262
+
263
+ volumes:
264
+
265
+ bundle:
266
+
267
+ mysql_data:
268
+
269
+ ```
270
+
271
+
272
+
273
+ database.yml.ci
274
+
275
+ ```
276
+
277
+ test:
278
+
279
+ adapter: mysql2
280
+
281
+ encoding: utf8
282
+
283
+ pool: 5
284
+
285
+ username: 'root'
286
+
287
+ port: 3306
288
+
289
+ host: '127.0.0.1'
290
+
291
+ database: LuggageMGT_test
292
+
293
+ ```
294
+
295
+
296
+
297
+
298
+
299
+
300
+
301
+ 下記コマンド実装結果です。
302
+
303
+ ```
304
+
305
+ name@mbp リポジトリ名 % bundler -v
306
+
307
+ Bundler version 1.17.3
308
+
309
+ ```
310
+
311
+
312
+
313
+
314
+
315
+ 追記です。
316
+
317
+
318
+
319
+ config.yml内の
320
+
321
+ ```
322
+
323
+ - run: mv config/database.yml.ci config/database.yml
324
+
325
+ ```
326
+
327
+
328
+
329
+ を削除したら、circleCIのエラーが変わりました。
330
+
331
+ 下記がエラーです。
332
+
333
+ ```
334
+
335
+ #!/bin/bash -eo pipefail
336
+
337
+ bundle exec rake db:create
338
+
339
+ Unknown MySQL server host 'db' (-2)
340
+
341
+ Couldn't create 'LuggageMGT_test' database. Please check your configuration.
342
+
343
+ rake aborted!
344
+
345
+ Mysql2::Error::ConnectionError: Unknown MySQL server host 'db' (-2)
346
+
347
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:90:in `connect'
348
+
349
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:90:in `initialize'
350
+
351
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/mysql2_adapter.rb:22:in `new'
352
+
353
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/mysql2_adapter.rb:22:in `mysql2_connection'
354
+
355
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:830:in `new_connection'
356
+
357
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:874:in `checkout_new_connection'
358
+
359
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:853:in `try_to_checkout_new_connection'
360
+
361
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:814:in `acquire_connection'
362
+
363
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:538:in `checkout'
364
+
365
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:382:in `connection'
366
+
367
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:1033:in `retrieve_connection'
368
+
369
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_handling.rb:118:in `retrieve_connection'
370
+
371
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_handling.rb:90:in `connection'
372
+
373
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/mysql_database_tasks.rb:6:in `connection'
374
+
375
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/mysql_database_tasks.rb:14:in `create'
376
+
377
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:119:in `create'
378
+
379
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:139:in `block in create_current'
380
+
381
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:316:in `block in each_current_configuration'
382
+
383
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:313:in `each'
384
+
385
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:313:in `each_current_configuration'
386
+
387
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:138:in `create_current'
388
+
389
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/railties/databases.rake:29:in `block (2 levels) in <top (required)>'
390
+
391
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
392
+
393
+ /usr/local/bundle/bin/bundle:23:in `load'
394
+
395
+ /usr/local/bundle/bin/bundle:23:in `<main>'
396
+
397
+ Tasks: TOP => db:create
398
+
399
+ (See full trace by running task with --trace)
46
400
 
47
401
 
48
402
 
@@ -51,385 +405,3 @@
51
405
  CircleCI received exit code 1
52
406
 
53
407
  ```
54
-
55
-
56
-
57
- #試した事
58
-
59
- bundlerのバージョン指定でエラーが出ている様で、bundlerをuninstallし、新たにインストールしました。
60
-
61
-
62
-
63
- rspecはインストール済みです。
64
-
65
-
66
-
67
- config.yml
68
-
69
- ```
70
-
71
- version: 2
72
-
73
- jobs:
74
-
75
- build:
76
-
77
- docker:
78
-
79
- - image: circleci/ruby:2.5.3-node-browsers
80
-
81
- environment:
82
-
83
- RAILS_ENV: 'test'
84
-
85
-
86
-
87
- - image: circleci/mysql:5.6.47
88
-
89
- environment:
90
-
91
- MYSQL_ROOT_PASSWORD: "password"
92
-
93
- MYSQL_ROOT_HOST: "%"
94
-
95
-
96
-
97
- working_directory: ~/app_name
98
-
99
-
100
-
101
- steps:
102
-
103
- - checkout
104
-
105
- - restore_cache: # キャッシュを読み込む
106
-
107
- keys:
108
-
109
- - gem-cache-v1-{{ checksum "Gemfile.lock" }}
110
-
111
- - gem-cache-v1-
112
-
113
-
114
-
115
- - run:
116
-
117
- name: Bundle Install
118
-
119
- command: bundle check --path vendor/bundle || bundle install --deployment
120
-
121
-
122
-
123
- - save_cache: # キャッシュを保存する
124
-
125
- key: gem-cache-v1-{{ checksum "Gemfile.lock" }}
126
-
127
- paths:
128
-
129
- - vendor/bundle
130
-
131
-
132
-
133
- - run:
134
-
135
- name: Wait for DB
136
-
137
- command: dockerize -wait tcp://127.0.0.1:3306 -timeout 120s
138
-
139
- - run: bundle exec rake db:create
140
-
141
- - run: bundle exec rake db:schema:load
142
-
143
- - run:
144
-
145
- name: run tests
146
-
147
- command: |
148
-
149
- mkdir /tmp/test-results
150
-
151
- TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
152
-
153
- bundle exec rspec --format progress \
154
-
155
- --out /tmp/test-results/rspec.xml \
156
-
157
- --format progress \
158
-
159
- $TEST_FILES
160
-
161
- - store_test_results:
162
-
163
- path: /tmp/test-results
164
-
165
- - store_artifacts:
166
-
167
- path: /tmp/test-results
168
-
169
- destination: test-results
170
-
171
-
172
-
173
- - add_ssh_keys:
174
-
175
- fingerprints:
176
-
177
- - "1f:d5:4b:1c:ed:c1:92:6e:47:a1:e0:18:a0:ff:27:ca"
178
-
179
-
180
-
181
- - deploy:
182
-
183
- name: Capistrano deploy
184
-
185
- command: |
186
-
187
- if [ "${CIRCLE_BRANCH}" != "master" ]; then
188
-
189
- exit 0
190
-
191
- fi
192
-
193
- bundle exec cap production deploy unicorn:restart
194
-
195
- ```
196
-
197
-
198
-
199
- dockerfile
200
-
201
- ```
202
-
203
- FROM ruby:2.5.3
204
-
205
- RUN apt-get update -qq && \
206
-
207
- apt-get install -y build-essential \
208
-
209
- libpq-dev \
210
-
211
- nodejs
212
-
213
-
214
-
215
- RUN mkdir /app_name
216
-
217
- ENV APP_ROOT /app_name
218
-
219
- WORKDIR $APP_ROOT
220
-
221
-
222
-
223
- ADD ./Gemfile $APP_ROOT/Gemfile
224
-
225
- ADD ./Gemfile.lock $APP_ROOT/Gemfile.lock
226
-
227
-
228
-
229
- RUN bundle install
230
-
231
- ADD . $APP_ROOT
232
-
233
- ```
234
-
235
-
236
-
237
- docker-compose.yml
238
-
239
- ```
240
-
241
- version: '3'
242
-
243
-
244
-
245
- services:
246
-
247
- web:
248
-
249
- build: .
250
-
251
- ports:
252
-
253
- - "3000:3000"
254
-
255
- links:
256
-
257
- - db
258
-
259
- tty: true
260
-
261
- command: /bin/sh -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
262
-
263
- volumes:
264
-
265
- - .:/app_name
266
-
267
- depends_on:
268
-
269
- - db
270
-
271
-
272
-
273
- db:
274
-
275
- image: mysql:5.6.47
276
-
277
- environment:
278
-
279
- MYSQL_ROOT_PASSWORD: password
280
-
281
- MYSQL_DATABASE: root
282
-
283
- ports:
284
-
285
- - "4306:3306"
286
-
287
- volumes:
288
-
289
- - ./tmp/db:/var/lib/mysql/data
290
-
291
- volumes:
292
-
293
- bundle:
294
-
295
- mysql_data:
296
-
297
- ```
298
-
299
-
300
-
301
- database.yml.ci
302
-
303
- ```
304
-
305
- test:
306
-
307
- adapter: mysql2
308
-
309
- encoding: utf8
310
-
311
- pool: 5
312
-
313
- username: 'root'
314
-
315
- port: 3306
316
-
317
- host: '127.0.0.1'
318
-
319
- database: LuggageMGT_test
320
-
321
- ```
322
-
323
-
324
-
325
-
326
-
327
-
328
-
329
- 下記コマンド実装結果です。
330
-
331
- ```
332
-
333
- name@mbp リポジトリ名 % bundler -v
334
-
335
- Bundler version 1.17.3
336
-
337
- ```
338
-
339
-
340
-
341
-
342
-
343
- 追記です。
344
-
345
-
346
-
347
- config.yml内の
348
-
349
- ```
350
-
351
- - run: mv config/database.yml.ci config/database.yml
352
-
353
- ```
354
-
355
-
356
-
357
- を削除したら、circleCIのエラーが変わりました。
358
-
359
- 下記がエラーです。
360
-
361
- ```
362
-
363
- #!/bin/bash -eo pipefail
364
-
365
- bundle exec rake db:create
366
-
367
- Unknown MySQL server host 'db' (-2)
368
-
369
- Couldn't create 'LuggageMGT_test' database. Please check your configuration.
370
-
371
- rake aborted!
372
-
373
- Mysql2::Error::ConnectionError: Unknown MySQL server host 'db' (-2)
374
-
375
- /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:90:in `connect'
376
-
377
- /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:90:in `initialize'
378
-
379
- /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/mysql2_adapter.rb:22:in `new'
380
-
381
- /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/mysql2_adapter.rb:22:in `mysql2_connection'
382
-
383
- /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:830:in `new_connection'
384
-
385
- /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:874:in `checkout_new_connection'
386
-
387
- /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:853:in `try_to_checkout_new_connection'
388
-
389
- /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:814:in `acquire_connection'
390
-
391
- /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:538:in `checkout'
392
-
393
- /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:382:in `connection'
394
-
395
- /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:1033:in `retrieve_connection'
396
-
397
- /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_handling.rb:118:in `retrieve_connection'
398
-
399
- /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_handling.rb:90:in `connection'
400
-
401
- /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/mysql_database_tasks.rb:6:in `connection'
402
-
403
- /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/mysql_database_tasks.rb:14:in `create'
404
-
405
- /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:119:in `create'
406
-
407
- /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:139:in `block in create_current'
408
-
409
- /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:316:in `block in each_current_configuration'
410
-
411
- /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:313:in `each'
412
-
413
- /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:313:in `each_current_configuration'
414
-
415
- /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:138:in `create_current'
416
-
417
- /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/railties/databases.rake:29:in `block (2 levels) in <top (required)>'
418
-
419
- /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
420
-
421
- /usr/local/bundle/bin/bundle:23:in `load'
422
-
423
- /usr/local/bundle/bin/bundle:23:in `<main>'
424
-
425
- Tasks: TOP => db:create
426
-
427
- (See full trace by running task with --trace)
428
-
429
-
430
-
431
- Exited with code exit status 1
432
-
433
- CircleCI received exit code 1
434
-
435
- ```

4

修正

2020/09/20 06:56

投稿

keisuke.F
keisuke.F

スコア19

test CHANGED
File without changes
test CHANGED
@@ -80,268 +80,276 @@
80
80
 
81
81
  environment:
82
82
 
83
- - BUNDLER_VERSION: 1.17.3
84
-
85
- - RAILS_ENV: 'test'
83
+ RAILS_ENV: 'test'
84
+
85
+
86
86
 
87
87
  - image: circleci/mysql:5.6.47
88
88
 
89
89
  environment:
90
90
 
91
- - MYSQL_ALLOW_EMPTY_PASSWORD: 'true'
91
+ MYSQL_ROOT_PASSWORD: "password"
92
-
92
+
93
- - MYSQL_ROOT_HOST: '%'
93
+ MYSQL_ROOT_HOST: "%"
94
-
95
-
96
-
94
+
95
+
96
+
97
- working_directory: ~/repo
97
+ working_directory: ~/app_name
98
-
99
-
98
+
99
+
100
100
 
101
101
  steps:
102
102
 
103
103
  - checkout
104
104
 
105
-
106
-
107
- - restore_cache:
105
+ - restore_cache: # キャッシュを読み込む
108
-
106
+
109
- keys:
107
+ keys:
110
-
108
+
111
- - v1-dependencies-{{ checksum "Gemfile.lock" }}
109
+ - gem-cache-v1-{{ checksum "Gemfile.lock" }}
110
+
112
-
111
+ - gem-cache-v1-
112
+
113
+
114
+
115
+ - run:
116
+
117
+ name: Bundle Install
118
+
119
+ command: bundle check --path vendor/bundle || bundle install --deployment
120
+
121
+
122
+
123
+ - save_cache: # キャッシュを保存する
124
+
125
+ key: gem-cache-v1-{{ checksum "Gemfile.lock" }}
126
+
127
+ paths:
128
+
113
- - v1-dependencies-
129
+ - vendor/bundle
114
130
 
115
131
 
116
132
 
117
133
  - run:
118
134
 
135
+ name: Wait for DB
136
+
137
+ command: dockerize -wait tcp://127.0.0.1:3306 -timeout 120s
138
+
139
+ - run: bundle exec rake db:create
140
+
141
+ - run: bundle exec rake db:schema:load
142
+
143
+ - run:
144
+
119
- name: install dependencies
145
+ name: run tests
120
146
 
121
147
  command: |
122
148
 
123
- gem install bundler -v 1.17.3
124
-
125
- bundle install --jobs=4 --retry=3 --path vendor/bundle
126
-
127
-
128
-
129
- - save_cache:
130
-
131
- paths:
132
-
133
- - ./vendor/bundle
134
-
135
- key: v1-dependencies-{{ checksum "Gemfile.lock" }}
136
-
137
-
149
+ mkdir /tmp/test-results
150
+
151
+ TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
152
+
153
+ bundle exec rspec --format progress \
154
+
155
+ --out /tmp/test-results/rspec.xml \
156
+
157
+ --format progress \
158
+
159
+ $TEST_FILES
160
+
161
+ - store_test_results:
162
+
163
+ path: /tmp/test-results
164
+
165
+ - store_artifacts:
166
+
167
+ path: /tmp/test-results
168
+
169
+ destination: test-results
170
+
171
+
172
+
173
+ - add_ssh_keys:
174
+
175
+ fingerprints:
176
+
177
+ - "1f:d5:4b:1c:ed:c1:92:6e:47:a1:e0:18:a0:ff:27:ca"
178
+
179
+
180
+
181
+ - deploy:
182
+
183
+ name: Capistrano deploy
184
+
185
+ command: |
186
+
187
+ if [ "${CIRCLE_BRANCH}" != "master" ]; then
188
+
189
+ exit 0
190
+
191
+ fi
192
+
193
+ bundle exec cap production deploy unicorn:restart
194
+
195
+ ```
196
+
197
+
198
+
199
+ dockerfile
200
+
201
+ ```
202
+
203
+ FROM ruby:2.5.3
204
+
205
+ RUN apt-get update -qq && \
206
+
207
+ apt-get install -y build-essential \
208
+
209
+ libpq-dev \
210
+
211
+ nodejs
212
+
213
+
214
+
215
+ RUN mkdir /app_name
216
+
217
+ ENV APP_ROOT /app_name
218
+
219
+ WORKDIR $APP_ROOT
220
+
221
+
222
+
223
+ ADD ./Gemfile $APP_ROOT/Gemfile
224
+
225
+ ADD ./Gemfile.lock $APP_ROOT/Gemfile.lock
226
+
227
+
228
+
229
+ RUN bundle install
230
+
231
+ ADD . $APP_ROOT
232
+
233
+ ```
234
+
235
+
236
+
237
+ docker-compose.yml
238
+
239
+ ```
240
+
241
+ version: '3'
242
+
243
+
244
+
245
+ services:
246
+
247
+ web:
248
+
249
+ build: .
250
+
251
+ ports:
252
+
253
+ - "3000:3000"
254
+
255
+ links:
256
+
257
+ - db
258
+
259
+ tty: true
260
+
261
+ command: /bin/sh -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
262
+
263
+ volumes:
264
+
265
+ - .:/app_name
266
+
267
+ depends_on:
268
+
269
+ - db
270
+
271
+
272
+
273
+ db:
274
+
275
+ image: mysql:5.6.47
276
+
277
+ environment:
278
+
279
+ MYSQL_ROOT_PASSWORD: password
280
+
281
+ MYSQL_DATABASE: root
282
+
283
+ ports:
284
+
285
+ - "4306:3306"
286
+
287
+ volumes:
288
+
289
+ - ./tmp/db:/var/lib/mysql/data
290
+
291
+ volumes:
292
+
293
+ bundle:
294
+
295
+ mysql_data:
296
+
297
+ ```
298
+
299
+
300
+
301
+ database.yml.ci
302
+
303
+ ```
304
+
305
+ test:
306
+
307
+ adapter: mysql2
308
+
309
+ encoding: utf8
310
+
311
+ pool: 5
312
+
313
+ username: 'root'
314
+
315
+ port: 3306
316
+
317
+ host: '127.0.0.1'
318
+
319
+ database: LuggageMGT_test
320
+
321
+ ```
322
+
323
+
324
+
325
+
326
+
327
+
328
+
329
+ 下記コマンド実装結果です。
330
+
331
+ ```
332
+
333
+ name@mbp リポジトリ名 % bundler -v
334
+
335
+ Bundler version 1.17.3
336
+
337
+ ```
338
+
339
+
340
+
341
+
342
+
343
+ 追記です。
344
+
345
+
346
+
347
+ config.yml内の
348
+
349
+ ```
138
350
 
139
351
  - run: mv config/database.yml.ci config/database.yml
140
352
 
141
-
142
-
143
- - run: bundle exec rake db:create
144
-
145
- - run: bundle exec rake db:schema:load
146
-
147
- - run:
148
-
149
- name: run tests
150
-
151
- command: |
152
-
153
- mkdir /tmp/test-results
154
-
155
- TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | \
156
-
157
- circleci tests split --split-by=timings)"
158
-
159
-
160
-
161
- bundle exec rspec \
162
-
163
- --format progress \
164
-
165
- --format RspecJunitFormatter \
166
-
167
- --out /tmp/test-results/rspec.xml \
168
-
169
- --format progress \
170
-
171
- $TEST_FILES
172
-
173
-
174
-
175
- - store_test_results:
176
-
177
- path: /tmp/test-results
178
-
179
- - store_artifacts:
180
-
181
- path: /tmp/test-results
182
-
183
- destination: test-results
184
-
185
-
186
-
187
- ```
188
-
189
-
190
-
191
- dockerfile
192
-
193
- ```
194
-
195
- FROM ruby:2.5.3
196
-
197
- RUN apt-get update -qq && \
198
-
199
- apt-get install -y build-essential \
200
-
201
- libpq-dev \
202
-
203
- nodejs
204
-
205
-
206
-
207
- RUN mkdir /app_name
208
-
209
- ENV APP_ROOT /app_name
210
-
211
- WORKDIR $APP_ROOT
212
-
213
-
214
-
215
- ADD ./Gemfile $APP_ROOT/Gemfile
216
-
217
- ADD ./Gemfile.lock $APP_ROOT/Gemfile.lock
218
-
219
-
220
-
221
- RUN bundle install
222
-
223
- ADD . $APP_ROOT
224
-
225
- ```
226
-
227
-
228
-
229
- docker-compose.yml
230
-
231
- ```
232
-
233
- version: '3'
234
-
235
-
236
-
237
- services:
238
-
239
- web:
240
-
241
- build: .
242
-
243
- ports:
244
-
245
- - "3000:3000"
246
-
247
- links:
248
-
249
- - db
250
-
251
- tty: true
252
-
253
- command: /bin/sh -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
254
-
255
- volumes:
256
-
257
- - .:/app_name
258
-
259
- depends_on:
260
-
261
- - db
262
-
263
-
264
-
265
- db:
266
-
267
- image: mysql:5.6.47
268
-
269
- environment:
270
-
271
- MYSQL_ROOT_PASSWORD: password
272
-
273
- MYSQL_DATABASE: root
274
-
275
- ports:
276
-
277
- - "4306:3306"
278
-
279
- volumes:
280
-
281
- - ./tmp/db:/var/lib/mysql/data
282
-
283
- volumes:
284
-
285
- bundle:
286
-
287
- mysql_data:
288
-
289
- ```
290
-
291
-
292
-
293
- database.yml.ci
294
-
295
- ```
296
-
297
- test:
298
-
299
- adapter: mysql2
300
-
301
- encoding: utf8
302
-
303
- pool: 5
304
-
305
- username: 'root'
306
-
307
- port: 3306
308
-
309
- host: '127.0.0.1'
310
-
311
- database: LuggageMGT_test
312
-
313
- ```
314
-
315
-
316
-
317
-
318
-
319
-
320
-
321
- 下記コマンド実装結果です。
322
-
323
- ```
324
-
325
- name@mbp リポジトリ名 % bundler -v
326
-
327
- Bundler version 1.17.3
328
-
329
- ```
330
-
331
-
332
-
333
-
334
-
335
- 追記です。
336
-
337
-
338
-
339
- config.yml内の
340
-
341
- ```
342
-
343
- - run: mv config/database.yml.ci config/database.yml
344
-
345
353
  ```
346
354
 
347
355
 

3

修正

2020/09/20 06:55

投稿

keisuke.F
keisuke.F

スコア19

test CHANGED
File without changes
test CHANGED
@@ -327,3 +327,101 @@
327
327
  Bundler version 1.17.3
328
328
 
329
329
  ```
330
+
331
+
332
+
333
+
334
+
335
+ 追記です。
336
+
337
+
338
+
339
+ config.yml内の
340
+
341
+ ```
342
+
343
+ - run: mv config/database.yml.ci config/database.yml
344
+
345
+ ```
346
+
347
+
348
+
349
+ を削除したら、circleCIのエラーが変わりました。
350
+
351
+ 下記がエラーです。
352
+
353
+ ```
354
+
355
+ #!/bin/bash -eo pipefail
356
+
357
+ bundle exec rake db:create
358
+
359
+ Unknown MySQL server host 'db' (-2)
360
+
361
+ Couldn't create 'LuggageMGT_test' database. Please check your configuration.
362
+
363
+ rake aborted!
364
+
365
+ Mysql2::Error::ConnectionError: Unknown MySQL server host 'db' (-2)
366
+
367
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:90:in `connect'
368
+
369
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:90:in `initialize'
370
+
371
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/mysql2_adapter.rb:22:in `new'
372
+
373
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/mysql2_adapter.rb:22:in `mysql2_connection'
374
+
375
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:830:in `new_connection'
376
+
377
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:874:in `checkout_new_connection'
378
+
379
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:853:in `try_to_checkout_new_connection'
380
+
381
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:814:in `acquire_connection'
382
+
383
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:538:in `checkout'
384
+
385
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:382:in `connection'
386
+
387
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:1033:in `retrieve_connection'
388
+
389
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_handling.rb:118:in `retrieve_connection'
390
+
391
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/connection_handling.rb:90:in `connection'
392
+
393
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/mysql_database_tasks.rb:6:in `connection'
394
+
395
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/mysql_database_tasks.rb:14:in `create'
396
+
397
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:119:in `create'
398
+
399
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:139:in `block in create_current'
400
+
401
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:316:in `block in each_current_configuration'
402
+
403
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:313:in `each'
404
+
405
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:313:in `each_current_configuration'
406
+
407
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:138:in `create_current'
408
+
409
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.4/lib/active_record/railties/databases.rake:29:in `block (2 levels) in <top (required)>'
410
+
411
+ /home/circleci/repo/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
412
+
413
+ /usr/local/bundle/bin/bundle:23:in `load'
414
+
415
+ /usr/local/bundle/bin/bundle:23:in `<main>'
416
+
417
+ Tasks: TOP => db:create
418
+
419
+ (See full trace by running task with --trace)
420
+
421
+
422
+
423
+ Exited with code exit status 1
424
+
425
+ CircleCI received exit code 1
426
+
427
+ ```

2

修正

2020/09/19 08:37

投稿

keisuke.F
keisuke.F

スコア19

test CHANGED
File without changes
test CHANGED
@@ -12,6 +12,8 @@
12
12
 
13
13
  ```
14
14
 
15
+ Config Processing Erorr(Don't rerun)
16
+
15
17
  #!/bin/sh -eo pipefail
16
18
 
17
19
  # Unable to parse YAML

1

修正

2020/09/19 08:30

投稿

keisuke.F
keisuke.F

スコア19

test CHANGED
File without changes
test CHANGED
@@ -8,6 +8,50 @@
8
8
 
9
9
 
10
10
 
11
+ #エラー文 circleCIより
12
+
13
+ ```
14
+
15
+ #!/bin/sh -eo pipefail
16
+
17
+ # Unable to parse YAML
18
+
19
+ # while parsing a block mapping
20
+
21
+ # in 'string', line 32, column 11:
22
+
23
+ # name: install dependencies
24
+
25
+ # ^
26
+
27
+ # expected <block end>, but found '<scalar>'
28
+
29
+ # in 'string', line 35, column 13:
30
+
31
+ # gem install bundler -v 1.17.3
32
+
33
+ # ^
34
+
35
+ #
36
+
37
+ # -------
38
+
39
+ # Warning: This configuration was auto-generated to show you the message above.
40
+
41
+ # Don't rerun this job. Rerunning will have no effect.
42
+
43
+ false
44
+
45
+
46
+
47
+ Exited with code exit status 1
48
+
49
+ CircleCI received exit code 1
50
+
51
+ ```
52
+
53
+
54
+
11
55
  #試した事
12
56
 
13
57
  bundlerのバージョン指定でエラーが出ている様で、bundlerをuninstallし、新たにインストールしました。