-
Notifications
You must be signed in to change notification settings - Fork 11
/
config.yml
214 lines (207 loc) · 7 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
---
version: 2
references:
circleci_docker_primary: &circleci_docker_primary trussworks/circleci-docker-primary:tf12-5ee2cb35bc081dbc91da46afc3904ef0e1c111fb
postgres: &postgres postgres:11.6
db_migrate: &db_migrate ${AWS_ACCOUNT_ID}.dkr.ecr.us-west-2.amazonaws.com/easi-db-migrate:latest
jobs:
build_db_migrate_image:
docker:
- image: *circleci_docker_primary
environment:
AWS_DEFAULT_REGION: us-west-2
steps:
- checkout
- setup_remote_docker
- run:
name: Build the flyway migrations for testing
command: |
./scripts/build_db_image "Dockerfile.db_migrations" "easi-db-migrate" "latest"
test:
docker:
- image: *circleci_docker_primary
environment:
PG_SSL_MODE: disable
PGUSER: postgres
PGPASS: easirox
- image: *postgres
environment:
POSTGRES_DB: postgres
POSTGRES_PASSWORD: easirox
POSTGRES_USER: postgres
POSTGRES_HOST_AUTH_METHOD: trust
- image: *db_migrate
environment:
FLYWAY_USER: postgres
FLYWAY_PASSWORD: easirox
FLYWAY_URL: jdbc:postgresql://localhost/postgres
steps:
- checkout
- run:
name: Run easi app tests
command: |
./scripts/build_app
./scripts/testsuite
lint:
docker:
- image: *circleci_docker_primary
steps:
- checkout
- restore_cache:
keys:
- pre-commit-dot-cache-{{ checksum ".pre-commit-config.yaml" }}
- restore_cache:
keys:
- yarn-deps-cache-{{ checksum "yarn.lock" }}
- run:
name: Install dependencies for pre-commit in yarn (temporary?)
command: yarn install
- run:
name: Run pre-commit checks
command: pre-commit run --all-files --show-diff-on-failure
- run:
name: Run Frontend Tests
command: yarn test
- save_cache:
key: pre-commit-dot-cache-{{ checksum ".pre-commit-config.yaml" }}
paths:
- ~/.cache/pre-commit
- save_cache:
key: yarn-deps-cache-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
build_db_clean_image:
docker:
- image: *circleci_docker_primary
environment:
AWS_DEFAULT_REGION: us-west-2
steps:
- checkout
- setup_remote_docker
- run:
name: Build the db cleaner image and push to ECR
command: |
./scripts/build_db_image "Dockerfile.db_clean" "easi-db-clean" "latest"
build_tag_push:
docker:
- image: *circleci_docker_primary
environment:
AWS_DEFAULT_REGION: us-west-2
steps:
- checkout
- setup_remote_docker
- run:
name: Build the app and push to ECR
command: |
./scripts/build_docker_image
deploy_dev:
docker:
- image: *circleci_docker_primary
environment:
AWS_DEFAULT_REGION: us-west-2
APP_ENV: dev
OKTA_CLIENT_ID: 0oa2e913coDQeG19S297
REACT_APP_OKTA_CLIENT_ID: 0oa2e913coDQeG19S297
REACT_APP_OKTA_DOMAIN: https://test.idp.idm.cms.gov
REACT_APP_OKTA_SERVER_ID: aus2e96etlbFPnBHt297
REACT_APP_OKTA_ISSUER: https://test.idp.idm.cms.gov/oauth2/aus2e96etlbFPnBHt297
OKTA_ISSUER: https://test.idp.idm.cms.gov/oauth2/aus2e96etlbFPnBHt297
REACT_APP_OKTA_REDIRECT_URI: https://dev.easi.cms.gov/implicit/callback
REACT_APP_API_ADDRESS: https://dev.easi.cms.gov/api/v1
steps:
- checkout
- run:
name: Setup custom environment variables
command: |
temp_role=$(aws sts assume-role \
--role-arn arn:aws:iam::$AWS_ACCOUNT_ID_DEV:role/circleci \
--role-session-name circleci)
echo "export AWS_ACCESS_KEY_ID=$(jq --raw-output .Credentials.AccessKeyId <<< "$temp_role")" >> $BASH_ENV
echo "export AWS_SECRET_ACCESS_KEY=$(jq --raw-output .Credentials.SecretAccessKey <<< "$temp_role")" >> $BASH_ENV
echo "export AWS_SESSION_TOKEN=$(jq --raw-output .Credentials.SessionToken <<< "$temp_role")" >> $BASH_ENV
- run:
name: Nuke the database
command: |
./scripts/db_lambda_invoke easi-app-db-clean
- run:
name: Run migrations
command: |
./scripts/db_lambda_invoke easi-app-db-migrate
- run:
name: Restart ECS service
command: |
./scripts/restart_ecs
- run:
name: Build static assets and release to S3
command: |
./scripts/release_static $STATIC_S3_BUCKET_DEV
deploy_impl:
docker:
- image: *circleci_docker_primary
environment:
AWS_DEFAULT_REGION: us-west-2
APP_ENV: impl
OKTA_CLIENT_ID: 0oa2sjdaxkwy3TrW1297
REACT_APP_OKTA_CLIENT_ID: 0oa2sjdaxkwy3TrW1297
REACT_APP_OKTA_DOMAIN: https://impl.idp.idm.cms.gov
REACT_APP_OKTA_SERVER_ID: aus2sjf5g6mzGsnSZ297
REACT_APP_OKTA_ISSUER: https://impl.idp.idm.cms.gov/oauth2/aus2sjf5g6mzGsnSZ297
OKTA_ISSUER: https://impl.idp.idm.cms.gov/oauth2/aus2sjf5g6mzGsnSZ297
REACT_APP_OKTA_REDIRECT_URI: https://impl.easi.cms.gov/implicit/callback
REACT_APP_API_ADDRESS: https://impl.easi.cms.gov/api/v1
steps:
- checkout
- run:
name: Setup custom environment variables
command: |
temp_role=$(aws sts assume-role \
--role-arn arn:aws:iam::$AWS_ACCOUNT_ID_IMPL:role/circleci \
--role-session-name circleci)
echo "export AWS_ACCESS_KEY_ID=$(jq --raw-output .Credentials.AccessKeyId <<< "$temp_role")" >> $BASH_ENV
echo "export AWS_SECRET_ACCESS_KEY=$(jq --raw-output .Credentials.SecretAccessKey <<< "$temp_role")" >> $BASH_ENV
echo "export AWS_SESSION_TOKEN=$(jq --raw-output .Credentials.SessionToken <<< "$temp_role")" >> $BASH_ENV
- run:
name: Run migrations
command: |
./scripts/db_lambda_invoke easi-app-db-migrate
- run:
name: Restart ECS service
command: |
./scripts/restart_ecs
- run:
name: Build static assets and release to S3
command: |
./scripts/release_static "$STATIC_S3_BUCKET_IMPL"
workflows:
version: 2
compile:
jobs:
- build_db_migrate_image
- lint
- test:
requires:
- build_db_migrate_image
- build_tag_push:
requires:
- lint
- test
- deploy_dev:
requires:
- build_tag_push
- deploy_impl:
filters:
branches:
only:
- master
requires:
- deploy_dev
weekly:
triggers:
- schedule:
cron: "0 2 * * 6"
filters:
branches:
only:
- master
jobs:
- build_db_clean_image