def load_secrets(args): """ Load secret from remote Taskcluster Instance """ assert args.taskcluster_secret, "Missing taskcluster secret" tc = TaskclusterConfig("https://firefox-ci-tc.services.mozilla.com") tc.auth() return tc.load_secrets(args.taskcluster_secret)
def _is_queue_overloaded(provisioner_id: str, worker_type: str, acceptable_limit=100) -> bool: """ Helper method for PerfSheriffBot to check load on processing queue. Usage example: _queue_is_too_loaded('gecko-3', 'b-linux') :return: True/False """ tc = TaskclusterConfig('https://firefox-ci-tc.services.mozilla.com') tc.auth(client_id=CLIENT_ID, access_token=ACCESS_TOKEN) queue = tc.get_service('queue') pending_tasks_count = queue.pendingTasks(provisioner_id, worker_type).get('pendingTasks') return pending_tasks_count > acceptable_limit
def __init__( self, taskcluster_config: TaskclusterConfig, queue_name: str, emails: list, period: int, ): assert period > 0 assert len(emails) > 0 self.queue_name = queue_name self.period = period self.stats: Dict[str, Dict[str, List[str]]] = {} self.emails = emails # Setup Taskcluster services self.notify = taskcluster_config.get_service("notify", use_async=True) self.queue = taskcluster_config.get_service("queue", use_async=True) self.taskcluster_base_url = taskcluster_config.default_url
def mock_taskcluster(): """ Mock Tasklcuster authentication """ tc = TaskclusterConfig("http://taskcluster.test") # Force options to avoid auto proxy detection tc.auth("client", "token") tc.default_url = "http://taskcluster.test" tc.options["maxRetries"] = 1 return tc
def test_taskcluster_service(): """ Test taskcluster service loader """ taskcluster = TaskclusterConfig("http://tc.test") assert taskcluster.get_service("secrets") is not None assert taskcluster.get_service("hooks") is not None assert taskcluster.get_service("index") is not None with pytest.raises(AssertionError) as e: taskcluster.get_service("nope") assert str(e.value) == "Invalid Taskcluster service nope"
# -*- coding: utf-8 -*- import os import shutil from zipfile import BadZipFile from zipfile import is_zipfile import requests import structlog import taskcluster from taskcluster.helper import TaskclusterConfig from code_coverage_bot.utils import retry logger = structlog.getLogger(__name__) taskcluster_config = TaskclusterConfig("https://firefox-ci-tc.services.mozilla.com") def get_task(branch, revision, platform): if platform == "linux": platform_name = "linux64-ccov-opt" product = "firefox" elif platform == "windows": platform_name = "win64-ccov-debug" product = "firefox" elif platform == "android-test": platform_name = "android-test-ccov" product = "mobile" elif platform == "android-emulator": platform_name = "android-api-16-ccov-debug" product = "mobile" else:
import argparse import json import re from abc import ABC, abstractmethod from argparse import ArgumentParser from functools import wraps from logging import DEBUG, INFO, WARNING, basicConfig, getLogger from pathlib import Path from typing import Any, Dict, List, Optional from Reporter.Reporter import Reporter from taskcluster.helper import TaskclusterConfig # Shared taskcluster configuration Taskcluster = TaskclusterConfig("https://community-tc.services.mozilla.com") LOG = getLogger(__name__) # this is duplicated from grizzly status_reporter.py def format_seconds(duration: float) -> str: # format H:M:S, and then remove all leading zeros with regex minutes, seconds = divmod(int(duration), 60) hours, minutes = divmod(minutes, 60) result = re.sub("^[0:]*", "", "%d:%02d:%02d" % (hours, minutes, seconds)) # if the result is all zeroes, ensure one zero is output if not result: result = "0" # a bare number is ambiguous. output 's' for seconds if ":" not in result: result += "s"
# 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 https://mozilla.org/MPL/2.0/. """Decision module for Orion builds""" import os from datetime import timedelta from dateutil.relativedelta import relativedelta from taskcluster.helper import TaskclusterConfig TASKCLUSTER_ROOT_URL = os.getenv("TASKCLUSTER_ROOT_URL", "https://community-tc.services.mozilla.com") Taskcluster = TaskclusterConfig(TASKCLUSTER_ROOT_URL) ARTIFACTS_EXPIRE = relativedelta(months=6) # timedelta doesn't support months DEADLINE = timedelta(hours=2) MAX_RUN_TIME = timedelta(hours=1) OWNER_EMAIL = "*****@*****.**" PROVISIONER_ID = "proj-fuzzing" SCHEDULER_ID = "taskcluster-github" SOURCE_URL = "https://github.com/MozillaSecurity/orion" WORKER_TYPE = "ci" WORKER_TYPE_MSYS = "ci-windows" WORKER_TYPE_BREW = "ci-osx" del os, relativedelta, timedelta, TaskclusterConfig
# -*- coding: utf-8 -*- # 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 os from taskcluster.helper import TaskclusterConfig ARTIFACT_BASE = "project/fuzzing/bugmon/" # Shared taskcluster configuration taskcluster = TaskclusterConfig(os.environ["TASKCLUSTER_ROOT_URL"]) queue = taskcluster.get_service("queue")
# -*- coding: utf-8 -*- from taskcluster.helper import TaskclusterConfig taskcluster = TaskclusterConfig("https://firefox-ci-tc.services.mozilla.com") # Force root url to avoid proxy as grcov is not available on Community instance taskcluster.options = {"rootUrl": taskcluster.default_url}
# coding: utf-8 # 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 https://mozilla.org/MPL/2.0/. """Decision module for Orion builds""" import os from datetime import timedelta from dateutil.relativedelta import relativedelta from taskcluster.helper import TaskclusterConfig Taskcluster = TaskclusterConfig( os.getenv("TASKCLUSTER_ROOT_URL", "https://community-tc.services.mozilla.com")) ARTIFACTS_EXPIRE = relativedelta(months=6) # timedelta doesn't support months DEADLINE = timedelta(hours=2) MAX_RUN_TIME = timedelta(hours=1) OWNER_EMAIL = "*****@*****.**" PROVISIONER_ID = "proj-fuzzing" SCHEDULER_ID = "taskcluster-github" SOURCE_URL = "https://github.com/MozillaSecurity/orion" WORKER_TYPE = "ci" del os, relativedelta, timedelta, TaskclusterConfig