|
11 | 11 | import sys |
12 | 12 |
|
13 | 13 | from ..git import Git |
| 14 | +from ..github import GitHub |
14 | 15 |
|
15 | 16 | from .parser import Parser |
16 | 17 |
|
@@ -48,6 +49,11 @@ def parse_args(): |
48 | 49 |
|
49 | 50 | parser = ArgumentParser(description="Parse flavors.yaml and generate combinations.") |
50 | 51 |
|
| 52 | + parser.add_argument( |
| 53 | + "--commit", |
| 54 | + default=None, |
| 55 | + help="Commit hash to fetch flavors.yaml from GitHub (if not specified, uses local file).", |
| 56 | + ) |
51 | 57 | parser.add_argument( |
52 | 58 | "--no-arch", |
53 | 59 | action="store_true", |
@@ -120,25 +126,44 @@ def main(): |
120 | 126 |
|
121 | 127 | args = parse_args() |
122 | 128 |
|
123 | | - flavors_file = os.path.join(Git().root, "flavors.yaml") |
124 | | - |
125 | | - if not os.path.isfile(flavors_file): |
126 | | - sys.exit(f"Error: {flavors_file} does not exist.") |
127 | | - |
128 | | - # Load and validate the flavors.yaml |
129 | | - with open(flavors_file, "r") as file: |
130 | | - flavors_data = file.read() |
131 | | - |
132 | | - combinations = Parser(flavors_data).filter( |
133 | | - include_only_patterns=args.include_only, |
134 | | - wildcard_excludes=args.exclude, |
135 | | - only_build=args.build, |
136 | | - only_test=args.test, |
137 | | - only_test_platform=args.test_platform, |
138 | | - only_publish=args.publish, |
139 | | - filter_categories=args.category, |
140 | | - exclude_categories=args.exclude_category, |
141 | | - ) |
| 129 | + if args.commit: |
| 130 | + # Use GitHub API to fetch flavors.yaml |
| 131 | + github = GitHub() |
| 132 | + flavors_content = github.get_flavors_yaml(commit=args.commit) |
| 133 | + |
| 134 | + parser = Parser(data=flavors_content) |
| 135 | + |
| 136 | + combinations = parser.filter( |
| 137 | + include_only_patterns=args.include_only, |
| 138 | + wildcard_excludes=args.exclude, |
| 139 | + only_build=args.build, |
| 140 | + only_test=args.test, |
| 141 | + only_test_platform=args.test_platform, |
| 142 | + only_publish=args.publish, |
| 143 | + filter_categories=args.category, |
| 144 | + exclude_categories=args.exclude_category, |
| 145 | + ) |
| 146 | + else: |
| 147 | + # Use local file |
| 148 | + flavors_file = os.path.join(Git().root, "flavors.yaml") |
| 149 | + |
| 150 | + if not os.path.isfile(flavors_file): |
| 151 | + sys.exit(f"Error: {flavors_file} does not exist.") |
| 152 | + |
| 153 | + # Load and validate the flavors.yaml |
| 154 | + with open(flavors_file, "r") as file: |
| 155 | + flavors_data = file.read() |
| 156 | + |
| 157 | + combinations = Parser(flavors_data).filter( |
| 158 | + include_only_patterns=args.include_only, |
| 159 | + wildcard_excludes=args.exclude, |
| 160 | + only_build=args.build, |
| 161 | + only_test=args.test, |
| 162 | + only_test_platform=args.test_platform, |
| 163 | + only_publish=args.publish, |
| 164 | + filter_categories=args.category, |
| 165 | + exclude_categories=args.exclude_category, |
| 166 | + ) |
142 | 167 |
|
143 | 168 | if args.json_by_arch: |
144 | 169 | grouped_combinations = Parser.group_by_arch(combinations) |
|
0 commit comments