2017-10-05 14:14:08 +03:00
|
|
|
version: 2.0
|
2016-06-27 11:57:25 +03:00
|
|
|
|
2017-10-05 14:14:08 +03:00
|
|
|
jobs:
|
2017-10-06 18:43:42 +03:00
|
|
|
build-deploy: # build for the master branch
|
2017-10-05 14:14:08 +03:00
|
|
|
machine: true
|
|
|
|
working_directory: ~/addons-server
|
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- run: >
|
|
|
|
printf '{"commit":"%s","version":"%s","source":"https://github.com/%s/%s","build":"%s"}\n'
|
|
|
|
"$CIRCLE_SHA1"
|
|
|
|
"$CIRCLE_TAG"
|
|
|
|
"$CIRCLE_PROJECT_USERNAME"
|
|
|
|
"$CIRCLE_PROJECT_REPONAME"
|
|
|
|
"$CIRCLE_BUILD_URL"
|
|
|
|
> version.json
|
2017-10-05 18:00:43 +03:00
|
|
|
- run:
|
2017-10-06 18:43:42 +03:00
|
|
|
name: Build docker image and push to repo
|
2017-10-05 18:00:43 +03:00
|
|
|
command: |
|
2017-12-01 20:52:04 +03:00
|
|
|
docker version
|
2017-10-05 18:00:43 +03:00
|
|
|
docker build -t app:build -f Dockerfile.deploy .
|
2017-10-06 18:43:42 +03:00
|
|
|
docker tag app:build ${DOCKERHUB_REPO}:latest
|
2017-12-01 20:52:04 +03:00
|
|
|
docker login -u $DOCKERHUB_USER -p $DOCKERHUB_PASS
|
2017-10-06 18:43:42 +03:00
|
|
|
docker push ${DOCKERHUB_REPO}:latest
|
|
|
|
build-release: # build for releases (tags)
|
|
|
|
machine: true
|
|
|
|
working_directory: ~/addons-server
|
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- run: >
|
|
|
|
printf '{"commit":"%s","version":"%s","source":"https://github.com/%s/%s","build":"%s"}\n'
|
|
|
|
"$CIRCLE_SHA1"
|
|
|
|
"$CIRCLE_TAG"
|
|
|
|
"$CIRCLE_PROJECT_USERNAME"
|
|
|
|
"$CIRCLE_PROJECT_REPONAME"
|
|
|
|
"$CIRCLE_BUILD_URL"
|
|
|
|
> version.json
|
|
|
|
- run:
|
|
|
|
name: Build docker image and push to repo
|
|
|
|
command: |
|
2017-12-01 20:52:04 +03:00
|
|
|
docker version
|
2017-10-06 18:43:42 +03:00
|
|
|
docker build -t app:build -f Dockerfile.deploy .
|
|
|
|
docker tag app:build ${DOCKERHUB_REPO}:${CIRCLE_TAG}
|
2017-12-01 20:52:04 +03:00
|
|
|
docker login -u $DOCKERHUB_USER -p $DOCKERHUB_PASS
|
2017-10-06 18:43:42 +03:00
|
|
|
docker push ${DOCKERHUB_REPO}:${CIRCLE_TAG}
|
2017-10-05 14:14:08 +03:00
|
|
|
integration_test:
|
|
|
|
working_directory: ~/addons-server
|
|
|
|
machine: true
|
|
|
|
steps:
|
2018-02-05 09:55:29 +03:00
|
|
|
- run:
|
|
|
|
name: Checkout git repository
|
|
|
|
command: |
|
|
|
|
git clone $CIRCLE_REPOSITORY_URL $CIRCLE_WORKING_DIRECTORY --depth=1
|
|
|
|
|
|
|
|
if [ -n "$CIRCLE_TAG" ]
|
|
|
|
then
|
|
|
|
git reset --hard "$CIRCLE_SHA1"
|
|
|
|
git checkout -q "$CIRCLE_TAG"
|
|
|
|
elif [ -n "$CIRCLE_BRANCH" ]
|
|
|
|
then
|
|
|
|
git reset --hard "$CIRCLE_SHA1"
|
|
|
|
git checkout -q -B "$CIRCLE_BRANCH"
|
|
|
|
fi
|
|
|
|
|
|
|
|
git reset --hard "$CIRCLE_SHA1"
|
2017-10-05 14:14:08 +03:00
|
|
|
- restore_cache:
|
|
|
|
keys:
|
|
|
|
- uitest-cache-{{ checksum "requirements/docs.txt" }}
|
|
|
|
- uitest-cache-{{ checksum "requirements/prod.txt" }}
|
|
|
|
- uitest-cache-{{ checksum "requirements/dev.txt" }}
|
|
|
|
- uitest-cache-{{ checksum "requirements/uitests.txt" }}
|
|
|
|
- uitest-cache-
|
|
|
|
- run:
|
|
|
|
name: Install Docker Compose
|
|
|
|
command: |
|
|
|
|
set -x
|
2018-01-12 08:58:00 +03:00
|
|
|
pip install docker-compose>=1.18
|
|
|
|
docker-compose --version
|
2017-10-05 14:14:08 +03:00
|
|
|
- run:
|
|
|
|
name: Start container, verify it's running and start tests
|
|
|
|
command: |
|
|
|
|
set -x
|
|
|
|
sudo sysctl -w vm.max_map_count=262144
|
|
|
|
docker-compose up -d
|
2017-10-16 12:16:41 +03:00
|
|
|
sleep 20
|
|
|
|
docker-compose ps
|
|
|
|
# Make sure dependencies get updated in worker and web container
|
|
|
|
docker-compose exec worker make -f Makefile-docker update_deps
|
|
|
|
docker-compose exec worker supervisorctl restart all
|
|
|
|
docker-compose exec web make -f Makefile-docker update_deps
|
|
|
|
docker-compose exec web supervisorctl restart all
|
2018-01-12 08:58:00 +03:00
|
|
|
# Start Test in Firefox docker container
|
|
|
|
docker-compose exec selenium-firefox tox -e ui-tests
|
2017-10-05 14:14:08 +03:00
|
|
|
- store_artifacts:
|
2018-01-12 08:58:00 +03:00
|
|
|
path: ui-test.html
|
2017-10-05 14:14:08 +03:00
|
|
|
- save_cache:
|
|
|
|
key: uitest-cache-{{ checksum "requirements/docs.txt" }}
|
|
|
|
paths:
|
|
|
|
- .tox
|
|
|
|
- save_cache:
|
|
|
|
key: uitest-cache-{{ checksum "requirements/prod.txt" }}
|
|
|
|
paths:
|
|
|
|
- .tox
|
|
|
|
- save_cache:
|
|
|
|
key: uitest-cache-{{ checksum "requirements/dev.txt" }}
|
|
|
|
paths:
|
|
|
|
- .tox
|
|
|
|
- save_cache:
|
|
|
|
key: uitest-cache-{{ checksum "requirements/uitests.txt" }}
|
|
|
|
paths:
|
|
|
|
- .tox
|
|
|
|
- save_cache:
|
|
|
|
key: uitest-cache-
|
|
|
|
paths:
|
|
|
|
- .tox
|
2017-10-16 12:16:41 +03:00
|
|
|
|
2017-10-05 14:14:08 +03:00
|
|
|
workflows:
|
|
|
|
version: 2
|
|
|
|
build_test_deploy_release:
|
|
|
|
jobs:
|
2017-10-06 18:43:42 +03:00
|
|
|
- build-deploy:
|
2017-10-05 14:14:08 +03:00
|
|
|
filters:
|
|
|
|
branches:
|
|
|
|
only: master
|
2017-10-06 18:43:42 +03:00
|
|
|
- build-release:
|
2017-10-05 14:14:08 +03:00
|
|
|
filters:
|
|
|
|
tags:
|
|
|
|
only: /.*/
|
|
|
|
branches:
|
|
|
|
ignore: /.*/
|
2017-10-06 18:43:42 +03:00
|
|
|
- integration_test
|