gen-matrix-packaging.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env python3
  2. import json
  3. import sys
  4. from ruamel.yaml import YAML
  5. ALWAYS_RUN_ARCHES = ["amd64", "x86_64"]
  6. SHORT_RUN = sys.argv[1]
  7. yaml = YAML(typ='safe')
  8. entries = list()
  9. run_limited = False
  10. with open('.github/data/distros.yml') as f:
  11. data = yaml.load(f)
  12. if bool(int(SHORT_RUN)):
  13. run_limited = True
  14. for i, v in enumerate(data['include']):
  15. if 'packages' in data['include'][i]:
  16. for arch in data['include'][i]['packages']['arches']:
  17. if arch in ALWAYS_RUN_ARCHES or not run_limited:
  18. entries.append({
  19. 'distro': data['include'][i]['distro'],
  20. 'version': data['include'][i]['version'],
  21. 'repo_distro': data['include'][i]['packages']['repo_distro'],
  22. 'format': data['include'][i]['packages']['type'],
  23. 'base_image': data['include'][i]['base_image'] if 'base_image' in data['include'][i] else ':'.join([data['include'][i]['distro'], data['include'][i]['version']]),
  24. 'builder_rev': data['include'][i]['packages']['builder_rev'],
  25. 'platform': data['platform_map'][arch],
  26. 'bundle_sentry': data['include'][i]['bundle_sentry'][arch],
  27. 'arch': arch
  28. })
  29. entries.sort(key=lambda k: (data['arch_order'].index(k['arch']), k['distro'], k['version']))
  30. matrix = json.dumps({'include': entries}, sort_keys=True)
  31. print(matrix)