From 2dfbe6e93877a5c37fa6402669d3fbaf51a30a3a Mon Sep 17 00:00:00 2001 From: Joakim Bygdell Date: Tue, 22 Aug 2023 12:20:48 +0200 Subject: [PATCH] Move chart tests into `PR container build` actiion --- .../scripts/charts/deploy_charts.sh | 17 ++-- .github/workflows/build_pr_container.yaml | 57 ++++++++++- .github/workflows/chart_test.yml | 95 ------------------- 3 files changed, 67 insertions(+), 102 deletions(-) delete mode 100644 .github/workflows/chart_test.yml diff --git a/.github/integration/scripts/charts/deploy_charts.sh b/.github/integration/scripts/charts/deploy_charts.sh index 7e999dffc..f3813b3a2 100644 --- a/.github/integration/scripts/charts/deploy_charts.sh +++ b/.github/integration/scripts/charts/deploy_charts.sh @@ -1,11 +1,16 @@ #!/bin/bash set -ex +if [ -z "$s" ];then + echo "PR number missing" + exit 1 +fi + if [ "$1" == "sda-db" ]; then ROOTPASS=$(yq e '.global.db.password' .github/integration/scripts/charts/values.yaml) helm install postgres charts/sda-db \ - --set image.tag=test-postgres \ - --set image.pullPolicy=Never \ + --set image.tag="PR$2-postgres" \ + --set image.pullPolicy=IfNotPresent \ --set global.postgresAdminPassword="$ROOTPASS" \ --set global.tls.enabled=false \ --set persistence.enabled=false \ @@ -16,8 +21,8 @@ fi if [ "$1" == "sda-mq" ]; then ADMINPASS=$(yq e '.global.broker.password' .github/integration/scripts/charts/values.yaml) helm install broker charts/sda-mq \ - --set image.tag=test-rabbitmq \ - --set image.pullPolicy=Never \ + --set image.tag="PR$2-rabbitmq" \ + --set image.pullPolicy=IfNotPresent \ --set global.adminPassword="$ADMINPASS" \ --set global.adminUser=admin \ --set global.tls.enabled=false \ @@ -28,8 +33,8 @@ fi if [ "$1" == "sda-svc" ]; then helm install pipeline charts/sda-svc \ - --set image.tag=test \ - --set image.pullPolicy=Never \ + --set image.tag="PR$2" \ + --set image.pullPolicy=IfNotPresent \ -f .github/integration/scripts/charts/values.yaml \ --wait fi diff --git a/.github/workflows/build_pr_container.yaml b/.github/workflows/build_pr_container.yaml index 9be96eb9d..f1e565f0f 100644 --- a/.github/workflows/build_pr_container.yaml +++ b/.github/workflows/build_pr_container.yaml @@ -236,4 +236,59 @@ jobs: uses: actions/checkout@v3 - name: Test sensitive-data-archive - run: docker compose -f .github/integration/sda-integration.yml run integration_test \ No newline at end of file + run: docker compose -f .github/integration/sda-integration.yml run integration_test + + chart: + needs: + - build_go_images + - build_server_images + - build_java_images + runs-on: ubuntu-latest + strategy: + matrix: + version: ["1.26", "1.27"] + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Helm + uses: azure/setup-helm@v3.5 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Initialise k3d + run: bash .github/integration/scripts/charts/k3d.sh ${{matrix.version}} + shell: bash + + - name: debug + if: failure() + run: k3d version list k3s | grep ${{matrix.version}} + shell: bash + + - name: Deploy external services + run: bash .github/integration/scripts/charts/dependencies.sh + shell: bash + + - name: Deploy DB + run: bash .github/integration/scripts/charts/deploy_charts.sh sda-db ${{ github.event.number }} + + - name: Deploy MQ + run: bash .github/integration/scripts/charts/deploy_charts.sh sda-mq ${{ github.event.number }} + shell: bash + + - name: Deploy pipeline + run: bash .github/integration/scripts/charts/deploy_charts.sh sda-svc ${{ github.event.number }} + shell: bash + + - name: test + if: always() + run: | + kubectl get secret broker-sda-mq -o json + kubectl get secret pipeline-sda-svc-mapper -o json + kubectl get pods + echo "describe mapper" && kubectl describe pod -l role=mapper + sleep 1 + echo "logs mapper" && kubectl logs -l role=mapper + sleep 1 + echo "describe broker" && kubectl logs -l role=broker + shell: bash \ No newline at end of file diff --git a/.github/workflows/chart_test.yml b/.github/workflows/chart_test.yml deleted file mode 100644 index 241fee3d4..000000000 --- a/.github/workflows/chart_test.yml +++ /dev/null @@ -1,95 +0,0 @@ -name: Chart deployment test - -on: - pull_request: - paths: - - "charts/**" - -env: - DOCKER_BUILDKIT: 1 - -jobs: - deploy: - name: deployment test - runs-on: ubuntu-latest - strategy: - matrix: - version: ["1.26", "1.27"] - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install Helm - uses: azure/setup-helm@v3.5 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Initialise k3d - run: bash .github/integration/scripts/charts/k3d.sh ${{matrix.version}} - shell: bash - - - name: debug - if: failure() - run: k3d version list k3s | grep ${{matrix.version}} - shell: bash - - - name: build postgres - shell: bash - run: | - cd postgresql - docker build -t ghcr.io/${{ github.repository }}:test-postgres . - - name: build rabbitmq - shell: bash - run: | - cd rabbitmq - docker build -t ghcr.io/${{ github.repository }}:test-rabbitmq . - - name: build sda - shell: bash - run: | - cd sda - docker build -t ghcr.io/${{ github.repository }}:test . - - name: build sda-auth - shell: bash - run: | - cd sda-auth - docker build -t ghcr.io/${{ github.repository }}:test-auth . - - name: build sda-download - shell: bash - run: | - cd sda-download - docker build -t ghcr.io/${{ github.repository }}:test-download . - - name: build sda-pipeline - shell: bash - run: | - cd sda-pipeline - docker build -t ghcr.io/${{ github.repository }}:test-pipeline . - - name: Import images to cluster - run: k3d image import ghcr.io/${{ github.repository }}:test-postgres ghcr.io/${{ github.repository }}:test-rabbitmq ghcr.io/${{ github.repository }}:test ghcr.io/${{ github.repository }}:test-auth ghcr.io/${{ github.repository }}:test-download ghcr.io/${{ github.repository }}:test-pipeline -c sda - - - name: Deploy external services - run: bash .github/integration/scripts/charts/dependencies.sh - shell: bash - - - name: Deploy DB - run: bash .github/integration/scripts/charts/deploy_charts.sh sda-db - - - name: Deploy MQ - run: bash .github/integration/scripts/charts/deploy_charts.sh sda-mq - shell: bash - - - name: Deploy pipeline - run: bash .github/integration/scripts/charts/deploy_charts.sh sda-svc - shell: bash - - - name: test - if: always() - run: | - kubectl get secret broker-sda-mq -o json - kubectl get secret pipeline-sda-svc-mapper -o json - kubectl get pods - echo "describe mapper" && kubectl describe pod -l role=mapper - sleep 1 - echo "logs mapper" && kubectl logs -l role=mapper - sleep 1 - echo "describe broker" && kubectl logs -l role=broker - shell: bash \ No newline at end of file