-
Notifications
You must be signed in to change notification settings - Fork 4
/
config.yml
255 lines (232 loc) · 7.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
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
version: 2.1
orbs:
codecov: codecov/codecov@3.2.4
references:
attach_deploy_workspace: &attach_deploy_workspace
attach_workspace:
at: .
deployment_container: &deployment_container
docker:
- image: cimg/python:3.11-node
node_prod_container: &node_prod_container
docker:
- image: cimg/node:18.18
install_aws_cli: &install_aws_cli
run:
name: Install AWS CLI
command: |
pip install --upgrade pip
pip install --upgrade awscli
persist_deploy_workspace: &persist_deploy_workspace
persist_to_workspace:
root: ./
paths:
- ./*
restore_build_cache: &restore_build_cache
restore_cache:
name: restore yarn package cache
keys:
- yarn-packages-{{ checksum "yarn.lock" }}
run_yarn_install: &run_yarn_install
run:
name: install dependencies
# See: https://github.com/mozilla/addons-frontend/issues/3034
command: yarn install --pure-lockfile
save_build_cache: &save_build_cache
save_cache:
name: save yarn package cache
key: yarn-packages-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
jobs:
test-wptheme:
docker:
- image: cimg/php:8.2-node
steps:
- checkout
- *restore_build_cache
- *run_yarn_install
- *save_build_cache
- run: yarn build:wptheme
- run: yarn lint:php
- run:
name: run phpunit
command: |
echo "AMO_BASE_URL=$AMO_BASE_URL"
composer install
./vendor/bin/phpunit
- run: test -f wptheme.zip
environment:
# See: https://github.com/mozilla/addons-blog/pull/344#issuecomment-990961180
AMO_BASE_URL: https://addons-dev.allizom.org
test-blog:
<<: *node_prod_container
steps:
- checkout
- *restore_build_cache
- *run_yarn_install
- *save_build_cache
- run: yarn test-ci
- codecov/upload
- run: yarn prettier-ci
- run: yarn lint:js
- run: yarn lint:scss
- run:
name: build assets
command: |
yarn sass:build
yarn script:build
bin/asset-pipeline
build-blog-dev:
<<: *node_prod_container
steps:
- checkout
- *restore_build_cache
- *run_yarn_install
- *save_build_cache
- run: yarn build:production
- run: yarn test-build
- *persist_deploy_workspace
environment:
# See: https://github.com/mozilla/addons-blog/issues/351
AMO_BASE_URL: https://addons-dev.allizom.org
build-blog-stage:
<<: *node_prod_container
steps:
- checkout
- run:
name: checkout latest tag
command: |
LATEST_TAG=$(git describe --tags --abbrev=0 --match='20*.*.*-stage')
echo "Latest tag is: $LATEST_TAG"
git checkout "$LATEST_TAG"
- *run_yarn_install
- run: yarn build:production
- run: yarn test-build
- *persist_deploy_workspace
build-blog-prod:
<<: *node_prod_container
steps:
- checkout
- *run_yarn_install
- run: yarn build:production
- run: yarn test-build
- *persist_deploy_workspace
deploy-dev:
<<: *deployment_container
steps:
- *attach_deploy_workspace
- *install_aws_cli
- run:
name: addons-blog deployment (dev)
command: |
pwd && ls -l
AWS_ACCESS_KEY_ID="${DEV_AWS_ACCESS_KEY_ID}" \
AWS_SECRET_ACCESS_KEY="${DEV_AWS_SECRET_ACCESS_KEY}" \
ADDONS_BLOG_BUCKET="${DEV_ADDONS_BLOG_BUCKET}" \
ADDONS_BLOG_BUCKET_PREFIX="${ADDONS_BLOG_BUCKET_PREFIX}" \
AMO_BASE_URL=https://addons-dev.allizom.org \
./bin/deploy.sh
deploy-stage:
<<: *deployment_container
steps:
- *attach_deploy_workspace
- *install_aws_cli
- run:
name: addons-blog deployment (stage)
command: |
pwd && ls -l
AWS_ACCESS_KEY_ID="${STAGE_AWS_ACCESS_KEY_ID}" \
AWS_SECRET_ACCESS_KEY="${STAGE_AWS_SECRET_ACCESS_KEY}" \
ADDONS_BLOG_BUCKET="${STAGE_ADDONS_BLOG_BUCKET}" \
ADDONS_BLOG_BUCKET_PREFIX="${ADDONS_BLOG_BUCKET_PREFIX}" \
AMO_BASE_URL=https://addons.allizom.org \
./bin/deploy.sh
deploy-prod:
<<: *deployment_container
steps:
- *attach_deploy_workspace
- *install_aws_cli
- run:
name: addons-blog deployment (prod)
command: |
pwd && ls -l
rm dist/robots.txt dist/blog/robots.txt
AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" \
AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \
ADDONS_BLOG_BUCKET="${ADDONS_BLOG_BUCKET}" \
ADDONS_BLOG_BUCKET_PREFIX="${ADDONS_BLOG_BUCKET_PREFIX}" \
AMO_BASE_URL=https://addons.mozilla.org \
./bin/deploy.sh
workflows:
version: 2
default-workflow:
jobs:
- test-wptheme
- test-blog
# -dev
- build-blog-dev:
requires:
- test-blog
filters:
branches:
only: main
- deploy-dev:
requires:
- build-blog-dev
filters:
branches:
only: main
# -stage
- build-blog-stage:
# Note that the tags filter is needed because "Circle CI does not
# run workflows for tags unless you explicitly specify tag filters.
# Additionally, if a job requires any other jobs (directly or
# indirectly), you must specify tag filters for those jobs.
filters:
tags:
only: /.+-stage/
branches:
ignore: /.*/
- deploy-stage:
requires:
- build-blog-stage
filters:
tags:
only: /.+-stage/
branches:
ignore: /.*/
# -prod
- build-blog-prod:
# Note that the tags filter is needed because "Circle CI does not
# run workflows for tags unless you explicitly specify tag filters.
# Additionally, if a job requires any other jobs (directly or
# indirectly), you must specify tag filters for those jobs.
filters:
tags:
# Matches tag names like `2021.09.10` or `2021.09.10-1`
only: /20\d{2}\.\d{2}\.\d{2}(-\d+)?$/
branches:
ignore: /.*/
- deploy-prod:
requires:
- build-blog-prod
filters:
tags:
only: /20\d{2}\.\d{2}\.\d{2}(-\d+)?$/
branches:
ignore: /.*/
autodeploy-stage:
triggers:
- schedule:
# Every 3 hours (but without `*/3` because it is NOT supported), see:
# https://circleci.com/docs/2.0/workflows/#scheduling-a-workflow
cron: "0 0,3,6,9,12,15,18,21 * * *"
filters:
branches:
only: main
jobs:
- build-blog-stage
- deploy-stage:
requires:
- build-blog-stage