Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
32 changes: 32 additions & 0 deletions src/mozilla_taskgraph/util/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,38 @@

import re

_COPYABLE_ATTRIBUTES = (
"accepted-mar-channel-ids",
"artifact_map",
"artifact_prefix",
"build_platform",
"build_type",
"l10n_chunk",
"locale",
"mar-channel-id",
"maven_packages",
"nightly",
"shippable",
"shipping_phase",
"shipping_product",
"signed",
"stub-installer",
"update-channel",
)


def copy_attributes_from_dependent_job(dep_job, denylist=()):
"""Copy the curated ``_COPYABLE_ATTRIBUTES`` from a dependent job.

Only attributes present on ``dep_job`` and not in ``denylist`` are copied,
so entries that don't apply to a given job are simply skipped.
"""
return {
attr: dep_job.attributes[attr]
for attr in _COPYABLE_ATTRIBUTES
if attr in dep_job.attributes and attr not in denylist
}


def release_level(release_branches: dict, params: dict):
"""Whether this is a production release or not.
Expand Down
27 changes: 26 additions & 1 deletion test/util/test_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
# 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 types import SimpleNamespace

import pytest

from mozilla_taskgraph.util.attributes import release_level
from mozilla_taskgraph.util.attributes import (
copy_attributes_from_dependent_job,
release_level,
)

FIREFOX_BRANCHES = ["main", "beta", "release", "esr140"]
RELEASE_BRANCHES = {
Expand Down Expand Up @@ -54,3 +59,23 @@
)
def test_release_level(release_branches, params, expected):
assert release_level(release_branches, params) == expected


def test_copy_attributes_from_dependent_job():
dep_job = SimpleNamespace(
attributes={
"build_platform": "linux64",
"shippable": True,
"locale": "de",
"not_copyable": "x", # not in _COPYABLE_ATTRIBUTES -> skipped
}
)
assert copy_attributes_from_dependent_job(dep_job) == {
"build_platform": "linux64",
"shippable": True,
"locale": "de",
}
assert copy_attributes_from_dependent_job(dep_job, denylist=("locale",)) == {
"build_platform": "linux64",
"shippable": True,
}