Skip to content

Commit e6ab9e7

Browse files
committed
ci: save kustomize build output to files for artifact upload
- Modify run_kustomize_build to return the built YAML output - Save output.yaml to .build-test/ for both rhoso components and examples - This enables the workflow artifact to contain the built manifests Made-with: opencode Model: big-pickle (opencode/big-pickle)
1 parent 18c6633 commit e6ab9e7

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

.github/scripts/verify-kustomize-builds.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ def generate_kustomization(
153153
)
154154

155155

156-
def run_kustomize_build(build_dir: Path) -> tuple[bool, str]:
157-
"""Run kustomize build in build_dir. Return (success, error_message)."""
156+
def run_kustomize_build(build_dir: Path) -> tuple[bool, str, str]:
157+
"""Run kustomize build in build_dir. Return (success, error_message, output)."""
158158
try:
159159
result = subprocess.run(
160160
["kustomize", "build", "."],
@@ -164,29 +164,35 @@ def run_kustomize_build(build_dir: Path) -> tuple[bool, str]:
164164
timeout=60,
165165
)
166166
if result.returncode == 0:
167-
return True, ""
168-
return False, result.stderr or result.stdout or f"Exit code {result.returncode}"
167+
return True, "", result.stdout
168+
return False, result.stderr or result.stdout or f"Exit code {result.returncode}", ""
169169
except subprocess.TimeoutExpired:
170-
return False, "Command timed out after 60s"
170+
return False, "Command timed out after 60s", ""
171171
except FileNotFoundError:
172-
return False, "kustomize not found in PATH"
172+
return False, "kustomize not found in PATH", ""
173173
except Exception as e:
174-
return False, str(e)
174+
return False, str(e), ""
175175

176176

177177
def build_and_collect(
178178
test_case: BuildTestCase, repo_root: Path, build_base: Path
179179
) -> BuildResult:
180180
"""Generate kustomization (or use source dir), run build, return result."""
181181
if test_case.source_directory is not None:
182-
# Build directly from the example directory (tests refs, patches, etc. as committed)
183182
build_dir = test_case.source_directory
183+
output_dir = build_base / test_case.build_dir_name
184184
else:
185185
build_dir = build_base / test_case.build_dir_name
186186
build_dir.mkdir(parents=True, exist_ok=True)
187187
generate_kustomization(build_dir, test_case.component_paths, repo_root)
188+
output_dir = build_dir
188189

189-
success, error = run_kustomize_build(build_dir)
190+
success, error, output = run_kustomize_build(build_dir)
191+
192+
if success and output:
193+
output_dir.mkdir(parents=True, exist_ok=True)
194+
output_file = output_dir / "output.yaml"
195+
output_file.write_text(output)
190196

191197
return BuildResult(
192198
test_case=test_case,

0 commit comments

Comments
 (0)