Skip to content

Commit

Permalink
Fix ECTEEN-87: Fix circleci jobs. (#64)
Browse files Browse the repository at this point in the history
* Fix ECTEEN-87
  • Loading branch information
b4handjr authored Feb 9, 2024
1 parent 9a52d11 commit f506b45
Show file tree
Hide file tree
Showing 14 changed files with 164 additions and 86 deletions.
70 changes: 27 additions & 43 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ version: 2.1

jobs:
build-deploy: # build for the master branch
machine: true
machine:
image: ubuntu-2204:2024.01.1
working_directory: ~/klaatu
steps:
- checkout
Expand All @@ -15,8 +16,9 @@ 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
working_directory: ~/klaatu
steps:
- checkout
- run:
Expand All @@ -29,90 +31,72 @@ jobs:
docker push "mozilla/klaatu:${CIRCLE_TAG}"
lint:
docker:
- image: circleci/python:3.7-browsers
- image: cimg/python:3.11
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 \
GECKODRIVER_VERSION=0.34.0

# 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
7 changes: 4 additions & 3 deletions docker-compose.yml
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"
- "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.11

COPY ping_server.py /code/

WORKDIR /code

RUN pip install flask

ENTRYPOINT [ "python" ]

CMD [ "ping_server.py" ]
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)
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"
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"
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

0 comments on commit f506b45

Please sign in to comment.