35 lines
964 B
Python
35 lines
964 B
Python
#!/usr/bin/env python3
|
|
|
|
"""Fail a terminal CI job unless every serialized dependency succeeded.
|
|
|
|
Parent workflows pass GitHub's `toJSON(needs)` object through the NEEDS
|
|
environment variable. Treat skipped and cancelled dependencies as failures too:
|
|
for a required fan-in job, only an explicit success is safe to accept.
|
|
"""
|
|
|
|
import json
|
|
import os
|
|
|
|
|
|
def main() -> None:
|
|
# Keep result policy in one script so blocking-ci and postmerge-ci cannot
|
|
# drift in how they interpret dependency conclusions.
|
|
needs = json.loads(os.environ["NEEDS"])
|
|
failures = sorted(
|
|
(name, dependency["result"])
|
|
for name, dependency in needs.items()
|
|
if dependency["result"] != "success"
|
|
)
|
|
|
|
if failures:
|
|
print("CI dependencies did not succeed:")
|
|
for name, result in failures:
|
|
print(f"{name}: {result}")
|
|
raise SystemExit(1)
|
|
|
|
print("All CI dependencies succeeded.")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|