experimenter/.circleci/config.yml

725 строки
25 KiB
YAML
Executable File

version: 2.1
orbs:
gh: circleci/github-cli@2.2
gcp-cli: circleci/gcp-cli@3.1.1
commands:
check_file_paths:
description: "Check file paths"
parameters:
paths:
type: string
default: ""
steps:
- run:
name: Check file paths
command: |
# Check if CIRCLE_BRANCH is "main" and skip the check
if [ "$CIRCLE_BRANCH" == "main" ]; then
echo "On main branch. Skipping path checks."
exit 0
fi
diff_output=$(git diff --name-only main HEAD)
echo "Changed files:"
echo "$diff_output"
if echo "$diff_output" | grep -E '<< parameters.paths >>|^[^/]+$|^.circleci/|application-services/'
then
echo "Changes detected in << parameters.paths >> or .circleci or root directory. Running tests and linting."
else
echo "No changes in << parameters.paths >> or .circleci or root directory. Skipping tests and linting."
circleci-agent step halt
fi
docker_login:
description: "Login to Docker"
parameters:
username:
type: string
password:
type: string
steps:
- run: |
echo "<< parameters.password >>" | docker login --username << parameters.username >> --password-stdin
jobs:
check_experimenter_x86_64:
machine:
image: ubuntu-2004:2023.10.1
docker_layer_caching: true
resource_class: large
working_directory: ~/experimenter
steps:
- checkout
- check_file_paths:
paths: "experimenter/"
- run:
name: Run tests and linting
command: |
cp .env.sample .env
make check
check_experimenter_aarch64:
machine:
image: ubuntu-2004:2023.10.1
docker_layer_caching: true
resource_class: arm.large
working_directory: ~/experimenter
steps:
- checkout
- check_file_paths:
paths: "experimenter/"
- run:
name: Run tests and linting
command: |
cp .env.sample .env
make check
check_cirrus_x86_64:
machine:
image: ubuntu-2004:2023.10.1
docker_layer_caching: true
resource_class: large
working_directory: ~/cirrus
steps:
- checkout
- check_file_paths:
paths: "cirrus/"
- run:
name: Run Cirrus tests and linting
command: |
make cirrus_check
check_cirrus_aarch64:
machine:
image: ubuntu-2004:2023.10.1
docker_layer_caching: true
resource_class: arm.large
working_directory: ~/cirrus
steps:
- checkout
- check_file_paths:
paths: "cirrus/"
- run:
name: Run Cirrus tests and linting
command: |
make cirrus_check
check_schemas:
machine:
image: ubuntu-2004:2023.10.1
docker_layer_caching: true
steps:
- checkout
- check_file_paths:
paths: "schemas/"
- run:
name: Run Schemas tests and linting
command: |
make schemas_check
integration_nimbus_desktop_release_targeting:
machine:
image: ubuntu-2004:2023.10.1
docker_layer_caching: true
resource_class: large
working_directory: ~/experimenter
environment:
FIREFOX_VERSION: nimbus-firefox-release
PYTEST_ARGS: -k FIREFOX_DESKTOP -m run_targeting -n 4 --reruns 1
MOZ_REMOTE_SETTINGS_DEVTOOLS: 1 # allows us to override and set the remote settings URL
steps:
- checkout
- check_file_paths:
paths: "experimenter/experimenter/targeting|experimenter/experimenter/experiments|experimenter/tests"
- run:
name: Run integration tests
command: |
cp .env.integration-tests .env
make refresh SKIP_DUMMY=1 PYTEST_SENTRY_DSN=$PYTEST_SENTRY_DSN CIRCLECI=$CIRCLECI up_prod_detached integration_test_nimbus PYTEST_ARGS="$PYTEST_ARGS"
- store_artifacts:
path: ~/experimenter/experimenter/tests/integration/test-reports/report.htm
integration_nimbus_desktop_beta_targeting:
machine:
image: ubuntu-2004:2023.10.1
docker_layer_caching: true
resource_class: large
working_directory: ~/experimenter
environment:
FIREFOX_VERSION: nimbus-firefox-beta
PYTEST_ARGS: -k FIREFOX_DESKTOP -m run_targeting -n 4 --reruns 1
MOZ_REMOTE_SETTINGS_DEVTOOLS: 1 # allows us to override and set the remote settings URL
steps:
- checkout
- check_file_paths:
paths: "experimenter/experimenter/targeting|experimenter/experimenter/experiments|experimenter/tests"
- run:
name: Run integration tests
command: |
cp .env.integration-tests .env
make refresh SKIP_DUMMY=1 PYTEST_SENTRY_DSN=$PYTEST_SENTRY_DSN CIRCLECI=$CIRCLECI up_prod_detached integration_test_nimbus PYTEST_ARGS="$PYTEST_ARGS"
- store_artifacts:
path: ~/experimenter/experimenter/tests/integration/test-reports/report.htm
integration_nimbus_desktop_nightly_targeting:
machine:
image: ubuntu-2004:2023.10.1
docker_layer_caching: true
resource_class: large
working_directory: ~/experimenter
environment:
FIREFOX_VERSION: nimbus-firefox-release
PYTEST_ARGS: -k FIREFOX_DESKTOP -m run_targeting -n 2 --reruns 1
UPDATE_FIREFOX_VERSION: true
steps:
- checkout
- check_file_paths:
paths: "experimenter/experimenter/targeting|experimenter/experimenter/experiments|experimenter/tests"
- run:
name: Run integration tests
command: |
cp .env.integration-tests .env
make refresh SKIP_DUMMY=1 PYTEST_SENTRY_DSN=$PYTEST_SENTRY_DSN CIRCLECI=$CIRCLECI up_prod_detached integration_test_nimbus PYTEST_ARGS="$PYTEST_ARGS"
- store_artifacts:
path: ~/experimenter/experimenter/tests/integration/test-reports/report.htm
integration_nimbus_desktop_remote_settings:
machine:
image: ubuntu-2004:2023.10.1
docker_layer_caching: true
resource_class: large
working_directory: ~/experimenter
environment:
FIREFOX_VERSION: nimbus-firefox-release
PYTEST_ARGS: -k FIREFOX_DESKTOP -m remote_settings --reruns 1
steps:
- checkout
- check_file_paths:
paths: "experimenter/"
- run:
name: Run integration tests
command: |
cp .env.integration-tests .env
make refresh SKIP_DUMMY=1 PYTEST_SENTRY_DSN=$PYTEST_SENTRY_DSN CIRCLECI=$CIRCLECI up_prod_detached integration_test_nimbus PYTEST_ARGS="$PYTEST_ARGS"
- store_artifacts:
path: ~/experimenter/experimenter/tests/integration/test-reports/report.htm
integration_nimbus_fenix_remote_settings:
machine:
image: ubuntu-2004:2023.10.1
docker_layer_caching: true
resource_class: medium
working_directory: ~/experimenter
environment:
FIREFOX_VERSION: nimbus-firefox-release
PYTEST_ARGS: -k FIREFOX_FENIX -m remote_settings --reruns 1
steps:
- checkout
- check_file_paths:
paths: "experimenter/"
- run:
name: Run integration tests
command: |
cp .env.integration-tests .env
make refresh SKIP_DUMMY=1 PYTEST_SENTRY_DSN=$PYTEST_SENTRY_DSN CIRCLECI=$CIRCLECI up_prod_detached integration_test_nimbus PYTEST_ARGS="$PYTEST_ARGS"
- store_artifacts:
path: ~/experimenter/experimenter/tests/integration/test-reports/report.htm
integration_nimbus_ios_remote_settings:
machine:
image: ubuntu-2004:2023.10.1
docker_layer_caching: true
resource_class: medium
working_directory: ~/experimenter
environment:
FIREFOX_VERSION: nimbus-firefox-release
PYTEST_ARGS: -k FIREFOX_IOS -m remote_settings --reruns 1
steps:
- checkout
- check_file_paths:
paths: "experimenter/"
- run:
name: Run integration tests
command: |
cp .env.integration-tests .env
make refresh SKIP_DUMMY=1 PYTEST_SENTRY_DSN=$PYTEST_SENTRY_DSN CIRCLECI=$CIRCLECI up_prod_detached integration_test_nimbus PYTEST_ARGS="$PYTEST_ARGS"
- store_artifacts:
path: ~/experimenter/experimenter/tests/integration/test-reports/report.htm
integration_nimbus_focus_android_remote_settings:
machine:
image: ubuntu-2004:2023.10.1
docker_layer_caching: true
resource_class: medium
working_directory: ~/experimenter
environment:
FIREFOX_VERSION: nimbus-firefox-release
PYTEST_ARGS: -k FOCUS_ANDROID -m remote_settings --reruns 1
steps:
- checkout
- check_file_paths:
paths: "experimenter/"
- run:
name: Run integration tests
command: |
cp .env.integration-tests .env
make refresh SKIP_DUMMY=1 PYTEST_SENTRY_DSN=$PYTEST_SENTRY_DSN CIRCLECI=$CIRCLECI up_prod_detached integration_test_nimbus PYTEST_ARGS="$PYTEST_ARGS"
- store_artifacts:
path: ~/experimenter/experimenter/tests/integration/test-reports/report.htm
integration_nimbus_focus_ios_remote_settings:
machine:
image: ubuntu-2004:2023.10.1
docker_layer_caching: true
resource_class: medium
working_directory: ~/experimenter
environment:
FIREFOX_VERSION: nimbus-firefox-release
PYTEST_ARGS: -k FOCUS_IOS -m remote_settings --reruns 1
steps:
- checkout
- check_file_paths:
paths: "experimenter/"
- run:
name: Run integration tests
command: |
cp .env.integration-tests .env
make refresh SKIP_DUMMY=1 PYTEST_SENTRY_DSN=$PYTEST_SENTRY_DSN CIRCLECI=$CIRCLECI up_prod_detached integration_test_nimbus PYTEST_ARGS="$PYTEST_ARGS"
- store_artifacts:
path: ~/experimenter/experimenter/tests/integration/test-reports/report.htm
integration_nimbus_desktop_enrollment:
machine:
image: ubuntu-2004:2023.10.1
docker_layer_caching: true
resource_class: xlarge
working_directory: ~/experimenter
environment:
FIREFOX_VERSION: nimbus-firefox-release
PYTEST_ARGS: -k FIREFOX_DESKTOP -m desktop_enrollment --reruns 1
UPDATE_FIREFOX_VERSION: true
steps:
- checkout
- check_file_paths:
paths: "experimenter/"
- run:
name: Run integration tests
command: |
cp .env.integration-tests .env
make refresh SKIP_DUMMY=1 PYTEST_SENTRY_DSN=$PYTEST_SENTRY_DSN CIRCLECI=$CIRCLECI up_prod_detached integration_test_nimbus PYTEST_ARGS="$PYTEST_ARGS"
no_output_timeout: 30m
- store_artifacts:
path: ~/experimenter/experimenter/tests/integration/test-reports/report.htm
integration_nimbus_desktop_ui:
machine:
image: ubuntu-2004:2023.10.1
docker_layer_caching: true
resource_class: large
working_directory: ~/experimenter
environment:
FIREFOX_VERSION: nimbus-firefox-release
PYTEST_ARGS: -m nimbus_ui -n 2 --reruns 1
steps:
- checkout
- check_file_paths:
paths: "experimenter/"
- run:
name: Run integration tests
command: |
cp .env.integration-tests .env
make refresh SKIP_DUMMY=1 PYTEST_SENTRY_DSN=$PYTEST_SENTRY_DSN CIRCLECI=$CIRCLECI up_prod_detached integration_test_nimbus PYTEST_ARGS="$PYTEST_ARGS"
- store_artifacts:
path: ~/experimenter/experimenter/tests/integration/test-reports/report.htm
integration_nimbus_sdk_targeting:
machine:
image: ubuntu-2004:2023.10.1
docker_layer_caching: true
resource_class: medium
working_directory: ~/experimenter
environment:
PYTEST_ARGS: -k FIREFOX_FENIX
steps:
- checkout
- check_file_paths:
paths: "experimenter/experimenter/targeting|experimenter/experimenter/experiments|experimenter/tests"
- run:
name: Run rust integration tests
command: |
cp .env.integration-tests .env
make refresh SKIP_DUMMY=1 PYTEST_SENTRY_DSN=$PYTEST_SENTRY_DSN CIRCLECI=$CIRCLECI up_prod_detached integration_test_nimbus_rust PYTEST_ARGS="$PYTEST_ARGS"
- store_artifacts:
path: ~/experimenter/experimenter/tests/integration/test-reports/report.htm
integration_nimbus_cirrus:
machine:
image: ubuntu-2004:2023.10.1
docker_layer_caching: true
resource_class: large
working_directory: ~/experimenter
environment:
FIREFOX_VERSION: nimbus-firefox-release
PYTEST_ARGS: -k DEMO_APP -m cirrus_enrollment --reruns 1
steps:
- checkout
- check_file_paths:
paths: "experimenter/"
- run:
name: Run integration tests
command: |
cp .env.integration-tests .env
export CIRRUS=1
make refresh SKIP_DUMMY=1 PYTEST_SENTRY_DSN=$PYTEST_SENTRY_DSN CIRCLECI=$CIRCLECI up_prod_detached integration_test_nimbus PYTEST_ARGS="$PYTEST_ARGS"
- store_artifacts:
path: ~/experimenter/experimenter/tests/integration/test-reports/report.htm
integration_legacy:
machine:
image: ubuntu-2004:2023.10.1
docker_layer_caching: true
resource_class: large
working_directory: ~/experimenter
environment:
FIREFOX_VERSION: nimbus-firefox-release
steps:
- checkout
- check_file_paths:
paths: "experimenter/"
- run:
name: Run integration tests
command: |
cp .env.sample .env
make refresh up_prod_detached integration_test_legacy
- store_artifacts:
path: ~/experimenter/experimenter/tests/integration/test-reports/report.htm
deploy_experimenter:
working_directory: ~/experimenter
machine:
image: ubuntu-2004:2023.10.1
docker_layer_caching: true
steps:
- checkout
- docker_login:
username: $DOCKER_USER
password: $DOCKER_PASS
- run:
name: Deploy to Dockerhub
command: |
./scripts/store_git_info.sh
make build_prod
docker tag experimenter:deploy ${DOCKERHUB_REPO}:latest
docker push ${DOCKERHUB_REPO}:latest
- gcp-cli/setup
- run:
name: Deploy to Google Container Registry
command: |
echo $GCLOUD_SERVICE_KEY | gcloud auth activate-service-account --key-file=-
gcloud --quiet config set project ${GOOGLE_PROJECT_ID}
gcloud --quiet config set compute/zone ${GOOGLE_COMPUTE_ZONE}
gcloud auth configure-docker
DOCKER_IMAGE="gcr.io/${GOOGLE_PROJECT_ID}/experimenter"
docker tag experimenter:deploy ${DOCKER_IMAGE}:latest
docker push "${DOCKER_IMAGE}:latest"
deploy_cirrus:
working_directory: ~/cirrus
machine:
image: ubuntu-2004:2023.10.1
docker_layer_caching: true
steps:
- checkout
- docker_login:
username: $DOCKERHUB_CIRRUS_USER
password: $DOCKERHUB_CIRRUS_PASS
- run:
name: Deploy to latest
command: |
make cirrus_build
docker tag cirrus:deploy ${DOCKERHUB_CIRRUS_REPO}:latest
docker push ${DOCKERHUB_CIRRUS_REPO}:latest
deploy_schemas:
machine:
image: ubuntu-2004:2023.10.1
docker_layer_caching: true
steps:
- checkout
- run:
name: Check for package version change in last commit before proceeding.
command: |
if git diff main HEAD~1 schemas/pyproject.toml | grep 'version'
then
echo "Found changes to package version dir, proceeding with deployment."
else
echo "No changes in package version. Skipping mozilla-nimbus-schemas deployment."
circleci-agent step halt
fi
- run:
name: Create the distribution files
command: |
make schemas_dist
- run:
name: Upload to PyPI
command: |
# Relies on the TWINE_USERNAME and TWINE_PASSWORD environment variables configured at:
# https://app.circleci.com/settings/project/github/mozilla/experimenter/environment-variables
# For more on twine, see:
# https://twine.readthedocs.io/en/latest/
make schemas_deploy_pypi SCHEMAS_ENV="-e TWINE_USERNAME=${TWINE_USERNAME} -e TWINE_PASSWORD=${TWINE_PASSWORD}"
- run:
name: NPM Authentication
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
- run:
name: Upload to NPM
command: |
# Relies on the NPM_TOKEN environment variable configured at:
# https://app.circleci.com/settings/project/github/mozilla/experimenter/environment-variables
make schemas_deploy_npm SCHEMAS_ENV="-e NPM_TOKEN=${NPM_TOKEN}"
update_external_configs:
working_directory: ~/experimenter
machine:
image: ubuntu-2004:2023.10.1
docker_layer_caching: true
steps:
- add_ssh_keys:
fingerprints:
- "32:8e:72:0b:9a:a1:1c:b8:7e:90:e1:53:a3:73:68:47" # for git pushes from circleci, since relies on ssh
- checkout
- gh/setup:
token: GH_EXTERNAL_CONFIG_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
cp .env.sample .env
env GITHUB_BEARER_TOKEN="${GH_EXTERNAL_CONFIG_TOKEN}" make fetch_external_resources FETCH_ARGS="--summary fetch-summary.txt"
mv ./experimenter/fetch-summary.txt /tmp/fetch-summary.txt
if python3 ./experimenter/bin/should-pr.py
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" -F /tmp/fetch-summary.txt --base main --head external-config --repo mozilla/experimenter || \
gh pr edit external-config -F /tmp/fetch-summary.txt
else
echo "Changes already committed, skipping"
fi
else
echo "No config changes, skipping"
fi
update_application_services:
machine:
image: ubuntu-2004:2023.10.1
docker_layer_caching: true
steps:
- add_ssh_keys:
fingerprints:
- "32:8e:72:0b:9a:a1:1c:b8:7e:90:e1:53:a3:73:68:47" # 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 Application Services update
command: |
git checkout main
git pull origin main
make update_application_services
if (($(git status --porcelain | wc -c) > 0)); then
git checkout -B update-application-services
git add .
git commit -m "chore(nimbus): Update application-services"
if (($((git diff update-application-services origin/update-application-services || git diff HEAD~1) | wc -c) > 0)); then
git push origin update-application-services -f
gh pr create -t "chore(nimbus): Update application-services" -b "" --base main --head update-application-services --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:2023.10.1
docker_layer_caching: true
steps:
- checkout
- docker_login:
username: $DOCKER_USER
password: $DOCKER_PASS
- run:
name: Build and upload images
command: |
git clone --depth=1 git@github.com:SeleniumHQ/docker-selenium.git
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
docker tag selenium/standalone-firefox:firefox-release ${DOCKERHUB_REPO}:nimbus-firefox-release
docker tag selenium/standalone-firefox:firefox-beta ${DOCKERHUB_REPO}:nimbus-firefox-beta
docker push ${DOCKERHUB_REPO}:nimbus-firefox-beta
docker push ${DOCKERHUB_REPO}:nimbus-firefox-release
workflows:
build_firefox:
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
- main
jobs:
- build_firefox_versions
update_configs:
triggers:
- schedule:
cron: "0 * * * *"
filters:
branches:
only:
- main
jobs:
- update_external_configs
- update_application_services
build:
jobs:
- check_experimenter_x86_64:
name: Check Experimenter x86_64
- check_experimenter_aarch64:
name: Check Experimenter aarch64
- check_cirrus_x86_64:
name: Check Cirrus x86_64
- check_cirrus_aarch64:
name: Check Cirrus aarch64
- check_schemas:
name: Check Schemas
filters:
branches:
ignore:
- main
- integration_nimbus_desktop_release_targeting:
name: Test Desktop Targeting (Release Firefox)
filters:
branches:
ignore:
- main
- integration_nimbus_desktop_beta_targeting:
name: Test Desktop Targeting (Beta Firefox)
filters:
branches:
ignore:
- main
- integration_nimbus_desktop_nightly_targeting:
name: Test Desktop Targeting (Nightly Firefox)
filters:
branches:
ignore:
- main
- integration_nimbus_desktop_ui:
name: Test Desktop Nimbus UI (Release Firefox)
filters:
branches:
ignore:
- main
- integration_nimbus_desktop_remote_settings:
name: Test Desktop and Remote Settings (Release Firefox)
filters:
branches:
ignore:
- main
- integration_nimbus_fenix_remote_settings:
name: Test Fenix and Remote Settings (Release Firefox)
filters:
branches:
ignore:
- main
- integration_nimbus_ios_remote_settings:
name: Test iOS and Remote Settings (Release Firefox)
filters:
branches:
ignore:
- main
- integration_nimbus_focus_android_remote_settings:
name: Test Focus Android and Remote Settings (Release Firefox)
filters:
branches:
ignore:
- main
- integration_nimbus_focus_ios_remote_settings:
name: Test Focus iOS and Remote Settings (Release Firefox)
filters:
branches:
ignore:
- main
- integration_nimbus_desktop_enrollment:
name: Test Desktop Enrollment (Release Firefox)
filters:
branches:
ignore:
- main
- integration_nimbus_sdk_targeting:
name: Test SDK Targeting (Release Firefox)
filters:
branches:
ignore:
- main
- integration_nimbus_cirrus:
name: Test Demo app with Cirrus
filters:
branches:
ignore:
- main
- integration_legacy:
name: Test Legacy Desktop (Release Firefox)
filters:
branches:
ignore:
- main
- deploy_experimenter:
name: Deploy Experimenter
filters:
branches:
only: main
requires:
- Check Experimenter x86_64
- Check Experimenter aarch64
- deploy_cirrus:
name: Deploy Cirrus
filters:
branches:
only: main
requires:
- Check Cirrus x86_64
- Check Cirrus aarch64
- deploy_schemas:
name: Deploy Schemas
filters:
branches:
only: main