Skip to content

Commit

Permalink
(ci) - Update bitrisescript task payload
Browse files Browse the repository at this point in the history
  • Loading branch information
hneiva committed May 8, 2024
1 parent 0acdb8d commit 8bbb0b3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 28 deletions.
20 changes: 0 additions & 20 deletions taskcluster/ffios_taskgraph/transforms/bitrise.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
Required("bitrise"): {
Required("workflows"): worker_schema["workflows"],
Optional("artifact_prefix"): worker_schema["artifact_prefix"],
Optional("build_params"): worker_schema["build_params"],
Optional("env"): worker_schema["env"],
},
Extra: object,
})
Expand All @@ -31,24 +29,6 @@ def set_bitrise_app(config, tasks):
yield task


@transforms.add
def set_build_params(config, tasks):
build_params = {}

if config.params["commit_message"]:
build_params["commit_message"] = config.params["commit_message"]

if config.params["pull_request_number"]:
build_params["pull_request_id"] = config.params["pull_request_number"]

if not build_params:
yield from tasks
else:
for task in tasks:
task["bitrise"].setdefault("build_params", {}).update(build_params)
yield task


@transforms.add
def add_worker(config, tasks):
for task in tasks:
Expand Down
33 changes: 25 additions & 8 deletions taskcluster/ffios_taskgraph/transforms/generate_screenshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from taskgraph.transforms.base import TransformSequence
from taskgraph.transforms.task import payload_builders
from taskgraph.util.schema import Schema, taskref_or_string
from voluptuous import Extra, Optional
from voluptuous import Extra, Optional, Required

transforms = TransformSequence()

worker_schema = payload_builders["scriptworker-bitrise"].schema["bitrise"]
schema = Schema(
{
Optional("attributes"): {
Optional("chunk_locales"): [str],
Extra: object,
},
Optional("build-derived-data-path"): taskref_or_string,
Required("bitrise"): {
Required("workflows"): worker_schema["workflows"],
Optional("artifact_prefix"): worker_schema["artifact_prefix"],
},
Extra: object,
}
)
Expand All @@ -28,17 +34,28 @@ def set_environment(config, tasks):
workflow.
"""
for task in tasks:
env = task.setdefault("bitrise", {}).setdefault("env", {})

# locales
locales = (
" ".join(task.get("attributes", {}).get("chunk_locales", [])) or "en-US"
)
env["MOZ_LOCALES"] = locales

# derived data path
derived_data_path = task.pop("build-derived-data-path", None)
if derived_data_path:
env["MOZ_DERIVED_DATA_PATH"] = derived_data_path

def _get_default_workflow():
default_workflow = {"MOZ_LOCALES": locales}
if derived_data_path:
default_workflow["MOZ_DERIVED_DATA_PATH"] = derived_data_path
return default_workflow

# Create an object with specific workflow configs
task_workflows = {}
for workflow_config in task["bitrise"]["workflows"]:
if isinstance(workflow_config, str):
task_workflows[workflow_config] = _get_default_workflow()
elif isinstance(workflow_config, dict):
for workflow_id, env in workflow_config.items():
task_workflows[workflow_id] = _get_default_workflow()
# Update the workflow config with data from bitrise.workflow.<workflow_id>
task_workflows[workflow_id].update(env)

task["bitrise"]["workflows"] = [task_workflows]
yield task

0 comments on commit 8bbb0b3

Please sign in to comment.