156 строки
5.5 KiB
YAML
156 строки
5.5 KiB
YAML
version: 2.0
|
|
|
|
jobs:
|
|
build-deploy: # build for the master branch
|
|
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: |
|
|
docker version
|
|
docker build -t app:build -f Dockerfile.deploy .
|
|
docker tag app:build ${DOCKERHUB_REPO}:latest
|
|
docker login -u $DOCKERHUB_USER -p $DOCKERHUB_PASS
|
|
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: |
|
|
docker version
|
|
docker build -t app:build -f Dockerfile.deploy .
|
|
docker tag app:build ${DOCKERHUB_REPO}:${CIRCLE_TAG}
|
|
docker login -u $DOCKERHUB_USER -p $DOCKERHUB_PASS
|
|
docker push ${DOCKERHUB_REPO}:${CIRCLE_TAG}
|
|
integration_test:
|
|
working_directory: ~/addons-server
|
|
machine: true
|
|
steps:
|
|
- run:
|
|
name: Checkout git repository
|
|
command: |
|
|
if [ -n "$CIRCLE_PR_NUMBER" ]
|
|
then
|
|
git clone --depth 1 https://github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME.git ~/addons-server
|
|
|
|
git fetch origin "+refs/pull/$CIRCLE_PR_NUMBER/merge:"
|
|
git checkout -f FETCH_HEAD
|
|
else
|
|
git clone --depth 1 --branch $CIRCLE_BRANCH https://github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME.git ~/addons-server
|
|
|
|
if [ -n "$CIRCLE_TAG" ]
|
|
then
|
|
git fetch --force origin "refs/tags/${CIRCLE_TAG}"
|
|
fi
|
|
|
|
if [ -n "$CIRCLE_TAG" ]
|
|
then
|
|
git checkout --force "$CIRCLE_TAG"
|
|
else
|
|
git checkout --force "$CIRCLE_SHA1"
|
|
fi
|
|
fi
|
|
- restore_cache:
|
|
keys:
|
|
- uitest-cache-{{ checksum "requirements/docs.txt" }}
|
|
- uitest-cache-{{ checksum "requirements/prod_py2.txt" }}
|
|
- uitest-cache-{{ checksum "requirements/tests.txt" }}
|
|
- uitest-cache-{{ checksum "requirements/dev.txt" }}
|
|
- uitest-cache-{{ checksum "requirements/uitests.txt" }}
|
|
- uitest-cache-
|
|
- run:
|
|
name: Install Docker Compose
|
|
command: |
|
|
# using curl to install for better ci -> local compatibility
|
|
set -x
|
|
curl -L https://github.com/docker/compose/releases/download/1.19.0/docker-compose-`uname -s`-`uname -m` > ~/docker-compose
|
|
chmod +x ~/docker-compose
|
|
sudo mv ~/docker-compose /usr/local/bin/docker-compose
|
|
docker-compose --version
|
|
- run:
|
|
name: Start container, verify it's running and start tests
|
|
command: |
|
|
set -x
|
|
sudo sysctl -w vm.max_map_count=262144
|
|
docker-compose pull --quiet
|
|
docker-compose up -d
|
|
sleep 20
|
|
docker-compose ps
|
|
scripts/ui-test-hostname-setup.sh
|
|
# Make sure dependencies get updated in worker and web container
|
|
docker-compose exec worker make -f Makefile-docker update_deps
|
|
docker-compose restart worker
|
|
docker-compose exec web make -f Makefile-docker update_deps
|
|
docker-compose restart web
|
|
# Delete any existing uitest users within restmail. TEMP FIX: https://github.com/mozilla/addons-server/issues/8980
|
|
wget --method=DELETE http://restmail.net/mail/uitest
|
|
# mod user in firefox container
|
|
docker-compose exec selenium-firefox sudo usermod -u 1001 seluser
|
|
# proper chown
|
|
sudo chown -R $USER .
|
|
# Start Test in Firefox docker container
|
|
docker-compose exec selenium-firefox tox -e ui-tests
|
|
- store_artifacts:
|
|
path: ui-test.html
|
|
- save_cache:
|
|
key: uitest-cache-{{ checksum "requirements/docs.txt" }}
|
|
paths:
|
|
- .tox
|
|
- save_cache:
|
|
key: uitest-cache-{{ checksum "requirements/prod_py2.txt" }}
|
|
paths:
|
|
- .tox
|
|
- save_cache:
|
|
key: uitest-cache-{{ checksum "requirements/tests.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
|
|
|
|
workflows:
|
|
version: 2
|
|
build_test_deploy_release:
|
|
jobs:
|
|
- build-deploy:
|
|
filters:
|
|
branches:
|
|
only: master
|
|
- build-release:
|
|
filters:
|
|
tags:
|
|
only: /.*/
|
|
branches:
|
|
ignore: /.*/
|
|
- integration_test
|