Skip to content

Commit 6f6eaeb

Browse files
authored
Merge pull request #342 from AlisProject/develop
Update 0.41.0
2 parents 73def31 + c4afb2a commit 6f6eaeb

23 files changed

+5261
-586
lines changed

.circleci/config.yml

+252-35
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,105 @@
1-
version: 2
1+
version: 2.1
22

33
references:
4-
setup_remote_docker: &setup_remote_docker
5-
setup_remote_docker:
6-
version: 17.11.0-ce
4+
setup_remote_docker: &setup_remote_docker
5+
setup_remote_docker:
6+
version: 17.11.0-ce
7+
ignore_master: &ignore_master
8+
filters:
9+
branches:
10+
ignore:
11+
- master
12+
only_master: &only_master
13+
filters:
14+
branches:
15+
only:
16+
- master
17+
deploy_requirements: &deploy_requires
18+
requires:
19+
- lint
20+
- test
21+
- packaging
22+
23+
orbs:
24+
aws-cli: circleci/[email protected]
25+
slack: circleci/[email protected]
26+
27+
executors:
28+
python3_6_1:
29+
working_directory: ~/repo
30+
docker:
31+
- image: circleci/python:3.6.1
32+
33+
commands:
34+
prepare-python-resources:
35+
description: 'Pythonのリソースを準備'
36+
parameters:
37+
resource:
38+
type: string
39+
default: 'requirements.txt'
40+
steps:
41+
- checkout
42+
43+
- <<: *setup_remote_docker
44+
45+
- restore_cache:
46+
keys:
47+
- v3-dependencies-{{ checksum "<< parameters.resource >>" }}
48+
- v3-dependencies-
49+
50+
- run:
51+
name: install dependencies
52+
command: |
53+
python3 -m venv venv
54+
. venv/bin/activate
55+
pip install -r << parameters.resource >>
56+
57+
- save_cache:
58+
paths:
59+
- ./venv
60+
key: v3-dependencies-{{ checksum "<< parameters.resource >>" }}
61+
62+
deploy-resources:
63+
description: 'リソースのデプロイの共通処理'
64+
parameters:
65+
target:
66+
type: string
67+
steps:
68+
- prepare-python-resources
69+
70+
- attach_workspace:
71+
at: .
72+
73+
- deploy:
74+
name: Deployment
75+
command: |
76+
if [ $ALIS_APP_ID ]; then
77+
. venv/bin/activate
78+
./deploy.sh << parameters.target >>
79+
fi
780
881
jobs:
9-
build:
82+
lint:
83+
executor:
84+
name: python3_6_1
85+
86+
steps:
87+
- prepare-python-resources:
88+
resource: 'requirements_test.txt'
89+
90+
- run:
91+
name: checkstyle
92+
command: |
93+
. venv/bin/activate
94+
pycodestyle src tests ./*.py
95+
96+
- run:
97+
name: pyflakes
98+
command: |
99+
. venv/bin/activate
100+
pyflakes src tests ./*.py
10101
102+
test:
11103
docker:
12104
- image: circleci/python:3.6.1
13105
- image: bluszcz/bflocalstack-dynamodb-s3
@@ -23,12 +115,13 @@ jobs:
23115

24116
steps:
25117
- checkout
118+
26119
- <<: *setup_remote_docker
27-
# Download and cache dependencies
120+
28121
- restore_cache:
29122
keys:
30-
- v3-dependencies-{{ checksum "requirements.txt" }}
31-
- v3-dependencies-
123+
- v3-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}
124+
- v3-dependencies-
32125

33126
- run:
34127
name: install dependencies
@@ -41,46 +134,170 @@ jobs:
41134
- save_cache:
42135
paths:
43136
- ./venv
44-
key: v3-dependencies-{{ checksum "requirements.txt" }}
137+
key: v3-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}
45138

46139
- run:
47-
name: run checkstyle for python code
140+
name: run tests
48141
command: |
49142
. venv/bin/activate
50-
pycodestyle src tests ./*.py
143+
python exec_test.py
51144
52-
- run:
53-
name: run pyflakes for python code
54-
command: |
55-
. venv/bin/activate
56-
pyflakes src tests ./*.py
145+
packaging:
146+
executor:
147+
name: python3_6_1
148+
149+
steps:
150+
- prepare-python-resources
57151

58152
- run:
59-
name: run tests
153+
name: make deploy package
60154
command: |
61155
. venv/bin/activate
62-
# 全テスト実行
63-
python exec_test.py
156+
./packaging.sh
157+
158+
- persist_to_workspace:
159+
root: .
160+
paths:
161+
- deploy/*
162+
163+
deploy-function:
164+
executor:
165+
name: python3_6_1
166+
167+
steps:
168+
- deploy-resources:
169+
target: 'function'
170+
171+
deploy-function02:
172+
executor:
173+
name: python3_6_1
174+
175+
steps:
176+
- deploy-resources:
177+
target: 'function02'
178+
179+
deploy-api:
180+
executor:
181+
name: python3_6_1
182+
183+
steps:
184+
- deploy-resources:
185+
target: 'api'
186+
187+
deploy-permission:
188+
executor:
189+
name: python3_6_1
190+
191+
steps:
192+
- deploy-resources:
193+
target: 'permission'
194+
195+
labo:
196+
docker:
197+
- image: circleci/node:12.4.0
198+
199+
working_directory: ~/repo
200+
201+
steps:
202+
- checkout
203+
204+
- attach_workspace:
205+
at: .
206+
207+
- restore_cache:
208+
keys:
209+
- v1-npm-dependencies-{{ checksum "package-lock.json" }}
210+
- v1-npm-dependencies-
211+
64212
- run:
65-
name: make deploy package
213+
command: npm i
214+
215+
- save_cache:
216+
paths:
217+
- ./node_modules
218+
key: v1-npm-dependencies-{{ checksum "package-lock.json" }}
219+
220+
- deploy:
221+
name: Deployment
66222
command: |
67223
if [ $ALIS_APP_ID ]; then
68-
docker image build --tag deploy-image .
69-
docker container run -it --name deploy-container deploy-image
70-
docker container cp deploy-container:/workdir/vendor-package .
71-
. venv/bin/activate
72-
python make_deploy_zip.py
224+
npm run deploy
73225
fi
74226
75-
- run:
76-
name: run deploy
227+
notify-to-slack-for-approval:
228+
executor:
229+
name: python3_6_1
230+
231+
steps:
232+
- slack/approval:
233+
message: "本番環境へのデプロイを承認してください"
234+
color: "#F5E911"
235+
236+
bulk-deployment-to-production:
237+
executor:
238+
name: python3_6_1
239+
240+
steps:
241+
- prepare-python-resources
242+
243+
- attach_workspace:
244+
at: .
245+
246+
- aws-cli/install
247+
248+
- aws-cli/configure
249+
250+
- deploy:
251+
name: Bulk deployment
77252
command: |
78-
if [ $ALIS_APP_ID ]; then
79-
. venv/bin/activate
80-
./deploy_api.sh
81-
./fix_api.sh
82-
fi
253+
. venv/bin/activate
254+
./deploy_api.sh
255+
./fix_api.sh
256+
257+
258+
workflows:
259+
# CloudFormationスタックの依存関係に即したワークフロー
260+
build-deploy:
261+
jobs:
262+
- lint
263+
- test
264+
- packaging
265+
- labo:
266+
<<: *ignore_master
267+
<<: *deploy_requires
268+
- deploy-function:
269+
<<: *ignore_master
270+
<<: *deploy_requires
271+
- deploy-function02:
272+
<<: *ignore_master
273+
<<: *deploy_requires
274+
- deploy-api:
275+
<<: *ignore_master
276+
requires:
277+
- deploy-function
278+
- deploy-function02
279+
- deploy-permission:
280+
<<: *ignore_master
281+
requires:
282+
- deploy-api
283+
284+
# 以下は本番環境へのデプロイ時のみ実行される
285+
- notify-to-slack-for-approval:
286+
<<: *deploy_requires
287+
<<: *only_master
288+
context: slack_notification
289+
- approval:
290+
<<: *deploy_requires
291+
<<: *only_master
292+
type: approval
293+
- bulk-deployment-to-production:
294+
<<: *only_master
295+
context: serverless_production
296+
requires:
297+
- approval
298+
- labo:
299+
<<: *only_master
300+
context: serverless_production
301+
requires:
302+
- approval
83303

84-
- store_artifacts:
85-
path: test-reports
86-
destination: test-reports

.github/pull_request_template.md

+31-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* [ ] Slackでエンジニア全員へこのPRの内容を共有
1616
* [ ] 必要であれば`.envrc.sample` へ環境変数名とその用途の詳細な説明を追加
1717
* [ ] 必要であればmasterへマージされた時に走るCI環境への追加
18+
* [ ] 必要であればCircleCI Contextsにも追加
1819

1920
## 関連URL
2021

@@ -47,7 +48,10 @@
4748

4849
* DBのスキーマに変更があるか
4950
- [ ] 変更がある場合は[ドキュメント](https://alismedia.atlassian.net/wiki/spaces/DEV/pages/9273460)に反映
50-
* 変更されるクエリ (変更前、変更後)
51+
* 変更されるクエリはあるか
52+
- あるならどのような変更か
53+
- 変更前:
54+
- 変更後:
5155
* 新規に追加されるクエリ
5256
* 観点:
5357
* index周りの指定は適切か
@@ -59,14 +63,38 @@
5963
* ブロックチェーンを参照するか
6064
* ブロックチェーンへのトランザクションが発生するか
6165

66+
## トークンの扱いに関する修正か
67+
68+
- Yes
69+
- 投げ銭におけるワンタイムトークンなど、フロントエンドに対してフェイルセーフな設計となっているか
70+
- No
71+
72+
## CDN(Cloudfront)への修正があるか
73+
74+
- 無い
75+
- ある
76+
- あるとしたらその修正内容を[Confluence](https://alismedia.atlassian.net/wiki/x/hICM)にまとめたか
77+
78+
## ElasticSearchへの修正があるか
79+
80+
- 無い
81+
- ある
82+
- あるとしたらその修正内容はコード化したか
83+
84+
## CloudFormationスタック間の依存関係に変更はあるか
85+
86+
- 無い
87+
- ある
88+
- あるとしたらその修正をCIへ反映したか
89+
6290
## 個人情報の取り扱いに変更のあるリリースか
6391

6492
* メールアドレスや住所情報等、個人情報にあたるものは細心の注意が必要
6593

6694
## ロギング
6795

68-
* ロギングは考慮されているか
69-
* ログをはくとしたらいつ、どこで、どこに、どのようなログが吐かれるか
96+
* CloudWatch等、AWS標準以外のログを考慮する必要があるか
97+
* あるとしたらいつ、どこで、なぜ、どこに、どのようなログが吐かれるか
7098

7199
### アラーム
72100
* アラームが必要か

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ README.txt
2828

2929
# etc
3030
node_modules
31+
.serverless
32+
*.log

.node-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v12.4.0

0 commit comments

Comments
 (0)