182 строки
6.9 KiB
YAML
182 строки
6.9 KiB
YAML
version: 2.1
|
|
|
|
commands:
|
|
build_and_push_container_image:
|
|
description: "Builds and pushes a Docker image"
|
|
parameters:
|
|
dockerfile:
|
|
type: string
|
|
default: "Dockerfile.deploy"
|
|
image_tag:
|
|
type: string
|
|
default: "latest"
|
|
steps:
|
|
- 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 << parameters.dockerfile >> .
|
|
docker tag app:build "${DOCKERHUB_REPO}":<< parameters.image_tag >>
|
|
docker login -u "${DOCKERHUB_USER}" -p "${DOCKERHUB_PASS}"
|
|
docker push "${DOCKERHUB_REPO}":<< parameters.image_tag >>
|
|
jobs:
|
|
build:
|
|
machine: true
|
|
working_directory: ~/addons-server
|
|
steps:
|
|
- checkout
|
|
- build_and_push_container_image:
|
|
image_tag: latest
|
|
dockerfile: "Dockerfile.deploy"
|
|
|
|
build-tag:
|
|
machine: true
|
|
working_directory: ~/addons-server
|
|
steps:
|
|
- checkout
|
|
- build_and_push_container_image:
|
|
image_tag: "${CIRCLE_TAG}"
|
|
dockerfile: "Dockerfile.deploy"
|
|
|
|
integration_test:
|
|
working_directory: ~/addons-server
|
|
machine:
|
|
image: ubuntu-1604:201903-01
|
|
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.txt" }}
|
|
- uitest-cache-{{ checksum "requirements/tests.txt" }}
|
|
- uitest-cache-{{ checksum "requirements/dev.txt" }}
|
|
- uitest-cache-{{ checksum "requirements/dev_without_hash.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: Set hosts
|
|
command: |
|
|
echo 127.0.0.1 olympia.test | sudo tee -a /etc/hosts
|
|
cat /etc/hosts
|
|
- run:
|
|
name: Start container, verify it's running and start tests
|
|
environment:
|
|
MOZ_HEADLESS: 1
|
|
command: |
|
|
set -x
|
|
sudo sysctl -w vm.max_map_count=262144
|
|
# Install UUID
|
|
sudo apt-get update -qqy && sudo apt-get -qqy install uuid
|
|
export UITEST_FXA_EMAIL=uitest-$(uuid)@restmail.net
|
|
# Pull images
|
|
docker-compose -f docker-compose.yml -f tests/ui/docker-compose.selenium.yml pull --quiet
|
|
# Start Containers
|
|
docker-compose -f docker-compose.yml -f tests/ui/docker-compose.selenium.yml up -d
|
|
sleep 20
|
|
docker-compose -f docker-compose.yml -f tests/ui/docker-compose.selenium.yml ps
|
|
# Make sure dependencies get updated in worker and web container
|
|
docker-compose -f docker-compose.yml -f tests/ui/docker-compose.selenium.yml exec worker make -f Makefile-docker update_deps update_assets
|
|
docker-compose -f docker-compose.yml -f tests/ui/docker-compose.selenium.yml restart worker
|
|
docker-compose -f docker-compose.yml -f tests/ui/docker-compose.selenium.yml exec web make -f Makefile-docker update_deps update_assets
|
|
docker-compose -f docker-compose.yml -f tests/ui/docker-compose.selenium.yml restart web
|
|
# mod user in firefox container
|
|
docker-compose -f docker-compose.yml -f tests/ui/docker-compose.selenium.yml exec selenium-firefox sudo usermod -u 1001 seluser
|
|
# proper chown
|
|
sudo chown -R $USER:$USER .
|
|
# Run Ui-tests setup
|
|
docker-compose -f docker-compose.yml -f tests/ui/docker-compose.selenium.yml exec web make setup-ui-tests
|
|
# Make sure everything is started
|
|
docker-compose -f docker-compose.yml -f tests/ui/docker-compose.selenium.yml up -d
|
|
sleep 10
|
|
docker-compose -f docker-compose.yml -f tests/ui/docker-compose.selenium.yml exec selenium-firefox sudo chown -R seluser:seluser .
|
|
# Start auto approve script
|
|
docker-compose -f docker-compose.yml -f tests/ui/docker-compose.selenium.yml exec -T web make -f Makefile-docker run-auto-approve &
|
|
# Start Test in Firefox docker container
|
|
docker-compose -f docker-compose.yml -f tests/ui/docker-compose.selenium.yml exec selenium-firefox tox -r -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.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/dev_without_hash.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:
|
|
filters:
|
|
branches:
|
|
only: master
|
|
- build-tag:
|
|
filters:
|
|
tags:
|
|
only: /.*/
|
|
branches:
|
|
ignore: /.*/
|
|
- integration_test
|