Unverified Commit 060e915d authored by Johan Lorenzo's avatar Johan Lorenzo Committed by GitHub
Browse files

Bug 1580778 - Rename GIT_TAG into MOBILE_HEAD_TAG and export it as a param (#5564)

parent 2f0d8d82
......@@ -199,7 +199,7 @@ tasks:
ACTION_CALLBACK: '${action.cb_name}'
- $if: 'tasks_for == "github-release"'
then:
GIT_TAG: '${event.release.tag_name}'
MOBILE_HEAD_TAG: '${event.release.tag_name}'
features:
taskclusterProxy: true
chainOfTrust: true
......
......@@ -21,6 +21,7 @@ taskgraph:
mobile:
name: "Fenix"
cached-task-prefix: project.mobile.fenix
decision-parameters: 'fenix_taskgraph:get_decision_parameters'
workers:
aliases:
......
......@@ -4,7 +4,17 @@
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
from importlib import import_module
from six import text_type
from voluptuous import Required
from taskgraph.parameters import extend_parameters_schema
BETA_SEMVER = re.compile(r'^v\d+\.\d+\.\d+-beta\.\d+$')
PRODUCTION_SEMVER = re.compile(r'^v\d+\.\d+\.\d+(-rc\.\d+)?$')
def register(graph_config):
......@@ -13,8 +23,42 @@ def register(graph_config):
the process.
"""
_import_modules(["job", "worker_types", "routes", "target_tasks"])
extend_parameters_schema({
Required("head_tag"): text_type,
Required("release_type"): text_type,
Required("release_version"): text_type,
})
def _import_modules(modules):
for module in modules:
import_module(".{}".format(module), package=__name__)
def get_decision_parameters(graph_config, parameters):
head_tag = os.environ.get("MOBILE_HEAD_TAG", "").decode('utf-8')
parameters["head_tag"] = head_tag
parameters["release_type"] = _resolve_release_type(head_tag)
parameters["release_version"] = head_tag[1:] if head_tag else ""
if parameters["tasks_for"] == "github-release":
for param_name in ("release_type", "release_version"):
if not parameters[param_name]:
raise ValueError(
'Cannot run github-release if "{}" is not defined. Got: {}'.format(
param_name, parameters[param_name]
)
)
parameters["target_tasks_method"] = "release"
def _resolve_release_type(head_tag):
if not head_tag:
return ""
elif BETA_SEMVER.match(head_tag):
return "beta"
elif PRODUCTION_SEMVER.match(head_tag):
return "production"
else:
raise ValueError('Github tag must be in semver format and prefixed with a "v", '
'e.g.: "v1.0.0-beta.0" (beta), "v1.0.0-rc.0" (production) or "v1.0.0" (production)')
......@@ -4,36 +4,23 @@
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
from taskgraph.target_tasks import _target_task, filter_for_tasks_for
BETA_SEMVER = re.compile(r'^v\d+\.\d+\.\d+-beta\.\d+$')
PRODUCTION_SEMVER = re.compile(r'^v\d+\.\d+\.\d+(-rc\.\d+)?$')
@_target_task('default')
def target_tasks_default(full_task_graph, parameters, graph_config):
"""Target the tasks which have indicated they should be run on this project
via the `run_on_projects` attributes."""
filter = filter_for_tasks_for
if parameters["tasks_for"] == 'github-release':
# TODO Move GIT_TAG as to a parameter
git_tag = os.environ['GIT_TAG']
version = git_tag[1:] # remove prefixed "v"
if BETA_SEMVER.match(git_tag):
def filter(task, params):
return task.attributes.get("release-type", "") == "beta"
elif PRODUCTION_SEMVER.match(git_tag):
def filter(task, params):
return task.attributes.get("release-type", "") == "production"
else:
raise ValueError('Github tag must be in semver format and prefixed with a "v", '
'e.g.: "v1.0.0-beta.0" (beta), "v1.0.0-rc.0" (production) or "v1.0.0" (production)')
return [l for l, t in full_task_graph.tasks.iteritems() if filter_for_tasks_for(t, parameters)]
@_target_task('release')
def target_tasks_default(full_task_graph, parameters, graph_config):
def filter(task, parameters):
return task.attributes.get("release-type", "") == parameters["release_type"]
return [l for l, t in full_task_graph.tasks.iteritems() if filter(t, parameters)]
......@@ -50,7 +37,7 @@ def target_tasks_nightly(full_task_graph, parameters, graph_config):
@_target_task('raptor')
def target_tasks_raptor(full_task_graph, parameters, graph_config):
def filter(task, params):
def filter(task, parameters):
return task.kind == 'raptor'
return [l for l, t in full_task_graph.tasks.iteritems() if filter(t, parameters)]
......@@ -9,7 +9,6 @@ kind.
from __future__ import absolute_import, print_function, unicode_literals
import datetime
import os
from taskgraph.transforms.base import TransformSequence
from fenix_taskgraph.gradle import get_variant
......@@ -92,11 +91,9 @@ def add_nightly_version(config, tasks):
def add_release_version(config, tasks):
for task in tasks:
if task.pop("include-release-version", False):
# TODO Move GIT_TAG to a parameter
git_tag = os.environ.get('GIT_TAG', 'vUNSET')
version = git_tag[1:] # remove prefixed "v"
task["run"]["gradlew"].append('-PversionName={}'.format(version))
task["run"]["gradlew"].append(
'-PversionName="{}"'.format(config.params["release_version"])
)
yield task
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment