Skip to content

Commit

Permalink
SONAR-23677 Uses script to build dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
davividal authored Nov 19, 2024
1 parent 1dce6a6 commit e510db5
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 33 deletions.
28 changes: 8 additions & 20 deletions .cirrus/tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ build_gcp_app_template: &BUILD_GCP_APP_TEMPLATE
- chmod 700 get_helm.sh
- ./get_helm.sh
helm_dependency_build_script:
- cd charts/sonarqube-dce
- helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
- helm repo add bitnami-pre2022 https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami
- helm dependency build
- ./.cirrus/build_chart_dependencies.sh charts/sonarqube-dce
tag_and_promote_script:
- export CURRENT_MINOR_VERSION=$(echo ${GCLOUD_TAG} | cut -d '.' -f 1,2)
- docker build -f google-cloud-marketplace-k8s-app/Dockerfile --build-arg REGISTRY=${GCLOUD_REGISTRY} --build-arg TAG=${GCLOUD_TAG} --tag ${GCLOUD_REGISTRY}/${GCLOUD_PRODUCT_NAME}/deployer:${CURRENT_MINOR_VERSION} .
Expand Down Expand Up @@ -135,14 +132,10 @@ chart_static_compatibility_test_task:
memory: 1Gb
<<: *CLONE_SCRIPT_TEMPLATE
script:
- helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
- helm repo add bitnami-pre2022 https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami
- cd ${CIRRUS_WORKING_DIR}/charts/sonarqube
- helm dependency build
- ../../.cirrus/unit_helm_compatibility_test.sh
- cd ${CIRRUS_WORKING_DIR}/charts/sonarqube-dce
- helm dependency build
- ../../.cirrus/unit_helm_compatibility_test.sh
- ./.cirrus/build_chart_dependencies.sh charts/sonarqube
- ./.cirrus/unit_helm_compatibility_test.sh sonarqube
- ./.cirrus/build_chart_dependencies.sh charts/sonarqube-dce
- ./.cirrus/unit_helm_compatibility_test.sh sonarqube-dce

chart_fixture_test_task:
<<: *ONLY_ON_NON_RELEASE_DRAFT_TEMPLATE
Expand All @@ -153,14 +146,9 @@ chart_fixture_test_task:
memory: 1Gb
<<: *CLONE_SCRIPT_TEMPLATE
script:
- helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
- helm repo add bitnami-pre2022 https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami
- cd ${CIRRUS_WORKING_DIR}/charts/sonarqube
- helm dependency build
- cd ${CIRRUS_WORKING_DIR}/charts/sonarqube-dce
- helm dependency build
- cd ../..
- .cirrus/generate_helm_fixtures.sh
- ./.cirrus/build_chart_dependencies.sh charts/sonarqube
- ./.cirrus/build_chart_dependencies.sh charts/sonarqube-dce
- ./.cirrus/generate_helm_fixtures.sh
- git diff --exit-code

chart_testing_on_kind_task:
Expand Down
39 changes: 28 additions & 11 deletions .cirrus/unit_helm_compatibility_test.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,38 @@
#!/bin/bash

set -euo pipefail

KUBE_VERSION="${KUBE_VERSION:-1.25.0}"
STATIC_TEST_FOLDER='../../tests/unit-compatibility-test/'$(basename $PWD)
PROJECT_ROOT=$(readlink -f "$(dirname "$0")"/..)
CHART_NAME="${1:-$(basename "${PWD}")}"

# NOTE: CHART_PATH is set to the first argument if it is provided,
# otherwise it is set to "." (current dir)
CHART_PATH="${1:+charts/$1}"
CHART_PATH="${CHART_PATH:-.}"

KUBE_VERSION="${KUBE_VERSION:-1.25.0}"
STATIC_TEST_FOLDER="${PROJECT_ROOT}/tests/unit-compatibility-test/${CHART_NAME}"

if ! [ -d "$STATIC_TEST_FOLDER" ]; then
echo "$STATIC_TEST_FOLDER folder not found"
if ! [[ -d "${STATIC_TEST_FOLDER}" ]]; then
echo "${STATIC_TEST_FOLDER} folder not found"
echo "you are probably not in the root of a chart"
exit 1
fi

echo 'Running unit compatibility tests for Kubernetes version' $KUBE_VERSION
echo "Running unit compatibility tests for Kubernetes version ${KUBE_VERSION}"

for file in "$STATIC_TEST_FOLDER"/*; do
TEST_CASE_NAME=$(basename "$file")
echo 'Entering test for' $TEST_CASE_NAME
helm template --kube-version $KUBE_VERSION --dry-run --debug -f "$file" $TEST_CASE_NAME . | kubeconform --kubernetes-version $KUBE_VERSION --summary --strict -schema-location default -schema-location "../../tests/test-crds/{{.ResourceKind}}.json"
echo 'Ending test for' $TEST_CASE_NAME
done
for file in "${STATIC_TEST_FOLDER}"/*; do
TEST_CASE_NAME=$(basename "${file}")
echo "Entering test for ${TEST_CASE_NAME}"
helm template \
--kube-version "${KUBE_VERSION}" \
--dry-run \
--debug \
-f "${file}" "${TEST_CASE_NAME}" "${CHART_PATH}" \
| kubeconform \
--kubernetes-version "${KUBE_VERSION}" \
--summary \
--strict -schema-location default \
-schema-location "${PROJECT_ROOT}/tests/test-crds/{{.ResourceKind}}.json"
echo "Ending test for ${TEST_CASE_NAME}"
done
5 changes: 3 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
gcloud 466.0.0
helm-ct 3.10.1
gcloud 470.0.0
helm-ct 3.10.1
kubeconform 0.6.3

0 comments on commit e510db5

Please sign in to comment.