diff --git a/.github/workflows/test.py b/.github/workflows/test.py new file mode 100644 index 000000000..c0a41c480 --- /dev/null +++ b/.github/workflows/test.py @@ -0,0 +1,33 @@ +# Extract from the files changed by this PR the channels/releases affected +import re +import sys +import json + +def main() -> None: + releases_affected = set() + + for file_path in sys.argv: + pattern = "^releases" + + # check if string starts with the "releases" + file_path_starts_with_releases = re.search(pattern, file_path) + + if file_path_starts_with_releases : + directories = file_path.split('/') + track = directories[1] + risk = directories[2] + accepted_tracks = ["1.4","1.6","1.7","latest"] + accepted_risks = ["beta","edge","stable"] + + if(track in accepted_tracks and risk in accepted_risks): + channel = f"{track}/{risk}" + print(channel) + releases_affected.add(channel) + else: + raise Exception(f"File {file_path} was changed in 'releases' directory but it's not part of a known release/channel.") + + releases_affected_json = json.dumps(list(releases_affected)) + print(f"The following releases have been affected by this PR: {releases_affected_json}") + print(f'::set-output name=releases_affected_json::{releases_affected_json}') + +main()