3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 queue
= taskcluster
.Queue(
14 "rootUrl": os
.environ
.get("TASKCLUSTER_PROXY_URL", "https://taskcluster.net"),
19 def check_all_dependencies_are_completed(current_task_id
):
20 print(f
"Fetching task definition of {current_task_id}...")
21 task
= queue
.task(current_task_id
)
22 dependencies_task_ids
= task
["dependencies"]
24 print(f
"Fetching status of {len(dependencies_task_ids)} dependencies...")
25 # TODO Make this dict-comprehension async once we go Python 3
26 state_per_task_ids
= {
27 task_id
: queue
.status(task_id
)["status"]["state"]
28 for task_id
in dependencies_task_ids
30 print("Statuses fetched.")
31 non_completed_tasks
= {
33 for task_id
, state
in state_per_task_ids
.items()
34 if state
!= "completed"
37 if non_completed_tasks
:
38 raise ValueError(f
"Some tasks are not completed: {non_completed_tasks}")
42 parser
= argparse
.ArgumentParser(
43 description
='Errors out if one of the DEPENDENCY_TASK_ID does not have the Taskcluster status "completed"'
48 metavar
="CURRENT_TASK_ID",
49 help="The task ID of the current running task",
52 result
= parser
.parse_args()
53 check_all_dependencies_are_completed(result
.current_task_id
)
54 print("All dependencies are completed. Reporting a green task!")
58 if __name__
== "__main__":