diff options
author | Austin S. Hemmelgarn <austin@netdata.cloud> | 2022-12-02 10:17:41 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-02 10:17:41 -0500 |
commit | cf199ac0344a6e77ca76879f70d883ddaf1ca6ff (patch) | |
tree | df0be507a3261f601daa9a6047133d9b54c82046 /.github/scripts/gen-matrix-packaging.py | |
parent | 3fc34a5e32fc16c7c832a0caefddf913c4e56eac (diff) |
Update workflows to use $GITHUB_OUTPUT instead of ::set-output:: (#13960)
* Update workflows to use $GITHUB_OUTPUT instead of ::set-output::
* Fix python code.
* Fix handling of python-based build matrix generation.
Diffstat (limited to '.github/scripts/gen-matrix-packaging.py')
-rwxr-xr-x | .github/scripts/gen-matrix-packaging.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/.github/scripts/gen-matrix-packaging.py b/.github/scripts/gen-matrix-packaging.py new file mode 100755 index 0000000000..e58dd736fe --- /dev/null +++ b/.github/scripts/gen-matrix-packaging.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 + +import json +import sys + +from ruamel.yaml import YAML + +ALWAYS_RUN_ARCHES = ["amd64", "x86_64"] +SHORT_RUN = sys.argv[1] +yaml = YAML(typ='safe') +entries = list() +run_limited = False + +with open('.github/data/distros.yml') as f: + data = yaml.load(f) + +if "${{ github.event_name }}" == "pull_request" and bool(int(SHORT_RUN)): + run_limited = True + +for i, v in enumerate(data['include']): + if 'packages' in data['include'][i]: + for arch in data['include'][i]['packages']['arches']: + if arch in ALWAYS_RUN_ARCHES or not run_limited: + entries.append({ + 'distro': data['include'][i]['distro'], + 'version': data['include'][i]['version'], + 'repo_distro': data['include'][i]['packages']['repo_distro'], + 'format': data['include'][i]['packages']['type'], + 'base_image': data['include'][i]['base_image'] if 'base_image' in data['include'][i] else data['include'][i]['distro'], + 'platform': data['platform_map'][arch], + 'arch': arch + }) + +entries.sort(key=lambda k: (data['arch_order'].index(k['arch']), k['distro'], k['version'])) +matrix = json.dumps({'include': entries}, sort_keys=True) +print(matrix) |