From 45b83f5b49639e25513c3813d2321acc19dac13b Mon Sep 17 00:00:00 2001 From: Matt Pryor Date: Mon, 19 Jun 2023 13:36:46 +0100 Subject: [PATCH] Add tasks to test upgrade from latest tag --- .github/actions/upgrade-and-test/action.yml | 23 ++++- .github/workflows/test.yaml | 94 ++++++++++++--------- 2 files changed, 78 insertions(+), 39 deletions(-) diff --git a/.github/actions/upgrade-and-test/action.yml b/.github/actions/upgrade-and-test/action.yml index d25e3f0..ce5be0c 100644 --- a/.github/actions/upgrade-and-test/action.yml +++ b/.github/actions/upgrade-and-test/action.yml @@ -16,6 +16,12 @@ inputs: description: The name of the cloud within the OpenStack clouds file required: true default: openstack + chart-version: + description: >- + Use the specified chart version from the repo if given. If not, + use the chart from the directory in the current checkout. + required: true + default: "" values-common-path: description: The path to a file containing common values required: true @@ -38,7 +44,7 @@ inputs: runs: using: "composite" steps: - - name: Install or upgrade cluster + - name: Install or upgrade cluster from directory shell: bash run: |- helm upgrade ${{ inputs.name }} ./charts/openstack-cluster \ @@ -49,6 +55,21 @@ runs: --set cloudName=${{ inputs.os-cloud }} \ --set kubernetesVersion=${{ inputs.kubernetes-version }} \ --set machineImageId=${{ inputs.image-id }} + if: "${{ inputs.chart-version == '' }}" + + - name: Install or upgrade cluster from repository + shell: bash + run: |- + helm upgrade ${{ inputs.name }} openstack-cluster \ + --repo https://stackhpc.github.io/capi-helm-charts \ + --version ${{ inputs.chart-version }} \ + --install \ + --values ${{ inputs.os-client-config-file }} \ + --values ${{ inputs.values-common-path }} \ + --set cloudName=${{ inputs.os-cloud }} \ + --set kubernetesVersion=${{ inputs.kubernetes-version }} \ + --set machineImageId=${{ inputs.image-id }} + if: "${{ inputs.chart-version != '' }}" # Wait for the upgrade to start before checking if it is complete # This is to make sure the controller has actioned the update before diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 3f595b8..921486d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -19,17 +19,6 @@ jobs: test-chart: runs-on: ubuntu-latest steps: - - name: Get latest tag - id: latest-tag - run: | - set -eo pipefail - TAG_NAME="$(curl -fsSL "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/latest" | jq -r '.tag_name')" - echo "tag-name=${TAG_NAME}" >> "$GITHUB_OUTPUT" - - - run: echo "${{ steps.latest-tag.outputs.tag-name }}" - - - run: "false" - - name: Checkout uses: actions/checkout@v3 @@ -192,41 +181,70 @@ jobs: # This will run a sonobuoy smoke test after every step with a full test at the end ##### - - name: Deploy Kubernetes 1.25 for Kubernetes upgrade test - uses: ./.github/actions/upgrade-and-test - with: - name: ci-${{ github.run_id }}-kube-upgrade - kubernetes-version: ${{ fromJson(inputs.images).kube-1-25-version }} - image-id: ${{ fromJson(inputs.images).kube-1-25-image }} - if: ${{ !github.event.pull_request.draft }} + # - name: Deploy Kubernetes 1.25 for Kubernetes upgrade test + # uses: ./.github/actions/upgrade-and-test + # with: + # name: ci-${{ github.run_id }}-kube-upgrade + # kubernetes-version: ${{ fromJson(inputs.images).kube-1-25-version }} + # image-id: ${{ fromJson(inputs.images).kube-1-25-image }} + # if: ${{ !github.event.pull_request.draft }} - - name: Upgrade to Kubernetes 1.26 - uses: ./.github/actions/upgrade-and-test - with: - name: ci-${{ github.run_id }}-kube-upgrade - kubernetes-version: ${{ fromJson(inputs.images).kube-1-26-version }} - image-id: ${{ fromJson(inputs.images).kube-1-26-image }} - if: ${{ !github.event.pull_request.draft }} + # - name: Upgrade to Kubernetes 1.26 + # uses: ./.github/actions/upgrade-and-test + # with: + # name: ci-${{ github.run_id }}-kube-upgrade + # kubernetes-version: ${{ fromJson(inputs.images).kube-1-26-version }} + # image-id: ${{ fromJson(inputs.images).kube-1-26-image }} + # if: ${{ !github.event.pull_request.draft }} - - name: Upgrade to Kubernetes 1.27 - uses: ./.github/actions/upgrade-and-test - with: - name: ci-${{ github.run_id }}-kube-upgrade - kubernetes-version: ${{ fromJson(inputs.images).kube-1-27-version }} - image-id: ${{ fromJson(inputs.images).kube-1-27-image }} - sonobuoy-mode: full - sonobuoy-upload: "yes" - if: ${{ !github.event.pull_request.draft }} + # - name: Upgrade to Kubernetes 1.27 + # uses: ./.github/actions/upgrade-and-test + # with: + # name: ci-${{ github.run_id }}-kube-upgrade + # kubernetes-version: ${{ fromJson(inputs.images).kube-1-27-version }} + # image-id: ${{ fromJson(inputs.images).kube-1-27-image }} + # sonobuoy-mode: full + # sonobuoy-upload: "yes" + # if: ${{ !github.event.pull_request.draft }} - - name: Delete upgrade deployment - run: helm delete ci-${{ github.run_id }}-kube-upgrade --wait - if: ${{ !github.event.pull_request.draft && always() }} + # - name: Delete Kubernetes upgrade deployment + # run: helm delete ci-${{ github.run_id }}-kube-upgrade --wait + # if: ${{ !github.event.pull_request.draft && always() }} ##### # On a reviewable PR, we also test that we can upgrade from a cluster deployed # using the latest tag ##### - + + - name: Get latest tag + id: latest-tag + run: | + set -eo pipefail + TAG_NAME="$(curl -fsSL "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/latest" | jq -r '.tag_name')" + echo "tag-name=${TAG_NAME}" >> "$GITHUB_OUTPUT" + if: ${{ !github.event.pull_request.draft }} + + - name: Deploy Kubernetes 1.27 with latest tag for chart upgrade test + uses: ./.github/actions/upgrade-and-test + with: + name: ci-${{ github.run_id }}-chart-upgrade + kubernetes-version: ${{ fromJson(inputs.images).kube-1-27-version }} + image-id: ${{ fromJson(inputs.images).kube-1-27-image }} + chart-version: ${{ steps.latest-tag.outputs.tag-name }} + if: ${{ !github.event.pull_request.draft }} + + - name: Upgrade to current chart + uses: ./.github/actions/upgrade-and-test + with: + name: ci-${{ github.run_id }}-chart-upgrade + kubernetes-version: ${{ fromJson(inputs.images).kube-1-27-version }} + image-id: ${{ fromJson(inputs.images).kube-1-27-image }} + if: ${{ !github.event.pull_request.draft }} + + - name: Delete chart upgrade deployment + run: helm delete ci-${{ github.run_id }}-chart-upgrade --wait + if: ${{ !github.event.pull_request.draft && always() }} + - name: Output controller logs if: ${{ always() }} run: |