-
Notifications
You must be signed in to change notification settings - Fork 6
/
config.yml
147 lines (139 loc) · 4.34 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
version: 2
defaults: &defaults
working_directory: ~/repo
docker:
- image: opennetworking/clam-ci
jobs:
test-node:
<<: *defaults
steps:
- checkout
# Restore cache for all the packages
- restore_cache:
keys:
- test-dependencies-{{ checksum "package.json" }}
- test-dependencies-
- restore_cache:
keys:
- functions-dependencies-{{ checksum "functions/package.json" }}
- functions-dependencies-
- restore_cache:
keys:
- client-dependencies-{{ checksum "client/package.json" }}
- client-dependencies-
- restore_cache:
keys:
- common-dependencies-{{ checksum "common/package.json" }}
- common-dependencies-
# install the new dependencies for all the packages
- run:
name: Install Firebase Tools
command: npm install --prefix=./firebase-emulator firebase-tools@9.16.0
- run: npm install
- run: npm --prefix ./functions install
- run: npm --prefix ./client install
- run: npm --prefix ./common install
# run the tests
- run: ./firebase-emulator/node_modules/.bin/firebase emulators:exec --only firestore 'npm test'
- run: npm --prefix ./common test
- run: npm --prefix ./functions test
- run: npm --prefix ./client test
- run:
name: Upload coverage reports
command: bash <(curl -s https://codecov.io/bash)
# update the cache for all the packages
- save_cache:
paths:
- node_modules
key: test-dependencies-{{ checksum "package.json" }}
when: always
- save_cache:
paths:
- functions/node_modules
key: functions-dependencies-{{ checksum "functions/package.json" }}
when: always
- save_cache:
paths:
- client/node_modules
key: client-dependencies-{{ checksum "client/package.json" }}
when: always
- save_cache:
paths:
- common/node_modules
key: common-dependencies-{{ checksum "common/package.json" }}
when: always
- persist_to_workspace:
root: ~/repo
paths: .
test-py:
docker:
# CentOS 7 used on ONF Gerrit has python 3.6 installed
- image: python:3.6
steps:
- checkout
- run: pip install tox && cd gerrit && tox
build:
<<: *defaults
environment:
steps:
- attach_workspace:
at: ~/repo
- run:
name: Build the clinet
command: |
pushd client
REACT_APP_FIREBASE_ENV=${FIREBASE_PROJECT_ID} REACT_APP_FIREBASE_API_KEY=${FIREBASE_API_KEY} CI=false npm run build
popd
- persist_to_workspace:
root: ~/repo
paths: .
backup:
docker:
- image: google/cloud-sdk
environment:
steps:
- run:
name: Backup Firestore
command: |
echo $GCLOUD_SERVICE_KEY | gcloud auth activate-service-account --key-file=-
gcloud --quiet config set project ${FIREBASE_PROJECT_ID}
gcloud firestore export gs://${GCLOUD_STORAGE_BUCKET}/before_${CIRCLE_SHA1} --collection-ids='addendums','whitelists','agreements'
deploy:
<<: *defaults
environment:
steps:
- attach_workspace:
at: ~/repo
- run:
name: Install Firebase Tools
command: npm install --prefix=./firebase-deploy firebase-tools@9.16.0
- run:
name: Deploy Client to Firebase
command: |
./firebase-deploy/node_modules/.bin/firebase --project ${FIREBASE_PROJECT_ID} deploy --token=${FIREBASE_DEPLOY_TOKEN} --only firestore,hosting
- run:
name: Deploy Functions to Firebase
command: |
./firebase-deploy/node_modules/.bin/firebase --project ${FIREBASE_PROJECT_ID} deploy --token=${FIREBASE_DEPLOY_TOKEN} --only functions
workflows:
version: 2
test-deploy:
jobs:
- test-node
- test-py
- build:
requires:
- test-node
- test-py
- backup:
requires:
- build
filters:
branches:
only: master
- deploy:
requires:
- backup
filters:
branches:
only: master