diff --git a/.github/workflows/compatibility.yml b/.github/workflows/compatibility.yml index 05a5573..b758d30 100644 --- a/.github/workflows/compatibility.yml +++ b/.github/workflows/compatibility.yml @@ -65,7 +65,8 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install --editable 'libs/tekton-dag-common[test]' --editable 'libs/baggage-python[test]' - python -m pytest libs/baggage-python/tests libs/tekton-dag-common/tests -q --tb=short + (cd libs/baggage-python && python -m pytest tests -q --tb=short) + (cd libs/tekton-dag-common && python -m pytest tests -q --tb=short) node: name: Node ${{ matrix.node }} diff --git a/helm/tekton-dag/package.sh b/helm/tekton-dag/package.sh index 5f42275..de12335 100755 --- a/helm/tekton-dag/package.sh +++ b/helm/tekton-dag/package.sh @@ -10,10 +10,12 @@ echo " Repo root: $REPO_ROOT" rm -rf "$CHART_DIR/raw" mkdir -p "$CHART_DIR/raw/tasks" "$CHART_DIR/raw/pipelines" "$CHART_DIR/raw/stacks" \ - "$CHART_DIR/raw/stack-crs" "$CHART_DIR/raw/team-crs" + "$CHART_DIR/raw/stack-crs" "$CHART_DIR/raw/team-crs" "$CHART_DIR/raw/scripts" echo " Copying tasks..." cp "$REPO_ROOT"/tasks/*.yaml "$CHART_DIR/raw/tasks/" +cp "$REPO_ROOT/scripts/run-stack-tests-runners.sh" \ + "$CHART_DIR/raw/scripts/run-stack-tests-runners.sh" echo " Copying pipelines and triggers..." cp "$REPO_ROOT"/pipeline/*.yaml "$CHART_DIR/raw/pipelines/" diff --git a/helm/tekton-dag/templates/configmap-run-stack-tests-runners.yaml b/helm/tekton-dag/templates/configmap-run-stack-tests-runners.yaml new file mode 100644 index 0000000..d033c57 --- /dev/null +++ b/helm/tekton-dag/templates/configmap-run-stack-tests-runners.yaml @@ -0,0 +1,14 @@ +{{- $script := .Files.Get "raw/scripts/run-stack-tests-runners.sh" -}} +{{- if $script }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: run-stack-tests-runners + namespace: {{ .Values.namespace }} + labels: + app.kubernetes.io/part-of: tekton-job-standardization + {{- include "tekton-dag.labels" . | nindent 4 }} +data: + run-stack-tests-runners.sh: | + {{- $script | nindent 4 }} +{{- end }} diff --git a/libs/tekton-dag-common/tests/test_m17_compatibility.py b/libs/tekton-dag-common/tests/test_m17_compatibility.py index ac9208f..f13a8ae 100644 --- a/libs/tekton-dag-common/tests/test_m17_compatibility.py +++ b/libs/tekton-dag-common/tests/test_m17_compatibility.py @@ -17,6 +17,8 @@ def test_compatibility_workflow_covers_documented_runtimes(): assert 'java: ["21"]' in workflow assert 'php: ["8.3"]' in workflow assert "bash scripts/check-support-matrix.sh" in workflow + assert "(cd libs/baggage-python && python -m pytest tests" in workflow + assert "(cd libs/tekton-dag-common && python -m pytest tests" in workflow assert 'workflow: ".github/workflows/compatibility.yml"' in matrix diff --git a/libs/tekton-dag-common/tests/test_m17_stack_test_runners.py b/libs/tekton-dag-common/tests/test_m17_stack_test_runners.py index 35e4efe..9eb09b4 100644 --- a/libs/tekton-dag-common/tests/test_m17_stack_test_runners.py +++ b/libs/tekton-dag-common/tests/test_m17_stack_test_runners.py @@ -7,11 +7,18 @@ def test_task_sources_extracted_runner_script(): task = (ROOT / "tasks/run-stack-tests.yaml").read_text() + installer = (ROOT / "scripts/install-tekton.sh").read_text() + chart = (ROOT / "helm/tekton-dag/templates/configmap-run-stack-tests-runners.yaml").read_text() + packager = (ROOT / "helm/tekton-dag/package.sh").read_text() script = (ROOT / "scripts/run-stack-tests-runners.sh").read_text() - assert "scripts/run-stack-tests-runners.sh" in task - assert "ERROR: run-stack-tests runners script missing" in task + assert "name: run-stack-tests-runners" in task + assert "mountPath: /opt/tekton-dag" in task + assert "ERROR: run-stack-tests runners ConfigMap missing" in task assert "PHASE 2: Per-app tests" not in task + assert "kubectl create configmap run-stack-tests-runners" in installer + assert "raw/scripts/run-stack-tests-runners.sh" in chart + assert "raw/scripts/run-stack-tests-runners.sh" in packager assert "run_newman" in script assert "run_playwright" in script assert "run_artillery" in script diff --git a/scripts/check-helm-chart.sh b/scripts/check-helm-chart.sh index da4eaf7..09a2cff 100644 --- a/scripts/check-helm-chart.sh +++ b/scripts/check-helm-chart.sh @@ -39,5 +39,16 @@ for filename in sys.argv[1:]: documents = [document for document in yaml.safe_load_all(path.read_text()) if document] if not documents: raise SystemExit(f"{path}: rendered no resources") + runners = [ + document + for document in documents + if document.get("kind") == "ConfigMap" + and document.get("metadata", {}).get("name") == "run-stack-tests-runners" + ] + if not runners: + raise SystemExit(f"{path}: missing ConfigMap run-stack-tests-runners") + script = runners[0].get("data", {}).get("run-stack-tests-runners.sh", "") + if "run_newman" not in script: + raise SystemExit(f"{path}: runner ConfigMap is missing run_newman") print(f"{path.name}: parsed {len(documents)} resource(s)") PY diff --git a/scripts/install-tekton.sh b/scripts/install-tekton.sh index 92410b2..45be660 100755 --- a/scripts/install-tekton.sh +++ b/scripts/install-tekton.sh @@ -79,6 +79,9 @@ kubectl apply -f "$TEKTON_GIT_CLONE_URL" -n "$NAMESPACE" 2>/dev/null || \ # 4. This repo's tasks and pipelines (kubectl apply is idempotent; triggers apply now that Triggers is installed) echo " Applying stack tasks and pipelines..." +kubectl create configmap run-stack-tests-runners \ + --from-file=run-stack-tests-runners.sh="$MILESTONE_DIR/scripts/run-stack-tests-runners.sh" \ + -n "$NAMESPACE" --dry-run=client -o yaml | kubectl apply -f - apply_with_retry -f "$MILESTONE_DIR/tasks/" -n "$NAMESPACE" # EventListener reconciliation creates el-* Services. It can race the explicit # Service in triggers.yaml between kubectl's read and create operations. diff --git a/tasks/run-stack-tests.yaml b/tasks/run-stack-tests.yaml index f3ebbc0..0071675 100644 --- a/tasks/run-stack-tests.yaml +++ b/tasks/run-stack-tests.yaml @@ -23,8 +23,9 @@ spec: apps this validates the PR build directly. For non-intercepted apps this validates they still work with the header present. - Runner logic lives in scripts/run-stack-tests-runners.sh in the - platform repo (cloned into the test-source workspace). + Runner logic lives in scripts/run-stack-tests-runners.sh and is + mounted from ConfigMap run-stack-tests-runners so the Task does + not depend on the cloned platform git-revision. params: - name: stack-json type: string @@ -68,6 +69,9 @@ spec: - name: run-tests image: node:22-alpine workingDir: $(workspaces.test-source.path) + volumeMounts: + - name: runners-script + mountPath: /opt/tekton-dag script: | #!/bin/sh set -e @@ -91,10 +95,14 @@ spec: DEFAULT_NS TESTS_TO_RUN UNMAPPED_AREA APPS_TO_TEST \ TEST_SOURCE TEST_SUMMARY_PATH - RUNNERS="${TEST_SOURCE}/scripts/run-stack-tests-runners.sh" + RUNNERS="/opt/tekton-dag/run-stack-tests-runners.sh" if [ ! -f "$RUNNERS" ]; then - echo "ERROR: run-stack-tests runners script missing: $RUNNERS" >&2 + echo "ERROR: run-stack-tests runners ConfigMap missing: $RUNNERS" >&2 exit 1 fi # shellcheck disable=SC1090 . "$RUNNERS" + volumes: + - name: runners-script + configMap: + name: run-stack-tests-runners