def is_github_task(task): """Determine if a task is related to GitHub. This function currently looks into the ``schedulerId``, ``extra.tasks_for``, and ``metadata.source``. Args: task (dict): the task definition to check. Returns: bool: True if a piece of data refers to GitHub """ return any(( # XXX Cron tasks don't usually define 'taskcluster-github' as their schedulerId as they # are scheduled within another Taskcluster task. task.get('schedulerId') == 'taskcluster-github', # XXX Same here, cron tasks don't start with github task.get('extra', {}).get('tasks_for', '').startswith('github-'), is_github_url(task.get('metadata', {}).get('source', '')), ))
def test_is_github_url(url, expected): assert github.is_github_url(url) == expected