Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ECTEEN-87: Fix circleci jobs. #64

Merged
merged 2 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 29 additions & 43 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ version: 2.1

jobs:
build-deploy: # build for the master branch
machine: true
machine:
image: ubuntu-2204:2024.01.1
docker_layer_caching: true
working_directory: ~/klaatu
steps:
- checkout
Expand All @@ -15,8 +17,10 @@ jobs:
docker login -u "${DOCKERHUB_USER}" -p "${DOCKERHUB_PASS}"
docker push mozilla/klaatu:latest
build-release: # build for tags
machine: true
working_directory: ~/redash-ui-tests
machine:
image: ubuntu-2204:2024.01.1
docker_layer_caching: true
working_directory: ~/klaatu
steps:
- checkout
- run:
Expand All @@ -29,90 +33,72 @@ jobs:
docker push "mozilla/klaatu:${CIRCLE_TAG}"
lint:
docker:
- image: circleci/python:3.7-browsers
- image: cimg/python:3.12
steps:
- checkout
- restore_cache:
key: klaatu-lint-{{ checksum "Pipfile.lock" }}
key: klaatu-lint-{{ checksum "poetry.lock" }}
- run:
name: Install tox
command: sudo pip install tox
command: pip install tox
- run:
name: Lint files
command: tox -e formatting
- run:
name: Run type check
command: tox -e mypy
- save_cache:
key: klaatu-lint-{{ checksum "Pipfile.lock" }}
key: klaatu-lint-{{ checksum "poetry.lock" }}
paths:
- .tox
test-current-nightly:
working_directory: ~/klaatu
machine: true
machine:
image: ubuntu-2204:2024.01.1
steps:
- checkout
- restore_cache:
key: klaatu-test-{{ checksum "Pipfile.lock" }}
- run:
name: Build docker image
command: docker build -t klaatu:latest .
command: docker build -t klaatu:latest -f Dockerfile.desktop .
- run:
name: Run tests
command: |
set -ex
docker run --name "klaatu" klaatu:latest tox -e exp-tests -- --experiment=fixtures/normandy-nextgen-study-example-a@mozilla.org-0.3-signed.xpi --html=test_results/report.html --variables=utilities/test_variables.json --private-browsing-enabled
docker cp klaatu:/code/test_results/report.html ./report.html
- save_cache:
key: klaatu-test-{{ checksum "Pipfile.lock" }}
paths:
- .tox
docker compose up -d
docker compose run klaatu tox -e bdd-tests -- --experiment-branch control --variables tests/fixtures/test_experiment.json
- store_artifacts:
path: report.html
path: tests/report.html
test-old-nightly:
working_directory: ~/klaatu
machine: true
machine:
image: ubuntu-2204:2024.01.1
steps:
- checkout
- restore_cache:
key: klaatu-test-{{ checksum "Pipfile.lock" }}
- run:
name: Build docker image
command: docker build -t klaatu:latest .
command: docker build -t klaatu:latest -f Dockerfile.desktop .
- run:
name: Run tests
command: |
set -ex
docker run --name "klaatu" klaatu:latest tox -e exp-tests -- --experiment=fixtures/normandy-nextgen-study-example-a@mozilla.org-0.3-signed.xpi --html=test_results/report.html --variables=utilities/test_variables.json --run-update-test --private-browsing-enabled
docker cp klaatu:/code/test_results/report.html ./report.html
- save_cache:
key: klaatu-test-{{ checksum "Pipfile.lock" }}
paths:
- .tox
docker compose up -d
docker compose run klaatu tox -e bdd-tests -- --experiment-branch control --variables tests/fixtures/test_experiment.json --run-update-test --private-browsing-enabled
- store_artifacts:
path: report.html
path: tests/report.html
test-release-firefox:
working_directory: ~/klaatu
machine: true
machine:
image: ubuntu-2204:2024.01.1
steps:
- checkout
- restore_cache:
key: klaatu-test-{{ checksum "Pipfile.lock" }}
- run:
name: Build docker image
command: docker build -t klaatu:latest .
command: docker build -t klaatu:latest -f Dockerfile.desktop .
- run:
name: Run tests
command: |
set -ex
docker run --name "klaatu" klaatu:latest tox -e exp-tests -- --experiment=fixtures/normandy-nextgen-study-example-a@mozilla.org-0.3-signed.xpi --html=test_results/report.html --variables=utilities/test_variables.json --run-firefox-release --private-browsing-enabled
docker cp klaatu:/code/test_results/report.html ./report.html
- save_cache:
key: klaatu-test-{{ checksum "Pipfile.lock" }}
paths:
- .tox
docker compose up -d
docker compose run klaatu tox -e bdd-tests -- --experiment-branch control --variables tests/fixtures/test_experiment.json --run-firefox-release --private-browsing-enabled
- store_artifacts:
path: report.html
path: tests/report.html
workflows:
version: 2.1
test_and_lint:
Expand Down
9 changes: 5 additions & 4 deletions Dockerfile.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

FROM ubuntu:lunar
FROM ubuntu:devel

USER root

Expand All @@ -11,8 +11,8 @@ ENV DEBIAN_FRONTEND=noninteractive \
MOZ_HEADLESS=1 \
LC_ALL=C.UTF-8 \
LANG=C.UTF-8 \
FIREFOX_VERSION=112.0 \
GECKODRIVER_VERSION=0.33.0
FIREFOX_VERSION=120.0 \
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Why 120? https://whattrainisitnow.com/

  • ESR: 115
  • Release: 122 — Firefox 123 ships on February 20 (in 11 days)
  • Beta: 123
  • Nightly: 124

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't matter too much as there is a script to update it to the latest version on line 48

GECKODRIVER_VERSION=0.34.0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


# Install requirements to install tools
RUN dependencies=' \
Expand Down Expand Up @@ -66,7 +66,8 @@ RUN mv /usr/bin/geckodriver /usr/bin/geckodriver2 \
&& chmod +x /usr/bin/geckodriver

# Install python deps
RUN pip install -r requirements.txt
RUN pip install poetry \
&& poetry install

# Download older firefox nightly
RUN FIREFOX_OLD_DOWNLOAD_URL=$(python3 utilities/download_old_firefox.py) \
Expand Down
5 changes: 3 additions & 2 deletions docker-compose.yml
b4handjr marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ version: "3"

services:
klaatu:
build: .
build:
dockerfile: Dockerfile.desktop
volumes:
- ./test_experiments:/code/test_experiments
- ./tests:/code/tests
links:
- ping-server
ping-server:
image: ping-server:latest
build: ping_server/
ports:
- "5000:5000"
Binary file not shown.
Binary file removed fixtures/shield_study_example-2.0.0.zip
Binary file not shown.
11 changes: 11 additions & 0 deletions ping_server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM python:3.10
b4handjr marked this conversation as resolved.
Show resolved Hide resolved

COPY ping_server.py /code/

WORKDIR /code

RUN pip install flask

ENTRYPOINT [ "python" ]

CMD [ "ping_server.py" ]
b4handjr marked this conversation as resolved.
Show resolved Hide resolved
49 changes: 49 additions & 0 deletions ping_server/ping_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import json
import os
import zlib

from flask import Flask, request
from flask.json import jsonify

app = Flask("ping_server")

PINGS = []


@app.route("/pings", methods=["GET", "DELETE"])
def pings():
if request.method == "GET":
return jsonify(PINGS)

if request.method == "DELETE":
PINGS.clear()
return ""


@app.route(
"/submit/<path:telemetry>",
methods=["POST"],
)
def submit(telemetry):

if request.method == "POST":
request_data = request.get_data()

if request.headers.get("Content-Encoding") == "gzip":
request_data = zlib.decompress(request_data, zlib.MAX_WBITS | 16)

ping_data = json.loads(request_data)

# Store JSON data to self.pings to be used by wait_for_pings()
PINGS.append(ping_data)
return ""
return ""


if __name__ == "__main__":
port = int(os.environ.get("PORT", 5000))
app.run(debug=True, host="0.0.0.0", port=port)
b4handjr marked this conversation as resolved.
Show resolved Hide resolved
34 changes: 33 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ profile = "black"
skip_gitignore = true

[tool.mypy]
python_version = "3.10"
python_version = "3.11"
b4handjr marked this conversation as resolved.
Show resolved Hide resolved
disable_error_code = "attr-defined"
disallow_untyped_calls = false
follow_imports = "normal"
Expand All @@ -43,6 +43,7 @@ pytest-rerunfailures = "^13.0"
mypy = "^1.8.0"
isort = "^5.13.2"
flake8 = "^7.0.0"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really relevant to anything (but I do enjoy me some linting topics; and apparently commenting on merged PRs)…
Reading through the deps reminded me of a recent Locust commit: locustio/locust#2549 "Use ruff instead of flake8 and black for linting and formatting".

Anyways... in case you're bored one day and wanted to see how ruff compares to other toolings. 🤷

beautifulsoup4 = "^4.12.3"

[build-system]
requires = ["poetry-core"]
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

[tool:pytest]
addopts = -vvv -p no:warnings --reruns-delay 5
addopts = -vvv -p no:warnings --reruns-delay 5 --self-contained-html
sensitive_url = mozilla\.(com|org)
xfail_strict = true
markers =
Expand Down
Loading