summaryrefslogtreecommitdiffstats
path: root/taskcluster/gecko_taskgraph/parameters.py
blob: e7e5df460567410f8bcaf1bff90c396a5f9b8f10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# 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 logging
import os

from taskgraph.parameters import extend_parameters_schema
from voluptuous import Any, Required

from gecko_taskgraph import GECKO

logger = logging.getLogger(__name__)


gecko_parameters_schema = {
    Required("app_version"): str,
    Required("backstop"): bool,
    Required("build_number"): int,
    Required("enable_always_target"): bool,
    Required("hg_branch"): str,
    Required("message"): str,
    Required("next_version"): Any(None, str),
    Required("optimize_strategies"): Any(None, str),
    Required("phabricator_diff"): Any(None, str),
    Required("release_enable_emefree"): bool,
    Required("release_enable_partner_repack"): bool,
    Required("release_enable_partner_attribution"): bool,
    Required("release_eta"): Any(None, str),
    Required("release_history"): {str: dict},
    Required("release_partners"): Any(None, [str]),
    Required("release_partner_config"): Any(None, dict),
    Required("release_partner_build_number"): int,
    Required("release_type"): str,
    Required("release_product"): Any(None, str),
    Required("required_signoffs"): [str],
    Required("signoff_urls"): dict,
    Required("test_manifest_loader"): str,
    Required("try_mode"): Any(None, str),
    Required("try_options"): Any(None, dict),
    Required("try_task_config"): dict,
    Required("version"): str,
}


def get_contents(path):
    with open(path, "r") as fh:
        contents = fh.readline().rstrip()
    return contents


def get_version(product_dir="browser"):
    version_path = os.path.join(GECKO, product_dir, "config", "version_display.txt")
    return get_contents(version_path)


def get_app_version(product_dir="browser"):
    app_version_path = os.path.join(GECKO, product_dir, "config", "version.txt")
    return get_contents(app_version_path)


def get_defaults(repo_root=None):
    return {
        "app_version": get_app_version(),
        "backstop": False,
        "base_repository": "https://hg.mozilla.org/mozilla-unified",
        "build_number": 1,
        "enable_always_target": False,
        "head_repository": "https://hg.mozilla.org/mozilla-central",
        "hg_branch": "default",
        "message": "",
        "next_version": None,
        "optimize_strategies": None,
        "phabricator_diff": None,
        "project": "mozilla-central",
        "release_enable_emefree": False,
        "release_enable_partner_repack": False,
        "release_enable_partner_attribution": False,
        "release_eta": "",
        "release_history": {},
        "release_partners": [],
        "release_partner_config": None,
        "release_partner_build_number": 1,
        "release_product": None,
        "release_type": "nightly",
        # This refers to the upstream repo rather than the local checkout, so
        # should be hardcoded to 'hg' even with git-cinnabar.
        "repository_type": "hg",
        "required_signoffs": [],
        "signoff_urls": {},
        "test_manifest_loader": "default",
        "try_mode": None,
        "try_options": None,
        "try_task_config": {},
        "version": get_version(),
    }


def register_parameters():
    extend_parameters_schema(gecko_parameters_schema, defaults_fn=get_defaults)