# References: # 1. https://circleci.com/blog/how-to-build-a-docker-image-on-circleci-2-0/ # 2. https://circleci.com/docs/2.0/building-docker-images/ # version: 2 main_filters: &main_filters branches: ignore: - /^(?:release|test)-20\d\d\d\d\d\d\.\d+/ - /\// - production defaults: bmo_slim_image: &bmo_slim_image image: mozillabteam/bmo-slim:20180325.1 user: app mysql_image: &mysql_image image: mozillabteam/bmo-mysql:5.6 bmo_env: &bmo_env PORT: 8000 LOGGING_PORT: 5880 LOCALCONFIG_ENV: 1 LOG4PERL_CONFIG_FILE: log4perl-test.conf BMO_db_user: bugs BMO_db_host: 127.0.0.1 BMO_db_pass: bugs BMO_db_name: bugs BMO_memcached_servers: localhost:11211 BMO_memcached_namespace: "bugzilla:" BMO_urlbase: AUTOMATIC HTTPD_StartServers: 1 HTTPD_MinSpareServers: 1 HTTPD_MaxSpareServers: 1 HTTPD_ServerLimit: 1 HTTPD_MaxClients: 1 HTTPD_MaxRequestsPerChild: 4000 mysql_env: &mysql_env MYSQL_DATABASE: bugs MYSQL_USER: bugs MYSQL_PASSWORD: bugs MYSQL_ALLOW_EMPTY_PASSWORD: 1 docker_oldtests: &docker_oldtests - <<: *bmo_slim_image environment: <<: *bmo_env BZ_QA_CONF_FILE: /app/.circleci/selenium_test.conf BZ_QA_ANSWERS_FILE: /app/.circleci/checksetup_answers.legacy.txt BZ_QA_LEGACY_MODE: 1 - <<: *mysql_image environment: *mysql_env - image: selenium/standalone-firefox:2.53.1 - image: memcached:latest default_qa_setup: &default_qa_setup run: name: default qa setup command: | mv /opt/bmo/local /app/local perl -MSys::Hostname -i -pE 's/bmo.test/hostname() . ":$ENV{PORT}"/ges' $BZ_QA_CONF_FILE perl checksetup.pl --no-database --default-localconfig mkdir artifacts jobs: build_info: parallelism: 1 working_directory: /app docker: - <<: *bmo_slim_image environment: <<: *bmo_env steps: - checkout - run: name: build push data command: | mv /opt/bmo/local /app/local perl checksetup.pl --no-database --no-templates --no-permissions perl scripts/build-bmo-push-data.pl - run: name: only publish if tag exists command: | tag="$(cat build_info/tag.txt)" git fetch --tags if git tag | fgrep -q "$tag"; then echo "tag $tag exists!" else echo "tag $tag does not exist" echo yes > build_info/publish.txt fi - persist_to_workspace: root: /app/build_info paths: ["*.txt"] - store_artifacts: path: /app/build_info build: working_directory: /app docker: - image: docker:17.06.1-ce steps: - setup_remote_docker - run: name: install git and ssh command: apk update && apk add git openssh-client - checkout - run: | docker build \ --build-arg CI="$CI" \ --build-arg CIRCLE_SHA1="$CIRCLE_SHA1" \ --build-arg CIRCLE_BUILD_URL="$CIRCLE_BUILD_URL" \ -t bmo . - attach_workspace: at: /app/build_info - run: "docker run --name bmo --entrypoint true bmo" - run: "docker cp bmo:/app/version.json build_info/version.json" - store_artifacts: path: /app/build_info - deploy: command: | TAG="$(cat /app/build_info/tag.txt)" [[ "$CIRCLE_BRANCH" == "master" && -n "$TAG" ]] || exit 0 [[ -n "$DOCKERHUB_REPO" && -n "$DOCKER_USER" && -n "$DOCKER_PASS" ]] || exit 0 [[ -n "$GITHUB_PERSONAL_TOKEN" ]] || exit 0 [[ -f build_info/publish.txt ]] || exit 0 git config credential.helper cache git config user.email "$GITHUB_EMAIL" git config user.name "$GITHUB_NAME" git tag $TAG git push https://${GITHUB_PERSONAL_TOKEN}:x-oauth-basic@github.com/$GITHUB_REPO.git $TAG docker tag bmo "$DOCKERHUB_REPO:$TAG" docker login -u "$DOCKER_USER" -p "$DOCKER_PASS" docker push "$DOCKERHUB_REPO:$TAG" test_sanity: parallelism: 2 working_directory: /app docker: - <<: *bmo_slim_image environment: *bmo_env steps: - checkout - run: | mv /opt/bmo/local /app/local mkdir artifacts - run: perl Makefile.PL - run: name: run sanity tests command: | /app/scripts/entrypoint.pl prove -qf $(circleci tests glob 't/*.t' | circleci tests split) | tee artifacts/$CIRCLE_JOB.txt - store_artifacts: path: /app/artifacts test_webservices: parallelism: 1 working_directory: /app docker: *docker_oldtests steps: - checkout - *default_qa_setup - run: | /app/scripts/entrypoint.pl load_test_data - run: command: | /app/scripts/entrypoint.pl test_webservices | tee artifacts/$CIRCLE_JOB.txt - store_artifacts: path: /app/artifacts test_selenium: parallelism: 1 working_directory: /app docker: *docker_oldtests steps: - checkout - *default_qa_setup - run: | /app/scripts/entrypoint.pl load_test_data --legacy - run: command: | /app/scripts/entrypoint.pl test_selenium | tee artifacts/$CIRCLE_JOB.txt - store_artifacts: path: /app/artifacts test_bmo: parallelism: 1 working_directory: /app docker: - <<: *bmo_slim_image environment: <<: *bmo_env BZ_QA_ANSWERS_FILE: /app/.circleci/checksetup_answers.txt TWD_HOST: localhost TWD_PORT: 4444 TWD_BROWSER: firefox - <<: *mysql_image environment: *mysql_env - image: memcached:latest - image: selenium/standalone-firefox:2.53.1 steps: - checkout - run: | mv /opt/bmo/local /app/local perl checksetup.pl --no-database /app/scripts/entrypoint.pl load_test_data mkdir artifacts - run: /app/scripts/entrypoint.pl test_bmo -q -f t/bmo/*.t workflows: version: 2 main: jobs: - build_info: filters: *main_filters - build: filters: *main_filters requires: - build_info - test_sanity - test_bmo - test_webservices - test_selenium - test_sanity: filters: *main_filters requires: - build_info - test_bmo: filters: *main_filters requires: - build_info - test_webservices: filters: *main_filters requires: - build_info - test_selenium: filters: *main_filters requires: - build_info