check_artifacts_expire_time.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/usr/bin/env python
  2. # internal use only
  3. # check if expire time is set for all artifacts
  4. import os
  5. import yaml
  6. IDF_PATH = os.getenv("IDF_PATH")
  7. if not IDF_PATH:
  8. print("Please set IDF_PATH before running this script")
  9. raise SystemExit(-1)
  10. GITLAB_CONFIG_FILE = os.path.join(os.getenv("IDF_PATH"), ".gitlab-ci.yml")
  11. def check_artifacts_expire_time():
  12. with open(GITLAB_CONFIG_FILE, "r") as f:
  13. config = yaml.load(f, Loader=yaml.Loader)
  14. errors = []
  15. print("expire time for jobs:")
  16. job_names = list(config.keys())
  17. job_names.sort()
  18. for job_name in job_names:
  19. if job_name.startswith("."):
  20. # skip ignored jobs
  21. continue
  22. try:
  23. if "expire_in" not in config[job_name]["artifacts"]:
  24. errors.append(job_name)
  25. else:
  26. print("{}: {}".format(job_name, config[job_name]["artifacts"]["expire_in"]))
  27. except (KeyError, TypeError):
  28. # this is not job, or the job does not have artifacts
  29. pass
  30. if errors:
  31. print("\n\nThe following jobs did not set expire time for its artifacts")
  32. for error in errors:
  33. print(error)
  34. raise SystemExit(-2)
  35. if __name__ == '__main__':
  36. check_artifacts_expire_time()