diff --git a/charts/pipelines-library/templates/pipelines/helm/gerrit-build-default.yaml b/charts/pipelines-library/templates/pipelines/helm/gerrit-build-default.yaml index de36b465..ab5ebbb1 100644 --- a/charts/pipelines-library/templates/pipelines/helm/gerrit-build-default.yaml +++ b/charts/pipelines-library/templates/pipelines/helm/gerrit-build-default.yaml @@ -53,6 +53,21 @@ spec: {{- include "gerrit-build-start" . | nindent 4 }} + - name: check-chart-name + params: + - name: codebase_name + value: $(params.CODEBASE_NAME) + - name: chart_dir + value: $(params.CHART_DIR) + runAfter: + - fetch-repository + taskRef: + name: check-helm-chart-name + workspaces: + - name: source + subPath: source + workspace: shared-workspace + - name: get-version taskRef: kind: Task diff --git a/charts/pipelines-library/templates/pipelines/helm/gerrit-build-edp.yaml b/charts/pipelines-library/templates/pipelines/helm/gerrit-build-edp.yaml index 9a5ea1f9..b620aac4 100644 --- a/charts/pipelines-library/templates/pipelines/helm/gerrit-build-edp.yaml +++ b/charts/pipelines-library/templates/pipelines/helm/gerrit-build-edp.yaml @@ -56,6 +56,20 @@ spec: {{- include "gerrit-build-start" . | nindent 4 }} + - name: check-chart-name + params: + - name: codebase_name + value: $(params.CODEBASE_NAME) + - name: chart_dir + value: $(params.CHART_DIR) + runAfter: + - fetch-repository + taskRef: + name: check-helm-chart-name + workspaces: + - name: source + subPath: source + workspace: shared-workspace - name: get-version taskRef: kind: Task diff --git a/charts/pipelines-library/templates/pipelines/helm/gerrit-review.yaml b/charts/pipelines-library/templates/pipelines/helm/gerrit-review.yaml index d9f98936..27adaf8f 100644 --- a/charts/pipelines-library/templates/pipelines/helm/gerrit-review.yaml +++ b/charts/pipelines-library/templates/pipelines/helm/gerrit-review.yaml @@ -61,6 +61,21 @@ spec: - name: ssh-directory workspace: ssh-creds + - name: check-chart-name + params: + - name: codebase_name + value: $(params.CODEBASE_NAME) + - name: chart_dir + value: $(params.CHART_DIR) + runAfter: + - fetch-repository + taskRef: + name: check-helm-chart-name + workspaces: + - name: source + subPath: source + workspace: shared-workspace + - name: gerrit-notify taskRef: kind: Task diff --git a/charts/pipelines-library/templates/pipelines/helm/github-build-default.yaml b/charts/pipelines-library/templates/pipelines/helm/github-build-default.yaml index 372b53f2..71b0d76f 100644 --- a/charts/pipelines-library/templates/pipelines/helm/github-build-default.yaml +++ b/charts/pipelines-library/templates/pipelines/helm/github-build-default.yaml @@ -49,6 +49,21 @@ spec: {{- include "github-build-start" . | nindent 4 }} + - name: check-chart-name + params: + - name: codebase_name + value: $(params.CODEBASE_NAME) + - name: chart_dir + value: $(params.CHART_DIR) + runAfter: + - fetch-repository + taskRef: + name: check-helm-chart-name + workspaces: + - name: source + subPath: source + workspace: shared-workspace + - name: get-version taskRef: kind: Task diff --git a/charts/pipelines-library/templates/pipelines/helm/github-build-edp.yaml b/charts/pipelines-library/templates/pipelines/helm/github-build-edp.yaml index ba2f7eb0..90c279df 100644 --- a/charts/pipelines-library/templates/pipelines/helm/github-build-edp.yaml +++ b/charts/pipelines-library/templates/pipelines/helm/github-build-edp.yaml @@ -52,6 +52,21 @@ spec: {{- include "github-build-start" . | nindent 4 }} + - name: check-chart-name + params: + - name: codebase_name + value: $(params.CODEBASE_NAME) + - name: chart_dir + value: $(params.CHART_DIR) + runAfter: + - fetch-repository + taskRef: + name: check-helm-chart-name + workspaces: + - name: source + subPath: source + workspace: shared-workspace + - name: get-version taskRef: kind: Task diff --git a/charts/pipelines-library/templates/pipelines/helm/github-review.yaml b/charts/pipelines-library/templates/pipelines/helm/github-review.yaml index 28002324..0c892aeb 100644 --- a/charts/pipelines-library/templates/pipelines/helm/github-review.yaml +++ b/charts/pipelines-library/templates/pipelines/helm/github-review.yaml @@ -84,6 +84,21 @@ spec: - name: ssh-directory workspace: ssh-creds + - name: check-chart-name + params: + - name: codebase_name + value: $(params.CODEBASE_NAME) + - name: chart_dir + value: $(params.CHART_DIR) + runAfter: + - fetch-repository + taskRef: + name: check-helm-chart-name + workspaces: + - name: source + subPath: source + workspace: shared-workspace + - name: helm-docs taskRef: kind: Task diff --git a/charts/pipelines-library/templates/pipelines/helm/gitlab-build-default.yaml b/charts/pipelines-library/templates/pipelines/helm/gitlab-build-default.yaml index 248ff024..59b2689d 100644 --- a/charts/pipelines-library/templates/pipelines/helm/gitlab-build-default.yaml +++ b/charts/pipelines-library/templates/pipelines/helm/gitlab-build-default.yaml @@ -49,6 +49,21 @@ spec: {{- include "gitlab-build-start" . | nindent 4 }} + - name: check-chart-name + params: + - name: codebase_name + value: $(params.CODEBASE_NAME) + - name: chart_dir + value: $(params.CHART_DIR) + runAfter: + - fetch-repository + taskRef: + name: check-helm-chart-name + workspaces: + - name: source + subPath: source + workspace: shared-workspace + - name: get-version taskRef: kind: Task diff --git a/charts/pipelines-library/templates/pipelines/helm/gitlab-build-edp.yaml b/charts/pipelines-library/templates/pipelines/helm/gitlab-build-edp.yaml index 6057f03e..43174b76 100644 --- a/charts/pipelines-library/templates/pipelines/helm/gitlab-build-edp.yaml +++ b/charts/pipelines-library/templates/pipelines/helm/gitlab-build-edp.yaml @@ -52,6 +52,21 @@ spec: {{- include "gitlab-build-start" . | nindent 4 }} + - name: check-chart-name + params: + - name: codebase_name + value: $(params.CODEBASE_NAME) + - name: chart_dir + value: $(params.CHART_DIR) + runAfter: + - fetch-repository + taskRef: + name: check-helm-chart-name + workspaces: + - name: source + subPath: source + workspace: shared-workspace + - name: get-version taskRef: kind: Task diff --git a/charts/pipelines-library/templates/pipelines/helm/gitlab-review.yaml b/charts/pipelines-library/templates/pipelines/helm/gitlab-review.yaml index aa3b2e59..ead056f7 100644 --- a/charts/pipelines-library/templates/pipelines/helm/gitlab-review.yaml +++ b/charts/pipelines-library/templates/pipelines/helm/gitlab-review.yaml @@ -84,6 +84,21 @@ spec: - name: ssh-directory workspace: ssh-creds + - name: check-chart-name + params: + - name: codebase_name + value: $(params.CODEBASE_NAME) + - name: chart_dir + value: $(params.CHART_DIR) + runAfter: + - fetch-repository + taskRef: + name: check-helm-chart-name + workspaces: + - name: source + subPath: source + workspace: shared-workspace + - name: helm-docs taskRef: kind: Task diff --git a/charts/pipelines-library/templates/tasks/check-helm-chart-name.yaml b/charts/pipelines-library/templates/tasks/check-helm-chart-name.yaml new file mode 100644 index 00000000..137d38fa --- /dev/null +++ b/charts/pipelines-library/templates/tasks/check-helm-chart-name.yaml @@ -0,0 +1,37 @@ +apiVersion: tekton.dev/v1beta1 +kind: Task +metadata: + name: check-helm-chart-name + namespace: edp-delivery-ot-dev +spec: + params: + - name: codebase_name + type: string + - name: chart_dir + description: The directory in source that contains the helm chart + default: "." + steps: + - name: check-helm-chart-name + env: + - name: CODEBASE_NAME + value: $(params.codebase_name) + - name: CHART_DIR + value: $(params.chart_dir) + image: alpine:3.18.6 + script: | + #!/bin/sh + # Extract the chart name from the Chart.yaml + CHART_NAME=$(awk '/^name:/ {print $2}' ${CHART_DIR}/Chart.yaml) + + # Compare with CODEBASE_NAME + if [ "$CHART_NAME" == "$CODEBASE_NAME" ]; then + echo "The name in Chart.yaml matches the CODEBASE_NAME." + else + echo "The name in Chart.yaml does not match the CODEBASE_NAME." + exit 1 + fi + + workingDir: $(workspaces.source.path) + workspaces: + - description: A workspace that contains fetched git repo. + name: source diff --git a/charts/pipelines-library/tests/test_helm_pipelines.py b/charts/pipelines-library/tests/test_helm_pipelines.py index 715311a4..3bdbf6f2 100644 --- a/charts/pipelines-library/tests/test_helm_pipelines.py +++ b/charts/pipelines-library/tests/test_helm_pipelines.py @@ -26,11 +26,12 @@ def test_helm_pipelines_gerrit(): r = ht["pipeline"][review]["spec"]["tasks"] assert "fetch-repository" in r[0]["name"] - assert "gerrit-notify" in r[1]["name"] - assert "helm-docs" in r[2]["name"] - assert "helm-dependency-update" in r[3]["name"] - assert "helm-lint" in r[4]["name"] - assert "helm-template" in r[5]["name"] + assert "check-chart-name" in r[1]["name"] + assert "gerrit-notify" in r[2]["name"] + assert "helm-docs" in r[3]["name"] + assert "helm-dependency-update" in r[4]["name"] + assert "helm-lint" in r[5]["name"] + assert "helm-template" in r[6]["name"] assert "gerrit-vote-success" in ht["pipeline"][review]["spec"]["finally"][0]["name"] assert "gerrit-vote-failure" in ht["pipeline"][review]["spec"]["finally"][1]["name"] @@ -38,27 +39,29 @@ def test_helm_pipelines_gerrit(): assert "fetch-repository" in bdef[0]["name"] assert "gerrit-notify" in bdef[1]["name"] assert "init-values" in bdef[2]["name"] - assert "get-version" in bdef[3]["name"] - assert "helm-dependency-update" in bdef[4]["name"] - assert "helm-lint" in bdef[5]["name"] - assert "helm-template" in bdef[6]["name"] - assert "helm-push" in bdef[7]["name"] - assert "git-tag" in bdef[8]["name"] - assert "update-cbis" in bdef[9]["name"] + assert "check-chart-name" in bdef[3]["name"] + assert "get-version" in bdef[4]["name"] + assert "helm-dependency-update" in bdef[5]["name"] + assert "helm-lint" in bdef[6]["name"] + assert "helm-template" in bdef[7]["name"] + assert "helm-push" in bdef[8]["name"] + assert "git-tag" in bdef[9]["name"] + assert "update-cbis" in bdef[10]["name"] assert "push-to-jira" in ht["pipeline"][build_def]["spec"]["finally"][0]["name"] bedp = ht["pipeline"][build_edp]["spec"]["tasks"] assert "fetch-repository" in bedp[0]["name"] assert "gerrit-notify" in bedp[1]["name"] assert "init-values" in bedp[2]["name"] - assert "get-version" in bedp[3]["name"] - assert "update-build-number" in bedp[4]["name"] - assert "helm-dependency-update" in bedp[5]["name"] - assert "helm-lint" in bedp[6]["name"] - assert "helm-template" in bedp[7]["name"] - assert "helm-push" in bedp[8]["name"] - assert "git-tag" in bedp[9]["name"] - assert "update-cbis" in bedp[10]["name"] + assert "check-chart-name" in bedp[3]["name"] + assert "get-version" in bedp[4]["name"] + assert "update-build-number" in bedp[5]["name"] + assert "helm-dependency-update" in bedp[6]["name"] + assert "helm-lint" in bedp[7]["name"] + assert "helm-template" in bedp[8]["name"] + assert "helm-push" in bedp[9]["name"] + assert "git-tag" in bedp[10]["name"] + assert "update-cbis" in bedp[11]["name"] assert "update-cbb" in ht["pipeline"][build_edp]["spec"]["finally"][0]["name"] assert "push-to-jira" in ht["pipeline"][build_edp]["spec"]["finally"][1]["name"] @@ -137,36 +140,39 @@ def test_helm_pipelines_gitlab(): r = ht["pipeline"][review]["spec"]["tasks"] assert "report-pipeline-start-to-gitlab" in r[0]["name"] assert "fetch-repository" in r[1]["name"] - assert "helm-docs" in r[2]["name"] - assert "helm-dependency-update" in r[3]["name"] - assert "helm-lint" in r[4]["name"] - assert "helm-template" in r[5]["name"] + assert "check-chart-name" in r[2]["name"] + assert "helm-docs" in r[3]["name"] + assert "helm-dependency-update" in r[4]["name"] + assert "helm-lint" in r[5]["name"] + assert "helm-template" in r[6]["name"] assert "gitlab-set-success-status" in ht["pipeline"][review]["spec"]["finally"][0]["name"] assert "gitlab-set-failure-status" in ht["pipeline"][review]["spec"]["finally"][1]["name"] bdef = ht["pipeline"][build_def]["spec"]["tasks"] assert "fetch-repository" in bdef[0]["name"] assert "init-values" in bdef[1]["name"] - assert "get-version" in bdef[2]["name"] - assert "helm-dependency-update" in bdef[3]["name"] - assert "helm-lint" in bdef[4]["name"] - assert "helm-template" in bdef[5]["name"] - assert "helm-push" in bdef[6]["name"] - assert "git-tag" in bdef[7]["name"] - assert "update-cbis" in bdef[8]["name"] + assert "check-chart-name" in bdef[2]["name"] + assert "get-version" in bdef[3]["name"] + assert "helm-dependency-update" in bdef[4]["name"] + assert "helm-lint" in bdef[5]["name"] + assert "helm-template" in bdef[6]["name"] + assert "helm-push" in bdef[7]["name"] + assert "git-tag" in bdef[8]["name"] + assert "update-cbis" in bdef[9]["name"] assert "push-to-jira" in ht["pipeline"][build_def]["spec"]["finally"][0]["name"] bedp = ht["pipeline"][build_edp]["spec"]["tasks"] assert "fetch-repository" in bedp[0]["name"] assert "init-values" in bedp[1]["name"] - assert "get-version" in bedp[2]["name"] - assert "update-build-number" in bedp[3]["name"] - assert "helm-dependency-update" in bedp[4]["name"] - assert "helm-lint" in bedp[5]["name"] - assert "helm-template" in bedp[6]["name"] - assert "helm-push" in bedp[7]["name"] - assert "git-tag" in bedp[8]["name"] - assert "update-cbis" in bedp[9]["name"] + assert "check-chart-name" in bedp[2]["name"] + assert "get-version" in bedp[3]["name"] + assert "update-build-number" in bedp[4]["name"] + assert "helm-dependency-update" in bedp[5]["name"] + assert "helm-lint" in bedp[6]["name"] + assert "helm-template" in bedp[7]["name"] + assert "helm-push" in bedp[8]["name"] + assert "git-tag" in bedp[9]["name"] + assert "update-cbis" in bedp[10]["name"] assert "update-cbb" in ht["pipeline"][build_edp]["spec"]["finally"][0]["name"] assert "push-to-jira" in ht["pipeline"][build_edp]["spec"]["finally"][1]["name"] @@ -243,36 +249,39 @@ def test_helm_pipelines_github(): r = ht["pipeline"][review]["spec"]["tasks"] assert "github-set-pending-status" in r[0]["name"] assert "fetch-repository" in r[1]["name"] - assert "helm-docs" in r[2]["name"] - assert "helm-dependency-update" in r[3]["name"] - assert "helm-lint" in r[4]["name"] - assert "helm-template" in r[5]["name"] + assert "check-chart-name" in r[2]["name"] + assert "helm-docs" in r[3]["name"] + assert "helm-dependency-update" in r[4]["name"] + assert "helm-lint" in r[5]["name"] + assert "helm-template" in r[6]["name"] assert "github-set-success-status" in ht["pipeline"][review]["spec"]["finally"][0]["name"] assert "github-set-failure-status" in ht["pipeline"][review]["spec"]["finally"][1]["name"] bdef = ht["pipeline"][build_def]["spec"]["tasks"] assert "fetch-repository" in bdef[0]["name"] assert "init-values" in bdef[1]["name"] - assert "get-version" in bdef[2]["name"] - assert "helm-dependency-update" in bdef[3]["name"] - assert "helm-lint" in bdef[4]["name"] - assert "helm-template" in bdef[5]["name"] - assert "helm-push" in bdef[6]["name"] - assert "git-tag" in bdef[7]["name"] - assert "update-cbis" in bdef[8]["name"] + assert "check-chart-name" in bdef[2]["name"] + assert "get-version" in bdef[3]["name"] + assert "helm-dependency-update" in bdef[4]["name"] + assert "helm-lint" in bdef[5]["name"] + assert "helm-template" in bdef[6]["name"] + assert "helm-push" in bdef[7]["name"] + assert "git-tag" in bdef[8]["name"] + assert "update-cbis" in bdef[9]["name"] assert "push-to-jira" in ht["pipeline"][build_def]["spec"]["finally"][0]["name"] bedp = ht["pipeline"][build_edp]["spec"]["tasks"] assert "fetch-repository" in bedp[0]["name"] assert "init-values" in bedp[1]["name"] - assert "get-version" in bedp[2]["name"] - assert "update-build-number" in bedp[3]["name"] - assert "helm-dependency-update" in bedp[4]["name"] - assert "helm-lint" in bedp[5]["name"] - assert "helm-template" in bedp[6]["name"] - assert "helm-push" in bedp[7]["name"] - assert "git-tag" in bedp[8]["name"] - assert "update-cbis" in bedp[9]["name"] + assert "check-chart-name" in bedp[2]["name"] + assert "get-version" in bedp[3]["name"] + assert "update-build-number" in bedp[4]["name"] + assert "helm-dependency-update" in bedp[5]["name"] + assert "helm-lint" in bedp[6]["name"] + assert "helm-template" in bedp[7]["name"] + assert "helm-push" in bedp[8]["name"] + assert "git-tag" in bedp[9]["name"] + assert "update-cbis" in bedp[10]["name"] assert "update-cbb" in ht["pipeline"][build_edp]["spec"]["finally"][0]["name"] assert "push-to-jira" in ht["pipeline"][build_edp]["spec"]["finally"][1]["name"]