experimenter/.circleci/config.yml

332 строки
12 KiB
YAML
Executable File

version: 2.1
orbs:
gh: circleci/github-cli@2.0
jobs:
check:
machine:
image: ubuntu-2004:202107-02 # Ubuntu 20.04, Docker v20.10.7, Docker Compose v1.29.2
docker_layer_caching: true
resource_class: large
working_directory: ~/experimenter
steps:
- run:
name: Docker info
command: docker -v
- run:
name: Docker compose info
command: docker-compose -v
- checkout
- run:
name: Run tests and linting
command: |
cp .env.sample .env
make check
integration_nimbus_desktop_release:
machine:
image: ubuntu-2004:202107-02 # Ubuntu 20.04, Docker v20.10.7, Docker Compose v1.29.2
docker_layer_caching: true
resource_class: xlarge
working_directory: ~/experimenter
environment:
FIREFOX_VERSION: nimbus-firefox-release
PYTEST_ARGS: -k DESKTOP -m run_targeting -n 2
MOZ_REMOTE_SETTINGS_DEVTOOLS: 1 # allows us to override and set the remote settings URL
steps:
- checkout
- run:
name: Check file paths
command: |
if git diff --name-only main HEAD | grep -E 'app/experimenter/targeting|app/experimenter/experiments'
then
echo "Continuing"
else
echo "No targeting changes, skipping"
circleci-agent step halt
fi
- run:
name: Run integration tests
command: |
cp .env.integration-tests .env
make refresh SKIP_DUMMY=1 up_prod_detached integration_test_nimbus PYTEST_ARGS="$PYTEST_ARGS"
integration_nimbus_desktop_beta:
machine:
image: ubuntu-2004:202107-02 # Ubuntu 20.04, Docker v20.10.7, Docker Compose v1.29.2
docker_layer_caching: true
resource_class: xlarge
working_directory: ~/experimenter
environment:
FIREFOX_VERSION: nimbus-firefox-beta
PYTEST_ARGS: -k DESKTOP -m run_targeting -n 2
MOZ_REMOTE_SETTINGS_DEVTOOLS: 1 # allows us to override and set the remote settings URL
steps:
- checkout
- run:
name: Check file paths
command: |
if git diff --name-only main HEAD | grep -E 'app/experimenter/targeting|app/experimenter/experiments'
then
echo "Continuing"
else
echo "No targeting changes, skipping"
circleci-agent step halt
fi
- run:
name: Run integration tests
command: |
cp .env.integration-tests .env
make refresh SKIP_DUMMY=1 up_prod_detached integration_test_nimbus PYTEST_ARGS="$PYTEST_ARGS"
integration_nimbus_desktop:
machine:
image: ubuntu-2004:202107-02 # Ubuntu 20.04, Docker v20.10.7, Docker Compose v1.29.2
docker_layer_caching: true
resource_class: xlarge
working_directory: ~/experimenter
parallelism: 7 # This should match the number of entries in parallel_pytest_args.txt
environment:
FIREFOX_VERSION: nimbus-firefox-release
steps:
- checkout
- run:
name: Run integration tests
command: |
PYTEST_ARGS=$(circleci tests split "app/tests/integration/nimbus/parallel_pytest_args.txt")
cp .env.integration-tests .env
make refresh SKIP_DUMMY=1 UPDATE_FIREFOX_VERSION="true" up_prod_detached integration_test_nimbus PYTEST_ARGS="$PYTEST_ARGS"
integration_nimbus_sdk:
machine:
image: ubuntu-2004:202107-02 # Ubuntu 20.04, Docker v20.10.7, Docker Compose v1.29.2
docker_layer_caching: true
resource_class: medium
working_directory: ~/experimenter
steps:
- checkout
- run:
name: Check file paths
command: |
if git diff --name-only main HEAD | grep -E 'app/experimenter/targeting|app/experimenter/experiments'
then
echo "Continuing"
else
echo "No targeting changes, skipping"
circleci-agent step halt
fi
- run:
name: Run rust integration tests
command: |
cp .env.integration-tests .env
make refresh SKIP_DUMMY=1 up_prod_detached integration_test_nimbus_rust PYTEST_ARGS="$PYTEST_ARGS"
integration_legacy:
machine:
image: ubuntu-2004:202107-02 # Ubuntu 20.04, Docker v20.10.7, Docker Compose v1.29.2
docker_layer_caching: true
resource_class: large
working_directory: ~/experimenter
environment:
FIREFOX_VERSION: nimbus-firefox-release
steps:
- run:
name: Docker info
command: docker -v
- run:
name: Docker compose info
command: docker-compose -v
- checkout
- run:
name: Run integration tests
command: |
cp .env.sample .env
make refresh
make up_prod_detached
make integration_test_legacy
deploy:
working_directory: ~/experimenter
machine:
image: ubuntu-2004:202107-02 # Ubuntu 20.04, Docker v20.10.7, Docker Compose v1.29.2
docker_layer_caching: true
steps:
- checkout
- deploy:
name: Deploy to latest
command: |
docker login -u $DOCKER_USER -p $DOCKER_PASS
make build_dev build_test build_ui
./scripts/store_git_info.sh
make build_prod
docker tag app:dev ${DOCKERHUB_REPO}:build_dev
docker tag app:test ${DOCKERHUB_REPO}:build_test
docker tag app:ui ${DOCKERHUB_REPO}:build_ui
docker tag app:deploy ${DOCKERHUB_REPO}:latest
docker push ${DOCKERHUB_REPO}:build_dev
docker push ${DOCKERHUB_REPO}:build_test
docker push ${DOCKERHUB_REPO}:build_ui
docker push ${DOCKERHUB_REPO}:latest
update_external_configs:
working_directory: ~/experimenter
machine:
image: ubuntu-2004:202107-02 # Ubuntu 20.04, Docker v20.10.7, Docker Compose v1.29.2
docker_layer_caching: true
steps:
- add_ssh_keys:
fingerprints:
- "6f:26:1b:06:f2:32:62:65:bd:92:be:a9:2f:7b:65:59" # for git pushes from circleci, since relies on ssh
- checkout
- gh/setup:
token: GH_TOKEN # for gh commands from circleci, since relies on user token, since por que no los dos?
- run:
name: Setup Git
command: |
git config --local user.name "dataops-ci-bot"
git config --local user.email "dataops+ci-bot@mozilla.com"
gh config set git_protocol https
- run:
name: Check for External Config Update
command: |
git checkout main
git pull origin main
make fetch_external_resources
if (($(git status --porcelain | wc -c) > 0))
then
git checkout -B external-config
git add .
git commit -m 'chore(nimbus): Update External Configs'
if (($((git diff external-config origin/external-config || git diff HEAD~1) | wc -c) > 0))
then
git push origin external-config -f
gh pr create -t "chore(nimbus): Update External Configs" -b "" --base main --head external-config --repo mozilla/experimenter || echo "PR already exists, skipping"
else
echo "Changes already committed, skipping"
fi
else
echo "No config changes, skipping"
fi
build_firefox_versions:
working_directory: ~/experimenter
machine:
image: ubuntu-2004:202107-02 # Ubuntu 20.04, Docker v20.10.7, Docker Compose v1.29.2
docker_layer_caching: true
steps:
- checkout
- run:
name: Check for Firefox Update
command: |
set +e
docker pull ${DOCKERHUB_REPO}:nimbus-firefox-beta
docker run -d --name firefox-beta ${DOCKERHUB_REPO}:nimbus-firefox-beta
docker_id=$(docker ps -aqf "name=^firefox-beta")
docker cp $docker_id:/old_versions.txt /home/circleci/experimenter/old_versions.txt
results=$(sudo ./.circleci/get_firefox_versions.sh)
DIFF=$(diff /home/circleci/experimenter/new_versions.txt /home/circleci/experimenter/old_versions.txt)
if [ ! "$DIFF" ]; then
echo "No Firefox Version Changes found!"
circleci-agent step halt
fi
- run:
name: Get Firefox Versions
command: |
git clone --depth=1 git@github.com:SeleniumHQ/docker-selenium.git
cd docker-selenium
if echo "$results" | grep -q "BETA"; then
BUILD_ARGS="--build-arg FIREFOX_VERSION=devedition-latest" VERSION="firefox" BUILD_DATE="beta" make standalone_firefox
fi
if echo "$results" | grep -q "RELEASE"; then
BUILD_ARGS="--build-arg FIREFOX_VERSION=latest" VERSION="firefox" BUILD_DATE="release" make standalone_firefox
fi
- run:
name: Save Images
command: |
results=$(sudo ./.circleci/get_firefox_versions.sh)
mv /home/circleci/experimenter/new_versions.txt /home/circleci/experimenter/old_versions.txt
cd docker-selenium
BUILD_ARGS="--build-arg FIREFOX_VERSION=latest" VERSION="firefox" BUILD_DATE="release" make standalone_firefox
BUILD_ARGS="--build-arg FIREFOX_VERSION=devedition-latest" VERSION="firefox" BUILD_DATE="beta" make standalone_firefox
# Save release
docker run -d --name firefox-release-build selenium/standalone-firefox:firefox-release
docker_id=$(docker ps -aqf "name=^firefox-release-build")
docker cp /home/circleci/experimenter/old_versions.txt $docker_id:/old_versions.txt
docker commit $docker_id ${DOCKERHUB_REPO}:nimbus-firefox-release
# Save Dev
docker run -d --name firefox-beta-build selenium/standalone-firefox:firefox-beta
docker_id=$(docker ps -aqf "name=^firefox-beta-build")
docker cp /home/circleci/experimenter/old_versions.txt $docker_id:/old_versions.txt
docker commit $docker_id ${DOCKERHUB_REPO}:nimbus-firefox-beta
docker login -u $DOCKER_USER -p $DOCKER_PASS
docker push ${DOCKERHUB_REPO}:nimbus-firefox-beta
docker push ${DOCKERHUB_REPO}:nimbus-firefox-release
- save_cache:
key: version-cache-{{ checksum "old_versions.txt" }}
paths:
- /home/circleci/experimenter/old_versions.txt
workflows:
version: 2
weekly:
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
- main
jobs:
- build_firefox_versions
hourly:
triggers:
- schedule:
cron: "0 * * * *"
filters:
branches:
only:
- main
jobs:
- update_external_configs
build:
jobs:
- check:
name: check
- integration_nimbus_desktop_release:
name: integration_nimbus_desktop_release
filters:
branches:
ignore:
- main
- integration_nimbus_desktop_beta:
name: integration_nimbus_desktop_beta
filters:
branches:
ignore:
- main
- integration_nimbus_desktop:
name: integration_nimbus_desktop
filters:
branches:
ignore:
- main
- integration_nimbus_sdk:
name: integration_nimbus_sdk
filters:
branches:
ignore:
- main
- integration_legacy:
name: integration_legacy
filters:
branches:
ignore:
- main
- deploy:
filters:
branches:
only: main
requires:
- check