parameters.py (6129B)
1 # This Source Code Form is subject to the terms of the Mozilla Public 2 # License, v. 2.0. If a copy of the MPL was not distributed with this 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 5 import logging 6 import os 7 8 from taskgraph.parameters import extend_parameters_schema 9 from voluptuous import Any, Optional, Required 10 11 from gecko_taskgraph import GECKO 12 from gecko_taskgraph.files_changed import get_locally_changed_files 13 14 logger = logging.getLogger(__name__) 15 16 17 gecko_parameters_schema = { 18 Required("android_perftest_backstop"): bool, 19 Required("app_version"): str, 20 Required("backstop"): bool, 21 Required("build_number"): int, 22 Required("enable_always_target"): Any(bool, [str]), 23 Required("files_changed"): [str], 24 Required("hg_branch"): Any(None, str), 25 Required("message"): str, 26 Required("next_version"): Any(None, str), 27 Required("optimize_strategies"): Any(None, str), 28 Required("phabricator_diff"): Any(None, str), 29 Required("release_enable_emefree"): bool, 30 Required("release_enable_partner_repack"): bool, 31 Required("release_enable_partner_attribution"): bool, 32 Required("release_eta"): Any(None, str), 33 Required("release_history"): {str: dict}, 34 Required("release_partners"): Any(None, [str]), 35 Required("release_partner_config"): Any(None, dict), 36 Required("release_partner_build_number"): int, 37 Required("release_type"): str, 38 Required("release_product"): Any(None, str), 39 Required("required_signoffs"): [str], 40 Required("signoff_urls"): dict, 41 Required("test_manifest_loader"): str, 42 Required("try_mode"): Any(None, str), 43 Required("try_task_config"): { 44 Optional("tasks"): [str], 45 Optional("browsertime"): bool, 46 Optional("disable-pgo"): bool, 47 Optional("env"): {str: str}, 48 Optional("gecko-profile"): bool, 49 Optional("gecko-profile-interval"): float, 50 Optional("gecko-profile-entries"): int, 51 Optional("gecko-profile-features"): str, 52 Optional("gecko-profile-threads"): str, 53 Optional( 54 "github", 55 description="Github pull request triggering a code-review analysis", 56 ): { 57 Required("branch", description="Pull request branch name"): str, 58 Required( 59 "pull_head_sha", description="Pull request head commit identifier" 60 ): str, 61 Required( 62 "pull_number", description="Pull request public numerical ID" 63 ): int, 64 Required( 65 "repo_url", description="Targeted Mozilla repository on Github" 66 ): str, 67 }, 68 Optional( 69 "new-test-config", 70 description="adjust parameters, chunks, etc. to speed up the process " 71 "of greening up a new test config.", 72 ): bool, 73 Optional( 74 "perftest-options", 75 description="Options passed from `mach perftest` to try.", 76 ): object, 77 Optional( 78 "optimize-strategies", 79 description="Alternative optimization strategies to use instead of the default. " 80 "A module path pointing to a dict to be use as the `strategy_override` " 81 "argument in `taskgraph.optimize.base.optimize_task_graph`.", 82 ): str, 83 Optional( 84 "pernosco", 85 description="Record an rr trace on supported tasks using the Pernosco debugging " 86 "service.", 87 ): bool, 88 Optional("priority"): Any("lowest", "very-low", "low"), 89 Optional("rebuild"): int, 90 Optional("tasks-regex"): { 91 "include": Any(None, [str]), 92 "exclude": Any(None, [str]), 93 }, 94 Optional("use-artifact-builds"): bool, 95 Optional( 96 "worker-overrides", 97 description="Mapping of worker alias to worker pools to use for those aliases.", 98 ): {str: str}, 99 Optional( 100 "worker-types", 101 description="List of worker types that we will use to run tasks on.", 102 ): [str], 103 Optional("routes"): [str], 104 }, 105 Required("version"): str, 106 Optional("head_git_rev"): str, 107 } 108 109 110 def get_contents(path): 111 with open(path) as fh: 112 contents = fh.readline().rstrip() 113 return contents 114 115 116 def get_version(product_dir="browser"): 117 version_path = os.path.join(GECKO, product_dir, "config", "version_display.txt") 118 return get_contents(version_path) 119 120 121 def get_app_version(product_dir="browser"): 122 app_version_path = os.path.join(GECKO, product_dir, "config", "version.txt") 123 return get_contents(app_version_path) 124 125 126 def get_defaults(repo_root=None): 127 return { 128 "android_perftest_backstop": False, 129 "app_version": get_app_version(), 130 "backstop": False, 131 "base_repository": "https://hg.mozilla.org/mozilla-unified", 132 "build_number": 1, 133 "enable_always_target": ["docker-image"], 134 "files_changed": lambda: sorted(get_locally_changed_files(repo_root)), 135 "head_repository": "https://hg.mozilla.org/mozilla-central", 136 "hg_branch": "default", 137 "message": "", 138 "next_version": None, 139 "optimize_strategies": None, 140 "phabricator_diff": None, 141 "project": "mozilla-central", 142 "release_enable_emefree": False, 143 "release_enable_partner_repack": False, 144 "release_enable_partner_attribution": False, 145 "release_eta": "", 146 "release_history": {}, 147 "release_partners": [], 148 "release_partner_config": None, 149 "release_partner_build_number": 1, 150 "release_product": None, 151 "release_type": "nightly", 152 # This refers to the upstream repo rather than the local checkout, so 153 # should be hardcoded to 'hg' even with git-cinnabar. 154 "repository_type": "hg", 155 "required_signoffs": [], 156 "signoff_urls": {}, 157 "test_manifest_loader": "default", 158 "try_mode": None, 159 "try_task_config": {}, 160 "version": get_version(), 161 } 162 163 164 def register_parameters(): 165 extend_parameters_schema(gecko_parameters_schema, defaults_fn=get_defaults)