Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions .github/scripts/verify-kustomize-builds.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env python3
"""Verify that all gitops components build successfully with kustomize.

Discovers components dynamically under components/rhoso/ and example/,
runs kustomize build for each, and reports a summary table. Fails only at
the end if any component failed.
Discovers components dynamically under components/rhoso/, example/, and
resources/, runs kustomize build for each, and reports a summary table.
Fails only at the end if any component failed.
"""

from __future__ import annotations
Expand All @@ -18,6 +18,7 @@
KUSTOMIZATION_FILES = ("kustomization.yaml", "kustomization.yml", "Kustomization")
RHOSO_COMPONENTS_ROOT = Path("components/rhoso")
EXAMPLES_ROOT = Path("example")
RESOURCES_ROOT = Path("resources")
BUILD_TEST_DIR = Path(".build-test")


Expand Down Expand Up @@ -112,6 +113,31 @@ def discover_examples(repo_root: Path) -> list[BuildTestCase]:
return cases


def discover_resources(repo_root: Path) -> list[BuildTestCase]:
"""Discover all resource wrappers under resources/."""
cases: list[BuildTestCase] = []
resources_root = repo_root / RESOURCES_ROOT

if not resources_root.exists():
return cases

for kustomization_path in _find_kustomization_files(resources_root):
rel_path = kustomization_path.relative_to(resources_root).parent
id_str = str(rel_path).replace("\\", "/")
slug = id_str.replace("/", "-")
source_dir = resources_root / rel_path
cases.append(
BuildTestCase(
id=f"resources/{id_str}",
component_paths=[],
build_dir_name=f"resources-{slug}",
source_directory=source_dir,
)
)

return cases


def _find_kustomization_files(root: Path) -> list[Path]:
"""Find all kustomization files under root."""
results: list[Path] = []
Expand Down Expand Up @@ -240,6 +266,7 @@ def main() -> int:
test_cases: list[BuildTestCase] = []
test_cases.extend(discover_rhoso_components(repo_root))
test_cases.extend(discover_examples(repo_root))
test_cases.extend(discover_resources(repo_root))

if not test_cases:
print("No components to test.")
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/kustomize-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on: # yamllint disable-line rule:truthy
- main
paths:
- "components/rhoso/**"
- "components/secrets/**"
- "resources/**"
- "example/**"
- ".github/workflows/kustomize-build.yml"
- ".github/scripts/verify-kustomize-builds.py"
Expand All @@ -16,6 +18,8 @@ on: # yamllint disable-line rule:truthy
- main
paths:
- "components/rhoso/**"
- "components/secrets/**"
- "resources/**"
- "example/**"
- ".github/workflows/kustomize-build.yml"
- ".github/scripts/verify-kustomize-builds.py"
Expand Down
Comment thread
oliashish marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
components:
- ../../../components/secrets/external-secrets-operator/redhat
Loading