Skip to content

Commit

Permalink
feat: Add quality gate for chart name alignment with codebase name(#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksandr_taruraiev committed May 15, 2024
1 parent 3fd3120 commit 93f593b
Show file tree
Hide file tree
Showing 11 changed files with 238 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit 93f593b

Please sign in to comment.