From 2a831e76666e03bf6ff9e07b8195ce7574f0deaa Mon Sep 17 00:00:00 2001 From: --show-origin Date: Wed, 20 Dec 2023 09:25:22 -0800 Subject: [PATCH 01/10] ci: added helm-test chart workflow --- .github/workflows/helm-test.yml | 102 ++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 .github/workflows/helm-test.yml diff --git a/.github/workflows/helm-test.yml b/.github/workflows/helm-test.yml new file mode 100644 index 00000000..c55cdc85 --- /dev/null +++ b/.github/workflows/helm-test.yml @@ -0,0 +1,102 @@ +# +# Copyright (c) 2023 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License, Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# +name: Lint and Test Charts + +on: + pull_request: + workflow_dispatch: + inputs: + node_image: + description: 'kindest/node image for k8s kind cluster' + # latest as default as latest -2 versions need to be supported (latest 3 versions) + default: 'kindest/node:latest' + required: false + type: string + upgrade_from: + description: 'chart version to upgrade from' + # chart version from 3.1 release as default + default: 'x.x.x' + required: false + type: string + helm_version: + description: 'helm version to test (default = latest)' + default: 'latest' + required: false + type: string + +jobs: + lint-test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1 + with: + fetch-depth: 0 + + - name: Kubernetes KinD Cluster + uses: container-tools/kind-action@7075d1458484493c6a92d4604cb27b87de0f8107 #v2.2 + with: + # upgrade version, default (v0.17.0) uses node image v1.21.1 and doesn't work with more recent node image versions + version: v0.20.0 + # default value for event_name != workflow_dispatch + node_image: ${{ github.event.inputs.node_image || 'kindest/node:latest' }} + + - name: Build image + uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 #v5.1 + with: + context: . + push: true + tags: kind-registry:5000/app-dashboard:testing + + - name: Set up Helm + uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 #v3.5 + with: + version: ${{ github.event.inputs.helm_version || 'latest' }} + + - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c #v5.0.0 + with: + python-version: '3.9' + check-latest: true + - name: Set up chart-testing + uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 #v2.6.1 + + - name: Run chart-testing (list-changed) + id: list-changed + run: | + changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }}) + if [[ -n "$changed" ]]; then + echo "changed=true" >> $GITHUB_OUTPUT + fi + + - name: Run chart-testing (lint) + run: ct lint --validate-maintainers=false --target-branch ${{ github.event.repository.default_branch }} + - name: Run chart-testing (install) + run: ct install --charts charts/app-dashboard + if: github.event_name != 'pull_request' || steps.list-changed.outputs.changed == 'true' + + # Upgrade the released chart version with the locally available chart + # default value for event_name != workflow_dispatch + - name: Run helm upgrade + run: | + helm repo add bitnami https://charts.bitnami.com/bitnami + helm repo add tractusx-dev https://eclipse-tractusx.github.io/charts/dev + helm install [NAME] tractusx-dev/[CHART] --version ${{ github.event.inputs.upgrade_from || 'x.x.x' }} + helm dependency update charts/[CHART] + helm upgrade [NAME] charts/[CHART] + if: github.event_name != 'pull_request' || steps.list-changed.outputs.changed == 'true' From 660418f6e71146abd89f570a7598e2272b0bfc96 Mon Sep 17 00:00:00 2001 From: --show-origin Date: Thu, 21 Dec 2023 05:51:41 -0800 Subject: [PATCH 02/10] ci(helm-test): remove helm upgrade and set R23.12 version for kind --- .github/workflows/helm-test.yml | 35 +++++++++++++++++---------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/.github/workflows/helm-test.yml b/.github/workflows/helm-test.yml index c55cdc85..c7155ab1 100644 --- a/.github/workflows/helm-test.yml +++ b/.github/workflows/helm-test.yml @@ -24,16 +24,17 @@ on: inputs: node_image: description: 'kindest/node image for k8s kind cluster' - # latest as default as latest -2 versions need to be supported (latest 3 versions) - default: 'kindest/node:latest' - required: false - type: string - upgrade_from: - description: 'chart version to upgrade from' - # chart version from 3.1 release as default - default: 'x.x.x' + # k8s version from 3.1 release as default + default: 'kindest/node:1.27.3' required: false type: string +# First participation in QGate, outcommented -> also below +# upgrade_from: +# description: 'chart version to upgrade from' +# # chart version from 3.1 release as default +# default: 'x.x.x' +# required: false +# type: string helm_version: description: 'helm version to test (default = latest)' default: 'latest' @@ -55,7 +56,7 @@ jobs: # upgrade version, default (v0.17.0) uses node image v1.21.1 and doesn't work with more recent node image versions version: v0.20.0 # default value for event_name != workflow_dispatch - node_image: ${{ github.event.inputs.node_image || 'kindest/node:latest' }} + node_image: ${{ github.event.inputs.node_image || 'kindest/node:1.27.3' }} - name: Build image uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 #v5.1 @@ -92,11 +93,11 @@ jobs: # Upgrade the released chart version with the locally available chart # default value for event_name != workflow_dispatch - - name: Run helm upgrade - run: | - helm repo add bitnami https://charts.bitnami.com/bitnami - helm repo add tractusx-dev https://eclipse-tractusx.github.io/charts/dev - helm install [NAME] tractusx-dev/[CHART] --version ${{ github.event.inputs.upgrade_from || 'x.x.x' }} - helm dependency update charts/[CHART] - helm upgrade [NAME] charts/[CHART] - if: github.event_name != 'pull_request' || steps.list-changed.outputs.changed == 'true' +# - name: Run helm upgrade +# run: | +# helm repo add bitnami https://charts.bitnami.com/bitnami +# helm repo add tractusx-dev https://eclipse-tractusx.github.io/charts/dev +# helm install [NAME] tractusx-dev/[CHART] --version ${{ github.event.inputs.upgrade_from || 'x.x.x' }} +# helm dependency update charts/[CHART] +# helm upgrade [NAME] charts/[CHART] +# if: github.event_name != 'pull_request' || steps.list-changed.outputs.changed == 'true' From a08682272162ec2369375f765ff4f3893ea377d3 Mon Sep 17 00:00:00 2001 From: --show-origin Date: Thu, 21 Dec 2023 05:55:31 -0800 Subject: [PATCH 03/10] chore(helm-test): remove comments for helm upgrade --- .github/workflows/helm-test.yml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/.github/workflows/helm-test.yml b/.github/workflows/helm-test.yml index c7155ab1..68c81207 100644 --- a/.github/workflows/helm-test.yml +++ b/.github/workflows/helm-test.yml @@ -28,13 +28,6 @@ on: default: 'kindest/node:1.27.3' required: false type: string -# First participation in QGate, outcommented -> also below -# upgrade_from: -# description: 'chart version to upgrade from' -# # chart version from 3.1 release as default -# default: 'x.x.x' -# required: false -# type: string helm_version: description: 'helm version to test (default = latest)' default: 'latest' @@ -90,14 +83,3 @@ jobs: - name: Run chart-testing (install) run: ct install --charts charts/app-dashboard if: github.event_name != 'pull_request' || steps.list-changed.outputs.changed == 'true' - - # Upgrade the released chart version with the locally available chart - # default value for event_name != workflow_dispatch -# - name: Run helm upgrade -# run: | -# helm repo add bitnami https://charts.bitnami.com/bitnami -# helm repo add tractusx-dev https://eclipse-tractusx.github.io/charts/dev -# helm install [NAME] tractusx-dev/[CHART] --version ${{ github.event.inputs.upgrade_from || 'x.x.x' }} -# helm dependency update charts/[CHART] -# helm upgrade [NAME] charts/[CHART] -# if: github.event_name != 'pull_request' || steps.list-changed.outputs.changed == 'true' From 2c34068128f86933e10678dd6e17c020fbeb41b5 Mon Sep 17 00:00:00 2001 From: --show-origin Date: Thu, 4 Jan 2024 03:59:49 -0800 Subject: [PATCH 04/10] fix: added missing v for version --- .github/workflows/helm-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/helm-test.yml b/.github/workflows/helm-test.yml index 68c81207..e4be4c4c 100644 --- a/.github/workflows/helm-test.yml +++ b/.github/workflows/helm-test.yml @@ -25,7 +25,7 @@ on: node_image: description: 'kindest/node image for k8s kind cluster' # k8s version from 3.1 release as default - default: 'kindest/node:1.27.3' + default: 'kindest/node:v1.27.3' required: false type: string helm_version: @@ -49,7 +49,7 @@ jobs: # upgrade version, default (v0.17.0) uses node image v1.21.1 and doesn't work with more recent node image versions version: v0.20.0 # default value for event_name != workflow_dispatch - node_image: ${{ github.event.inputs.node_image || 'kindest/node:1.27.3' }} + node_image: ${{ github.event.inputs.node_image || 'kindest/node:v1.27.3' }} - name: Build image uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 #v5.1 From 9130ea1183f1507018f8c91843fbdbe25faf49ed Mon Sep 17 00:00:00 2001 From: --show-origin Date: Sun, 28 Jan 2024 08:58:02 -0800 Subject: [PATCH 05/10] ci(helm-test): added separate docker build steps --- .github/workflows/helm-test.yml | 95 +++++++++++++++++++-------------- 1 file changed, 56 insertions(+), 39 deletions(-) diff --git a/.github/workflows/helm-test.yml b/.github/workflows/helm-test.yml index e4be4c4c..a57f154f 100644 --- a/.github/workflows/helm-test.yml +++ b/.github/workflows/helm-test.yml @@ -34,52 +34,69 @@ on: required: false type: string +env: + REGISTRY: kind-registry:5000 + TAG: testing + APP_BACKEND_NAME: app-puris-backend + APP_FRONTEND_NAME: app-puris-frontend + jobs: lint-test: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1 - with: - fetch-depth: 0 + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1 + with: + fetch-depth: 0 + + - name: Kubernetes KinD Cluster + uses: container-tools/kind-action@7075d1458484493c6a92d4604cb27b87de0f8107 #v2.2 + with: + # upgrade version, default (v0.17.0) uses node image v1.21.1 and doesn't work with more recent node image versions + version: v0.20.0 + # default value for event_name != workflow_dispatch + node_image: ${{ github.event.inputs.node_image || 'kindest/node:v1.27.3' }} + + - name: Build Frontend image + uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 #v5.1 + with: + context: ./frontend/Dockerfile + push: true + tags: ${{ env.REGISTRY }}/${{ env.APP_FRONTEND_NAME }}:${{ env.TAG }} - - name: Kubernetes KinD Cluster - uses: container-tools/kind-action@7075d1458484493c6a92d4604cb27b87de0f8107 #v2.2 - with: - # upgrade version, default (v0.17.0) uses node image v1.21.1 and doesn't work with more recent node image versions - version: v0.20.0 - # default value for event_name != workflow_dispatch - node_image: ${{ github.event.inputs.node_image || 'kindest/node:v1.27.3' }} + - name: Build Backend image + uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 #v5.1 + with: + context: ./backend/Dockerfile + push: true + tags: ${{ env.REGISTRY }}/${{ env.APP_BACKEND_NAME }}:${{ env.TAG }} - - name: Build image - uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 #v5.1 - with: - context: . - push: true - tags: kind-registry:5000/app-dashboard:testing + - name: Set up Helm + uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 #v3.5 + with: + version: ${{ github.event.inputs.helm_version || 'latest' }} - - name: Set up Helm - uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 #v3.5 - with: - version: ${{ github.event.inputs.helm_version || 'latest' }} + - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c #v5.0.0 + with: + python-version: '3.9' + check-latest: true + - name: Set up chart-testing + uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 #v2.6.1 - - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c #v5.0.0 - with: - python-version: '3.9' - check-latest: true - - name: Set up chart-testing - uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 #v2.6.1 + - name: Run chart-testing (list-changed) + id: list-changed + run: | + changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }}) + if [[ -n "$changed" ]]; then + echo "changed=true" >> $GITHUB_OUTPUT + fi - - name: Run chart-testing (list-changed) - id: list-changed - run: | - changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }}) - if [[ -n "$changed" ]]; then - echo "changed=true" >> $GITHUB_OUTPUT - fi + - name: Run chart-testing (lint) + run: ct lint --validate-maintainers=false --target-branch ${{ github.event.repository.default_branch }} - - name: Run chart-testing (lint) - run: ct lint --validate-maintainers=false --target-branch ${{ github.event.repository.default_branch }} - - name: Run chart-testing (install) - run: ct install --charts charts/app-dashboard - if: github.event_name != 'pull_request' || steps.list-changed.outputs.changed == 'true' + - name: Run chart-testing (install) + run: | + helm repo add bitnami https://charts.bitnami.com/bitnami + helm dependency update + ct install --charts charts/puris --helm-extra-set-args "--set backend.image.repository=${{ env.REGISTRY }}/${{ env.APP_BACKEND_NAME}} --set backend.image.tag=${{ env.TAG }} --set frontend.image.repository=${{ env.REGISTRY }}/${{ env.APP_FRONTEND_NAME }} --set frontend.image.tag=${{ env.TAG }}" + if: github.event_name != 'pull_request' || steps.list-changed.outputs.changed == 'true' From a12a518a9b6e6ec205e6766828b7be21acbd66b5 Mon Sep 17 00:00:00 2001 From: --show-origin Date: Sun, 28 Jan 2024 09:00:36 -0800 Subject: [PATCH 06/10] fix(helm-test): separate context and file in docker build --- .github/workflows/helm-test.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/helm-test.yml b/.github/workflows/helm-test.yml index a57f154f..cf0bfa10 100644 --- a/.github/workflows/helm-test.yml +++ b/.github/workflows/helm-test.yml @@ -60,14 +60,16 @@ jobs: - name: Build Frontend image uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 #v5.1 with: - context: ./frontend/Dockerfile + context: . + file: /frontend/Dockerfile push: true tags: ${{ env.REGISTRY }}/${{ env.APP_FRONTEND_NAME }}:${{ env.TAG }} - name: Build Backend image uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 #v5.1 with: - context: ./backend/Dockerfile + context: . + file: /backend/Dockerfile push: true tags: ${{ env.REGISTRY }}/${{ env.APP_BACKEND_NAME }}:${{ env.TAG }} From 62d39bac9692c93b2f5c29072ca3ad262e7d8beb Mon Sep 17 00:00:00 2001 From: --show-origin Date: Sun, 28 Jan 2024 09:02:41 -0800 Subject: [PATCH 07/10] fix(helm-test): make file a relative path in docker build --- .github/workflows/helm-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/helm-test.yml b/.github/workflows/helm-test.yml index cf0bfa10..eb2f292d 100644 --- a/.github/workflows/helm-test.yml +++ b/.github/workflows/helm-test.yml @@ -61,7 +61,7 @@ jobs: uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 #v5.1 with: context: . - file: /frontend/Dockerfile + file: ./frontend/Dockerfile push: true tags: ${{ env.REGISTRY }}/${{ env.APP_FRONTEND_NAME }}:${{ env.TAG }} @@ -69,7 +69,7 @@ jobs: uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 #v5.1 with: context: . - file: /backend/Dockerfile + file: ./backend/Dockerfile push: true tags: ${{ env.REGISTRY }}/${{ env.APP_BACKEND_NAME }}:${{ env.TAG }} From c11bb8ddb896ff04f811a4ad71287de57153dc8c Mon Sep 17 00:00:00 2001 From: --show-origin Date: Sun, 28 Jan 2024 09:06:30 -0800 Subject: [PATCH 08/10] fix(helm-test): set context to frontend and backend folder in docker build --- .github/workflows/helm-test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/helm-test.yml b/.github/workflows/helm-test.yml index eb2f292d..8b8ea15a 100644 --- a/.github/workflows/helm-test.yml +++ b/.github/workflows/helm-test.yml @@ -60,16 +60,16 @@ jobs: - name: Build Frontend image uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 #v5.1 with: - context: . - file: ./frontend/Dockerfile + context: ./frontend + file: ./Dockerfile push: true tags: ${{ env.REGISTRY }}/${{ env.APP_FRONTEND_NAME }}:${{ env.TAG }} - name: Build Backend image uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 #v5.1 with: - context: . - file: ./backend/Dockerfile + context: ./backend + file: ./Dockerfile push: true tags: ${{ env.REGISTRY }}/${{ env.APP_BACKEND_NAME }}:${{ env.TAG }} From c7b5fe4ee401d1b8a4d81845de331089289cbe83 Mon Sep 17 00:00:00 2001 From: --show-origin Date: Sun, 28 Jan 2024 09:21:37 -0800 Subject: [PATCH 09/10] fix(helm-test): update file and frontend dockerfile paths --- .github/workflows/helm-test.yml | 9 +++++---- frontend/Dockerfile | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/helm-test.yml b/.github/workflows/helm-test.yml index 8b8ea15a..5b2aa9c0 100644 --- a/.github/workflows/helm-test.yml +++ b/.github/workflows/helm-test.yml @@ -60,16 +60,16 @@ jobs: - name: Build Frontend image uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 #v5.1 with: - context: ./frontend - file: ./Dockerfile + context: . + file: ./frontend/Dockerfile push: true tags: ${{ env.REGISTRY }}/${{ env.APP_FRONTEND_NAME }}:${{ env.TAG }} - name: Build Backend image uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 #v5.1 with: - context: ./backend - file: ./Dockerfile + context: . + file: ./backend/Dockerfile push: true tags: ${{ env.REGISTRY }}/${{ env.APP_BACKEND_NAME }}:${{ env.TAG }} @@ -82,6 +82,7 @@ jobs: with: python-version: '3.9' check-latest: true + - name: Set up chart-testing uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 #v2.6.1 diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 823dcd57..65871bdf 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -56,7 +56,7 @@ ENV JSFOLDER=/usr/share/nginx/html/assets/*.js # use root user to install moreutils for sponge in start-nginx to substring env workaround USER root -COPY ./start-nginx.sh /usr/bin/start-nginx.sh +COPY start-nginx.sh /usr/bin/start-nginx.sh RUN apk --no-cache add moreutils # use non-root user From 697e36a3f26c58fcaa2abcce63b67ded833b2052 Mon Sep 17 00:00:00 2001 From: --show-origin Date: Wed, 31 Jan 2024 06:56:01 -0800 Subject: [PATCH 10/10] ci(helm-test): build docker same as in docker workflows --- .github/workflows/helm-test.yml | 4 ++-- frontend/Dockerfile | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/helm-test.yml b/.github/workflows/helm-test.yml index 5b2aa9c0..ef9a4786 100644 --- a/.github/workflows/helm-test.yml +++ b/.github/workflows/helm-test.yml @@ -60,7 +60,7 @@ jobs: - name: Build Frontend image uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 #v5.1 with: - context: . + context: ./frontend file: ./frontend/Dockerfile push: true tags: ${{ env.REGISTRY }}/${{ env.APP_FRONTEND_NAME }}:${{ env.TAG }} @@ -68,7 +68,7 @@ jobs: - name: Build Backend image uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 #v5.1 with: - context: . + context: ./backend file: ./backend/Dockerfile push: true tags: ${{ env.REGISTRY }}/${{ env.APP_BACKEND_NAME }}:${{ env.TAG }} diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 65871bdf..823dcd57 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -56,7 +56,7 @@ ENV JSFOLDER=/usr/share/nginx/html/assets/*.js # use root user to install moreutils for sponge in start-nginx to substring env workaround USER root -COPY start-nginx.sh /usr/bin/start-nginx.sh +COPY ./start-nginx.sh /usr/bin/start-nginx.sh RUN apk --no-cache add moreutils # use non-root user