From fd171ff3b9992fe7049f252ec602776f49d7f280 Mon Sep 17 00:00:00 2001 From: jeremy cotineau Date: Tue, 16 Jan 2024 16:54:05 +0100 Subject: [PATCH] SONAR-21408 run static test in PR --- .cirrus.yaml | 21 ++++++++++++++++++ .cirrus/Dockerfile | 12 ++++++++++- .github/workflows/static-test.yml | 36 ------------------------------- 3 files changed, 32 insertions(+), 37 deletions(-) delete mode 100644 .github/workflows/static-test.yml diff --git a/.cirrus.yaml b/.cirrus.yaml index 46646a943..8618d495f 100644 --- a/.cirrus.yaml +++ b/.cirrus.yaml @@ -43,6 +43,25 @@ clone_script_template: &CLONE_SCRIPT_TEMPLATE git reset --hard $CIRRUS_CHANGE_IN_REPO fi +chart_static_testing_task: + <<: *ONLY_ON_NON_RELEASE_DRAFT_TEMPLATE + timeout_in: 30m + eks_container: + <<: *CONTAINER_TEMPLATE + cpu: 1 + memory: 1Gb + <<: *CLONE_SCRIPT_TEMPLATE + script: + - helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx + - helm repo add bitnami https://charts.bitnami.com/bitnami + - helm repo add bitnami-pre2022 https://raw.githubusercontent.com/bitnami/charts/pre-2022/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 + chart_testing_task: <<: *ONLY_ON_NON_RELEASE_DRAFT_TEMPLATE timeout_in: 30m @@ -74,6 +93,8 @@ chart_testing_task: - ct install --config test.yaml --all artifacthub_lint_script: - ah lint + depends_on: + - chart_static_testing chart_packaging_task: <<: *ONLY_ON_NON_RELEASE_DRAFT_TEMPLATE diff --git a/.cirrus/Dockerfile b/.cirrus/Dockerfile index 266d2f35a..1b57daf3b 100644 --- a/.cirrus/Dockerfile +++ b/.cirrus/Dockerfile @@ -17,6 +17,8 @@ ARG AH_VERSION=1.16.0 ARG AH_CHECKSUM="d5955b409361922f609c261bf4b124c4d8ecd294cf85e5fee11c2ba774d45366" ARG YQ_VERSION=4.35.2 ARG YQ_CHECKSUM="8afd786b3b8ba8053409c5e7d154403e2d4ed4cf3e93c237462dc9ef75f38c8d" +ARG KUBECONFORM_VERSION=0.6.4 +ARG KUBECONFORM_CHECKSUM="2b4ebeaa4d5ac4843cf8f7b7e66a8874252b6b71bc7cbfc4ef1cbf85acec7c07" ENV HELM_BASE_URL="https://get.helm.sh" ENV HELM_TAR_FILE="helm-v${HELM_VERSION}-linux-amd64.tar.gz" @@ -92,6 +94,14 @@ RUN set -eux; \ chmod +x ./yq_linux_amd64 ; \ mv ./yq_linux_amd64 /usr/bin/yq +RUN set -eux; \ + curl -LO https://github.com/yannh/kubeconform/releases/download/v${KUBECONFORM_VERSION}/kubeconform-linux-amd64.tar.gz ; \ + echo "${KUBECONFORM_CHECKSUM} kubeconform-linux-amd64.tar.gz" | sha256sum -c ; \ + tar -xf kubeconform-linux-amd64.tar.gz ; \ + chmod +x ./kubeconform ; \ + mv ./kubeconform /usr/bin/kubeconform ; \ + rm kubeconform-linux-amd64.tar.gz + COPY --from=tools /usr/local/bin/cirrus-env /usr/local/bin/cirrus-env -COPY --from=tools /usr/bin/gh /usr/local/bin/gh +COPY --from=tools /usr/local/bin/gh /usr/local/bin/gh COPY --from=tools /home/sonarsource/.m2/settings-public.xml /root/.m2/settings-public.xml \ No newline at end of file diff --git a/.github/workflows/static-test.yml b/.github/workflows/static-test.yml deleted file mode 100644 index 32c1dd8b1..000000000 --- a/.github/workflows/static-test.yml +++ /dev/null @@ -1,36 +0,0 @@ -on: - # Trigger analysis when pushing in master or pull requests, and when creating - # a pull request. - push: - branches: - - master - pull_request: - types: [opened, synchronize, reopened] - -name: Main Workflow -jobs: - run-static-analysis-test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - # Disabling shallow clone is recommended for improving relevancy of reporting - fetch-depth: 0 - - uses: azure/setup-helm@v3 - with: - version: latest # default is latest (stable) - token: ${{ secrets.GITHUB_TOKEN }} # only needed if version is 'latest' - id: install-helm - - name: Set up Kubeconform - uses: bmuschko/setup-kubeconform@v1 - - name: run static compatibility test - run: | - helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx - helm repo add bitnami https://charts.bitnami.com/bitnami - helm repo add bitnami-pre2022 https://raw.githubusercontent.com/bitnami/charts/pre-2022/bitnami - cd ${{ github.workspace }}/charts/sonarqube - helm dependency build - ../../.cirrus/unit_helm_compatibility_test.sh - cd ${{ github.workspace }}/charts/sonarqube-dce - helm dependency build - ../../.cirrus/unit_helm_compatibility_test.sh \ No newline at end of file