-
Notifications
You must be signed in to change notification settings - Fork 432
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
On the road to end2end localdb tests
- Loading branch information
Showing
1 changed file
with
182 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,182 @@ | ||
version: 2 | ||
jobs: | ||
build: | ||
docker: | ||
- image: circleci/ruby:2.4.1 | ||
steps: | ||
- checkout | ||
- run: echo "A first hello" | ||
defaults: &defaults | ||
docker: | ||
- image: circleci/node:8.12.0-browsers | ||
|
||
version: 2 | ||
jobs: | ||
determine_frontend_codebase: | ||
<<: *defaults | ||
working_directory: /tmp/repos/cbioportal | ||
steps: | ||
- checkout | ||
- run: | ||
name: Check if end-to-end tests are required | ||
command: | | ||
echo $(grep 'frontend\.version' cbioportal/pom.xml | sed 's/<frontend\.version>//g' | sed 's|</frontend\.version>||' | tr -d '[:blank:]') >> /tmp/repos/FRONTEND_VERSION | ||
- persist_to_workspace: | ||
root: /tmp/repos | ||
paths: | ||
FRONTEND_VERSION | ||
|
||
setup_frontend: | ||
<<: *defaults | ||
working_directory: /tmp/repos/cbioportal-frontend | ||
steps: | ||
- attach_workspace: | ||
at: /tmp/repos | ||
- run: | | ||
if [ ! -f /tmp/repos/FRONTEND_VERSION ]; then | ||
circleci-agent step halt | ||
fi | ||
- run: | ||
name: Pull frontend code | ||
command: | | ||
export FRONTEND_VERSION=$(cat ../FRONTEND_VERSION) && \ | ||
cd .. && \ | ||
git clone https://github.com/$CIRCLE_PROJECT_USERNAME/cbioportal-frontend.git && \ | ||
cd cbioportal-frontend && \ | ||
git fetch --tags && \ | ||
git checkout ${FRONTEND_VERSION} | ||
- run: | ||
name: "Install yarn at specific version" | ||
command: | ||
sudo npm install --global yarn@1.13.0 | ||
- 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: | ||
- v2-dependencies-plus-dist-{{ checksum "has_source_changed" }} | ||
- v2-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: v2-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 | ||
- save_cache: | ||
paths: | ||
- node_modules | ||
- dist | ||
- common-dist | ||
key: v2-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: | | ||
if [ ! -f /tmp/repos/FRONTEND_VERSION ]; then | ||
circleci-agent step halt | ||
fi | ||
- 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.5.2 && virtualenv venv | ||
- run: | ||
name: Setup python libraries | ||
command: | | ||
pip3 install requests pyyaml | ||
- run: | ||
name: Setup e2e-environment | ||
command: | | ||
echo -e "\nexport BACKEND=$CIRCLE_PR_USERNAME:$CIRCLE_SHA1" >> $PORTAL_SOURCE_DIR/env/custom.sh && \ | ||
source $PORTAL_SOURCE_DIR/env/custom.sh || true && \ | ||
cd $TEST_HOME/local/runtime-config && \ | ||
./setup_environment.sh && ./setup_environment.sh >> $BASH_ENV | ||
- run: | ||
name: Generate checksum of data that populates the test database | ||
command: | | ||
$TEST_HOME/local/runtime-config/db_content_fingerprint.sh > /tmp/db_data_md5key | ||
- restore_cache: | ||
keys: | ||
- v4-e2e-database-files-{{ checksum "/tmp/db_data_md5key" }} | ||
- run: | ||
name: Create MySQL data directory when no cache found | ||
command: | | ||
mkdir -p $DB_DATA_DIR | ||
- run: | ||
name: Setup docker images and containers | ||
command: | | ||
docker network create $DOCKER_NETWORK_NAME && \ | ||
cd $TEST_HOME/local/docker && \ | ||
if (ls $DB_DATA_DIR/* 2> /dev/null > /dev/null); then \ | ||
./setup_docker_containers.sh -p -e; \ | ||
else \ | ||
./setup_docker_containers.sh -p -e -d; \ | ||
fi | ||
- run: | ||
name: Change owner of MySQL database files (needed by cache) | ||
command: | | ||
sudo chmod -R 777 $DB_DATA_DIR && \ | ||
sudo chown -R circleci:circleci $DB_DATA_DIR | ||
- save_cache: | ||
paths: | ||
- /tmp/mysql | ||
key: v4-e2e-database-files-{{ checksum "/tmp/db_data_md5key" }} | ||
- run: | ||
name: Run end-2-end tests with studies in local database | ||
command: | | ||
cd $PORTAL_SOURCE_DIR && $TEST_HOME/local/runtime-config/run_container_screenshot_test.sh | ||
- run: | ||
name: "Make sure all screenshots are tracked (otherwise the test will always be successful)" | ||
command: 'for f in $TEST_HOME/local/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 | ||
FRONTEND_TEST_USE_LOCAL_DIST: true | ||
NO_PARALLEL: true | ||
|
||
|
||
workflows: | ||
version: 2 | ||
end_to_end_tests: | ||
jobs: | ||
- determine_frontend_codebase | ||
- setup_frontend: | ||
requires: | ||
- determine_frontend_codebase | ||
- end_to_end_tests_localdb: | ||
requires: | ||
- determine_frontend_codebase | ||
- setup_frontend |