-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcircle.yml
168 lines (165 loc) · 4.11 KB
/
circle.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
version: 2.1
executors:
builder_frontend:
docker:
- image: nibbleproject/nibble-ci-frontend
builder:
environment:
IMAGE_NAME: nibbleproject/nibble
docker:
- image: nibbleproject/nibble-ci
jobs:
test_backend:
executor: builder
steps:
- checkout
- run:
name: Install requirements
command: sudo pipenv install --system --dev
- run:
name: Run tests
command: CI=true make test
- run:
name: Report Coverage
command:
coveralls
test_frontend:
executor: builder_frontend
steps:
- checkout
- run:
name: Install dependencies
working_directory: ./frontend
command: |
yarn install
- run:
name: Run tests
working_directory: ./frontend
command: |
yarn test:unit
yarn test:e2e --headless
build_image:
executor: builder
steps:
- checkout
- setup_remote_docker
- run:
name: Build image
command: docker build -t $IMAGE_NAME .
- run:
name: Archive image
command: docker save -o image.tar $IMAGE_NAME
- persist_to_workspace:
root: .
paths:
- ./image.tar
test_image:
executor: builder
steps:
- checkout
- setup_remote_docker
- attach_workspace:
at: /tmp/workspace
- run:
name: Load image
command: docker load -i /tmp/workspace/image.tar
- run:
name: Smoke test
command: |
set -x
docker-compose -f .circle/docker-compose.yml up -d web postgres
docker-compose -f .circle/docker-compose.yml run ci
push_image:
executor: builder
steps:
- checkout
- setup_remote_docker
- attach_workspace:
at: /tmp/workspace
- run:
name: Load image
command: docker load -i /tmp/workspace/image.tar
- run:
name: Push image
command: |
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker push $IMAGE_NAME:latest
deploy_staging:
executor: builder
steps:
- checkout
- run:
name: Configure Heroku
command: |
cat > ~/.netrc \<< EOF
machine api.heroku.com
login $HEROKU_LOGIN
password $HEROKU_AUTH_TOKEN
EOF
- add_ssh_keys:
fingerprints:
- "61:66:4f:6c:6a:a6:1b:c3:18:18:04:2a:32:d0:b3:79"
- run:
name: Deploy to staging
command: |
heroku git:remote --app nibbleproject-staging --ssh-git
git push heroku main
deploy_production:
executor: builder
steps:
- checkout
- run:
name: Configure Heroku
command: |
cat > ~/.netrc \<< EOF
machine api.heroku.com
login $HEROKU_LOGIN
password $HEROKU_AUTH_TOKEN
EOF
- add_ssh_keys:
fingerprints:
- "61:66:4f:6c:6a:a6:1b:c3:18:18:04:2a:32:d0:b3:79"
- run:
name: Deploy to production
command: |
heroku git:remote --app nibbleproject-staging --ssh-git
heroku pipelines:promote
workflows:
version: 2
main:
jobs:
- test_backend
- test_frontend
- build_image
- test_image:
requires:
- build_image
- push_image:
requires:
- build_image
- test_image
filters:
branches:
only: main
- deploy_staging:
requires:
- test_frontend
- test_backend
- test_image
- push_image
filters:
branches:
only: main
- hold:
type: approval
requires:
- deploy_staging
filters:
branches:
only: main
- deploy_production:
requires:
- hold
filters:
branches:
only: main