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
17 changes: 13 additions & 4 deletions .github/scripts/run_chart_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
- Checks if helm-unittest plugin is installed
- If not installed, runs: helm plugin install (does not require Makefile)
- Finds all directories under charts/ containing Chart.yaml
- For each chart directory with a Makefile, runs: make -C <chart_dir> tests
- For each chart directory with a Makefile, runs: make -C <chart_dir> test-all
(when defined) or `make tests` (legacy fallback) — `test-all` exercises the
parent-recursive suite AND each subchart standalone, catching helper/value
divergence that the parent-only run masks
- Skips charts without a Makefile (e.g., library charts with no tests)
- Subcharts are tested through their parent chart's test suite

REQUIREMENTS:
- helm CLI must be installed
Expand Down Expand Up @@ -91,8 +93,15 @@ def main():
skipped_charts.append(chart_dir)
continue

print(f"Running helm chart tests in {chart_dir}...")
test_result = subprocess.run(["make", "-C", chart_dir, "tests"])
# Prefer `test-all` (parent + standalone subcharts) when the chart's Makefile defines
# it; fall back to legacy `tests` target for charts that haven't adopted it yet.
makefile_targets = subprocess.run(
["make", "-C", chart_dir, "-pn"], capture_output=True, text=True
).stdout
target = "test-all" if "\ntest-all:" in makefile_targets else "tests"

print(f"Running helm chart tests in {chart_dir} (target: {target})...")
test_result = subprocess.run(["make", "-C", chart_dir, target])
if test_result.returncode != 0:
print(f"Helm chart tests failed in {chart_dir}.")
failed_charts.append(chart_dir)
Expand Down
38 changes: 37 additions & 1 deletion charts/platform/Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
.PHONY: test tests unittests unittests-no-build debug check-unittest-plugin install-unittest-plugin clean-deps clean-subchart-packages rebuild-deps rebuild-deps-and-unpack rebuild-deps-force help
.PHONY: test tests unittests unittests-no-build debug check-unittest-plugin install-unittest-plugin clean-deps clean-subchart-packages rebuild-deps rebuild-deps-and-unpack rebuild-deps-force unittests-standalone test-all help

# Run tests (with external dependencies rebuild) - DEFAULT behavior
test: unittests
tests: test
test-no-build: unittests-no-build
tests-no-build: test-no-build

# Run BOTH the parent's recursive test suite AND each standalone-installable subchart's
# tests rendered with that subchart's own values/helpers (matching how a customer would
# install it on its own). Catches helper / values divergence that the parent-recursive
# run silently masks.
test-all: unittests unittests-standalone

help:
@echo "Seqera Platform Helm Chart - Available Make Targets"
@echo ""
@echo "Testing:"
@echo " make test - Rebuild all Platform dependencies and run tests (DEFAULT)"
@echo " make test-no-build - Run tests without rebuilding dependencies"
@echo " make test-all - Run parent-recursive tests AND each subchart standalone"
@echo " make unittests-standalone - Run each subchart's tests standalone (no parent context)"
@echo " make debug - Run tests in debug mode"
@echo " make unittests-update-snapshots - Rebuild all Platform dependencies and update snapshots"
@echo ""
Expand Down Expand Up @@ -119,6 +127,34 @@ unittests: rebuild-deps
@echo "Running unit tests..."
@helm unittest .

# Run each subchart's unit tests STANDALONE — i.e. invoke `helm unittest` from inside the
# subchart directory so its templates render with its own values.yaml / helpers, not under
# the parent's merged context. A subchart is considered "standalone-installable" if it ships
# its own `tests/` directory.
#
# This complements `unittests`: the parent-recursive run exercises the full integrated
# deployment, this target exercises each subchart as if a customer installed it on its own.
unittests-standalone: rebuild-deps
@echo "Running unit tests for each standalone-installable subchart..."
@failed=""; \
for subchart_dir in charts/*/; do \
subchart=$$(basename $$subchart_dir); \
if [ ! -d "$$subchart_dir/tests" ]; then \
echo "→ skipping $$subchart (no tests/ directory)"; \
continue; \
fi; \
echo ""; \
echo "→ $$subchart (standalone)"; \
(cd "$$subchart_dir" && helm unittest .) || failed="$$failed $$subchart"; \
done; \
if [ -n "$$failed" ]; then \
echo ""; \
echo "✗ standalone tests failed for:$$failed"; \
exit 1; \
fi; \
echo ""; \
echo "✓ all standalone subchart tests passed"

unittests-update-snapshots: rebuild-deps
@echo "Running unit tests and updating snapshots..."
@helm unittest -u .
Expand Down
Loading