| # Copyright (c) 2024 VEXXHOST, Inc. |
| # SPDX-License-Identifier: Apache-2.0 |
| def run_helm_unittest(charts_dir, exclusions): |
| :param charts_dir: The directory containing Helm charts. |
| :param exclusions: List of subdirectories to exclude. |
| for d in glob.glob(os.path.join(charts_dir, "*")) |
| if os.path.isdir(d) and os.path.basename(d) not in exclusions |
| print(f"Running helm unittest for chart: {chart}") |
| chart_tests_path = f"../../roles/{chart}/tests/*.yaml" |
| chart_path = os.path.join(charts_dir, chart) |
| ["helm", "unittest", "-f", chart_tests_path, chart_path], |
| print(f"Helm unitest passed for chart: {chart}") |
| except subprocess.CalledProcessError as e: |
| print(f"Helm unittest failed for chart: {chart}") |
| print("\nAll Helm unitests passed successfully!") |
| print("\nOne or more charts had test failures.") |
| charts_dir = os.getenv("CHARTS_DIR", "charts") |
| run_helm_unittest(charts_dir, exclusions) |
| if __name__ == "__main__": |