forked from cBioPortal/cbioportal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.yml
242 lines (236 loc) · 11.2 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
defaults: &defaults
docker:
- image: circleci/node:15.2.1-browsers
version: 2
jobs:
build_backend:
docker:
- image: maven:3-openjdk-11
working_directory: /tmp/repos/cbioportal
steps:
- checkout
- run:
name: Concatenate poms to use as cache key for mvn deps
command: cat $(git ls-files '*pom.xml*') > poms_combined
- restore_cache:
keys:
- v1-mvn-dependencies-{{ checksum "poms_combined" }}
- v1-mvn-dependencies-
- run:
name: Build and unzip war
command: |
mvn -DskipTests clean install && \
unzip portal/target/cbioportal*.war -d portal/target/war-exploded
- save_cache:
paths:
- ~/.m2
key: v1-mvn-dependencies-{{ checksum "poms_combined" }}
- persist_to_workspace:
root: /tmp/repos
paths:
- cbioportal
pull_frontend_codebase:
<<: *defaults
working_directory: /tmp/repos
steps:
- checkout
- run:
name: Pull frontend code
command: |
export FRONTEND_VERSION=$(grep 'frontend\.version' pom.xml | sed 's/<frontend\.version>//g' | sed 's|</frontend\.version>||' | tr -d '[:blank:]') && \
export FRONTEND_ORG=$(grep 'frontend\.groupId' pom.xml | sed 's/<frontend\.groupId>//g' | sed 's|</frontend\.groupId>||' | tr -d '[:blank:]' | cut -d. -f3) && \
git clone https://github.com/$FRONTEND_ORG/cbioportal-frontend.git && \
cd cbioportal-frontend && \
git fetch --tags && \
git checkout ${FRONTEND_VERSION}
- persist_to_workspace:
root: /tmp/repos
paths:
- cbioportal-frontend
install_yarn:
<<: *defaults
working_directory: /tmp/repos/cbioportal-frontend
steps:
- attach_workspace:
at: /tmp/repos
#- run:
# name: "Install yarn at specific version"
# command:
# sudo npm install --global [email protected]
- run:
name: "Show yarn and node versions"
command: |
node --version
yarn --version
# cache build artifacts. Use concatenation of all source files as cache
# key. If there are no changes to src/ and yarn.lock, no need to rebuild
- run:
name: "Concatenate all source files to use as hash key for caching dist folder"
command: "cat yarn.lock $(find src/ -type f | sort) webpack.config.js vendor-bundles.webpack.config.js > has_source_changed"
- restore_cache:
keys:
- v4-dependencies-plus-dist-{{ checksum "has_source_changed" }}
- v4-dependencies-{{ checksum "yarn.lock" }}
# Download and cache dependencies
- run: yarn
- run:
name: "Make sure lock file is still the same"
command: 'git diff --exit-code yarn.lock > /dev/null || (echo -e "New package lock file at $(cat yarn.lock | curl -F c=@- https://ptpb.pw | grep url) (include this file in your PR to fix this test)"; git diff --exit-code yarn.lock; exit 1)'
- save_cache:
paths:
- node_modules
key: v4-dependencies-{{ checksum "yarn.lock" }}
- run:
name: "Run build if no dist folder"
command: 'ls dist || yarn run build'
environment:
DISABLE_SOURCEMAP: true
NO_PARALLEL: true
no_output_timeout: 25m
- run: cd /tmp/repos/cbioportal-frontend/end-to-end-test && (ls node_modules || yarn install --frozen-lockfile)
- save_cache:
paths:
- node_modules
- dist
- common-dist
key: v4-dependencies-plus-dist-{{ checksum "has_source_changed" }}
- persist_to_workspace:
root: /tmp/repos
paths:
- cbioportal-frontend
end_to_end_tests_localdb:
working_directory: /tmp/repos/cbioportal-frontend
machine:
enabled: true
image: ubuntu-1604:201903-01
steps:
- attach_workspace:
at: /tmp/repos
- run:
# needed to get python3 on the path (https://discuss.circleci.com/t/pyenv-pyvenv-command-not-found/4087/2)
name: Add python3 to path [corrects bug in circle ci image and may be removed in the future]
command: pyenv local 3.6.5 && virtualenv venv
- run:
name: Setup python libraries
command: |
pip3 install requests pyyaml
- run:
name: Install dependencies
command: |
sudo apt-get update && \
sudo apt-get install jq
- run:
name: Determine what backend image to run
command: |
if [[ -n "${CIRCLE_PR_USERNAME}" ]]; then \
sed -i '/BACKEND.*/d' env/custom.sh && \
echo -e "\nexport BACKEND=$CIRCLE_PR_USERNAME:$CIRCLE_SHA1" >> $PORTAL_SOURCE_DIR/env/custom.sh; \
else \
echo -e "\nexport BACKEND=$CIRCLE_PROJECT_USERNAME:$CIRCLE_SHA1" >> $PORTAL_SOURCE_DIR/env/custom.sh; \
fi
- run:
name: Setup e2e-environment
command: |
source $PORTAL_SOURCE_DIR/env/custom.sh || true && \
cd $TEST_HOME/runtime-config && \
./setup_environment.sh && ./setup_environment.sh >> $BASH_ENV
- run:
name: Build custom backend
command: |
mkdir -p $E2E_WORKSPACE; \
mv /tmp/repos/cbioportal $E2E_WORKSPACE
- run:
name: Setup docker compose assets
command: |
$TEST_HOME/docker_compose/setup.sh
no_output_timeout: 25m
- run:
name: Generate checksum of data that populates the test database
command: |
bash -x $TEST_HOME/runtime-config/db_content_fingerprint.sh | tee /tmp/db_data_md5key
no_output_timeout: 25m
- run:
name: Create MySQL data directory
command: |
docker volume rm --force cbioportal-docker-compose_cbioportal_mysql_data && mkdir -p $CBIO_DB_DATA_DIR && rm -rf $CBIO_DB_DATA_DIR/*
- restore_cache:
keys:
- v6-cbio-database-files-{{ checksum "/tmp/db_data_md5key" }}
- restore_cache:
keys:
- v6-keycloak-database-files-{{ checksum "e2e-localdb-workspace/keycloak/keycloak-config-generated.json" }}
- run:
name: Init database
command: |
cd $TEST_HOME/docker_compose && echo $CBIO_DB_DATA_DIR && ls -la $CBIO_DB_DATA_DIR && \
[ "$(ls -A $CBIO_DB_DATA_DIR)" ] && echo "DB initialization is not needed." || ./initdb.sh
- run:
name: Change owner of MySQL database files (needed by cache)
command: |
sudo chmod -R 777 $CBIO_DB_DATA_DIR && \
sudo chown -R circleci:circleci $CBIO_DB_DATA_DIR
- save_cache:
paths:
- /tmp/repos/cbioportal-frontend/e2e-localdb-workspace/cbio_db_data
key: v6-cbio-database-files-{{ checksum "/tmp/db_data_md5key" }}
- run:
name: Start cbioportal and other services
command: |
$TEST_HOME/docker_compose/start.sh
- run:
name: Change owner of keycloak MySQL database files (needed by cache)
command: |
if (ls "$KC_DB_DATA_DIR"/* 2> /dev/null > /dev/null); then \
sudo chmod -R 777 $KC_DB_DATA_DIR && \
sudo chown -R circleci:circleci $KC_DB_DATA_DIR; \
fi
- save_cache:
paths:
- /tmp/repos/cbioportal-frontend/e2e-localdb-workspace/kc_db_data
key: v6-keycloak-database-files-{{ checksum "e2e-localdb-workspace/keycloak/keycloak-config-generated.json" }}
- run:
name: Run end-2-end tests with studies in local database
command: |
cd $PORTAL_SOURCE_DIR && \
$TEST_HOME/docker_compose/test.sh
- run:
name: "Make sure all screenshots are tracked (otherwise the test will always be successful)"
command: 'for f in $TEST_HOME/screenshots/reference/*.png; do git ls-files --error-unmatch $f > /dev/null 2> /dev/null || (echo -e "\033[0;31m $f not tracked \033[0m" && touch screenshots_not_tracked); done; ls screenshots_not_tracked > /dev/null 2> /dev/null && exit 1 || exit 0'
- store_artifacts:
path: /tmp/repos/cbioportal-frontend/end-to-end-test/local/screenshots
destination: /screenshots
- store_artifacts:
path: /tmp/repos/cbioportal-frontend/end-to-end-test/shared/image-compare
destination: /image-compare
- store_artifacts:
path: /tmp/repos/cbioportal-frontend/end-to-end-test/local/errorShots
destination: /errorShots
- store_test_results:
path: /tmp/repos/cbioportal-frontend/end-to-end-test/local/junit
- store_artifacts:
path: /tmp/repos/cbioportal-frontend/end-to-end-test/local/junit
- store_artifacts:
path: /tmp/repos/cbioportal-frontend/end-to-end-test/shared/imageCompare.html
destination: /imageCompare.html
environment:
PORTAL_SOURCE_DIR: /tmp/repos/cbioportal-frontend/
TEST_HOME: /tmp/repos/cbioportal-frontend/end-to-end-test/local
E2E_WORKSPACE: /tmp/repos/cbioportal-frontend/e2e-localdb-workspace
CBIO_DB_DATA_DIR: /tmp/repos/cbioportal-frontend/e2e-localdb-workspace/cbio_db_data
KC_DB_DATA_DIR: /tmp/repos/cbioportal-frontend/e2e-localdb-workspace/kc_db_data
DOCKER_IMAGE_SESSION_SERVICE: cbioportal/session-service:0.5.0
FRONTEND_TEST_DO_NOT_LOAD_EXTERNAL_FRONTEND: true
workflows:
version: 2
end_to_end_tests:
jobs:
- build_backend
- pull_frontend_codebase
- install_yarn:
requires:
- pull_frontend_codebase
- end_to_end_tests_localdb:
requires:
- build_backend
- pull_frontend_codebase
- install_yarn