From 0a57d0044a6764e9003c8c841ebe78115a2e19bb Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Tue, 23 Jan 2024 10:41:13 +0100 Subject: [PATCH] Use reusable GH wokrflow * Use for PR ugprade job * Use for main merge upgrade job --- .github/workflows/pull-e2e-upgrade-test.yaml | 96 ++------------- .github/workflows/push-e2e-upgrade-test.yaml | 99 ++++++++++++++++ .../workflows/run-upgrade-tests-reusable.yaml | 109 ++++++++++++++++++ 3 files changed, 219 insertions(+), 85 deletions(-) create mode 100644 .github/workflows/push-e2e-upgrade-test.yaml create mode 100644 .github/workflows/run-upgrade-tests-reusable.yaml diff --git a/.github/workflows/pull-e2e-upgrade-test.yaml b/.github/workflows/pull-e2e-upgrade-test.yaml index a7b1f97f..d2e7654f 100644 --- a/.github/workflows/pull-e2e-upgrade-test.yaml +++ b/.github/workflows/pull-e2e-upgrade-test.yaml @@ -1,12 +1,5 @@ name: pull-e2e-upgrade-test -env: - DOCKER_IMAGE_LATEST_MAIN: europe-docker.pkg.dev/kyma-project/prod/eventing-manager:latest - DOCKER_IMAGE_PR: europe-docker.pkg.dev/kyma-project/dev/eventing-manager:PR-${{ github.event.number }} - E2E_LOG_LEVEL: debug - KYMA_STABILITY: "unstable" - KYMA: "./hack/kyma" - on: pull_request: branches: [ "main" ] @@ -16,81 +9,14 @@ on: - 'sec-scanners-config.yaml' jobs: - e2e-upgrade: # This job tests the upgrade of Eventing module from latest image of the main branch to the current commit. - runs-on: ubuntu-latest - env: - BACKEND_TYPE: NATS - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install k3d tools - run: | - make -C hack/ci/ install-k3d-tools - - - name: Install Kyma CLI & setup k3d cluster using kyma CLI - run: | - make kyma - make -C hack/ci/ create-k3d - kubectl version - kubectl cluster-info - - - name: Create kyma-system namespace - run: | - make -C hack/ci/ create-kyma-system-ns - - - name: Install the latest released NATS manager - run: | - kubectl apply -f https://github.com/kyma-project/nats-manager/releases/latest/download/nats-manager.yaml - kubectl apply -f https://github.com/kyma-project/nats-manager/releases/latest/download/nats-default-cr.yaml - - - name: Wait for NATS module to be ready - run: | - while [[ $(kubectl get -n kyma-system nats eventing-nats -o jsonpath='{.status.state}') != "Ready" ]]; do - echo "waiting for NATS module to be ready" - sleep 3 - done - echo "NATS module is ready!" - - - name: Install latest Eventing manager from main branch - run: | - make deploy IMG=${DOCKER_IMAGE_LATEST_MAIN} - - - name: Setup & test Eventing CR - run: | - export MANAGER_IMAGE=${DOCKER_IMAGE_LATEST_MAIN} - make e2e-setup - - - name: Wait for the 'pull-eventing-manager-build' job to succeed - uses: kyma-project/wait-for-commit-status-action@2b3ffe09af8b6f40e1213d5fb7f91a7bd41ffb20 - with: - context: "pull-eventing-manager-build" - commit_ref: "${{ github.event.pull_request.head.sha }}" # Note: 'github.event.pull_request.head.sha' is not same as 'github.sha' on pull requests. - timeout: 600000 # 10 minutes in milliseconds - # The check interval is kept long otherwise it will exhaust the GitHub rate limit (More info: https://docs.github.com/en/rest/overview/resources-in-the-rest-api?apiVersion=2022-11-28#rate-limiting) - check_interval: 60000 # 1 minute in milliseconds - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - GITHUB_OWNER: "${{ github.repository_owner }}" - GITHUB_REPO: "eventing-manager" - - - name: Install the new Eventing manager from current commit - run: | - make deploy IMG=${DOCKER_IMAGE_PR} - - - name: Wait for new changes to be reflected and create test resources - # Waits for eventing-manager image to be updated and Eventing CR readiness. - # Creates Subscription CRs for testing too. - run: | - export MANAGER_IMAGE=${DOCKER_IMAGE_PR} - make e2e-setup - make e2e-eventing-setup - - - name: Run e2e tests - run: | - make e2e-eventing - - - name: Cleanup Test Resources - run: | - make e2e-eventing-cleanup - make e2e-cleanup + call-run-upgrade-tests-reusable: + uses: ./.github/workflows/run-upgrade-tests-reusable.yaml + with: + pre-upgrade-image: europe-docker.pkg.dev/kyma-project/prod/eventing-manager:main + post-upgrade-image: europe-docker.pkg.dev/kyma-project/dev/eventing-manager:PR-${{ github.event.number }} + pre-upgrade-branch: main + # set current branch name as post-upgrade-branch + post-upgrade-branch: ${{ github.head_ref }} + build-job-name: pull-eventing-manager-build + commit-sha: ${{ github.event.pull_request.head.sha }} + secrets: inherit diff --git a/.github/workflows/push-e2e-upgrade-test.yaml b/.github/workflows/push-e2e-upgrade-test.yaml new file mode 100644 index 00000000..e09485a8 --- /dev/null +++ b/.github/workflows/push-e2e-upgrade-test.yaml @@ -0,0 +1,99 @@ +name: post-e2e-upgrade-test + +env: + DOCKER_IMAGE: "europe-docker.pkg.dev/kyma-project/prod/eventing-manager" + DOCKER_IMAGE_LATEST_RELEASE: europe-docker.pkg.dev/kyma-project/dev/eventing-manager:1.0.3 + E2E_LOG_LEVEL: debug + KYMA_STABILITY: "unstable" + KYMA: "./hack/kyma" + +on: + push: + branches: [ "main" ] + paths-ignore: + - 'docs/**' + - '**.md' + - 'sec-scanners-config.yaml' + +jobs: + e2e-upgrade: # This job tests the upgrade of Eventing module from latest image of the main branch to the current commit. + runs-on: ubuntu-latest + env: + BACKEND_TYPE: NATS + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install k3d tools + run: | + make -C hack/ci/ install-k3d-tools + + - name: Install Kyma CLI & setup k3d cluster using kyma CLI + run: | + make kyma + make -C hack/ci/ create-k3d + kubectl version + kubectl cluster-info + + - name: Create kyma-system namespace + run: | + make -C hack/ci/ create-kyma-system-ns + + - name: Install the latest released NATS manager + run: | + kubectl apply -f https://github.com/kyma-project/nats-manager/releases/latest/download/nats-manager.yaml + kubectl apply -f https://github.com/kyma-project/nats-manager/releases/latest/download/nats-default-cr.yaml + + - name: Wait for NATS module to be ready + run: | + while [[ $(kubectl get -n kyma-system nats eventing-nats -o jsonpath='{.status.state}') != "Ready" ]]; do + echo "waiting for NATS module to be ready" + sleep 3 + done + echo "NATS module is ready!" + + - name: Install the latest released Eventing manager + run: | + kubectl apply -f https://github.com/kyma-project/eventing-manager/releases/latest/download/eventing-manager.yaml + + - name: Setup & test Eventing CR + run: | + export MANAGER_IMAGE=${DOCKER_IMAGE_LATEST_RELEASE} + make e2e-setup + + - name: Wait for the 'post-eventing-manager-build' job to succeed + uses: kyma-project/wait-for-commit-status-action@2b3ffe09af8b6f40e1213d5fb7f91a7bd41ffb20 + with: + context: "post-eventing-manager-build" + commit_ref: "${{ github.sha }}" + timeout: 600000 # 10 minutes in milliseconds + # The check interval is kept long otherwise it will exhaust the GitHub rate limit (More info: https://docs.github.com/en/rest/overview/resources-in-the-rest-api?apiVersion=2022-11-28#rate-limiting) + check_interval: 60000 # 1 minute in milliseconds + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + GITHUB_OWNER: "${{ github.repository_owner }}" + GITHUB_REPO: "eventing-manager" + + - name: Install the new Eventing manager from current commit + run: | + export DOCKER_TAG="$(date +v%Y%m%d)-$(echo ${COMMIT_SHA} | head -c 8)" + export MANAGER_IMAGE="${DOCKER_IMAGE}:${DOCKER_TAG}" + make deploy IMG="${DOCKER_IMAGE}:${DOCKER_TAG}" + + - name: Wait for new changes to be reflected and create test resources + # Waits for eventing-manager image to be updated and Eventing CR readiness. + # Creates Subscription CRs for testing too. + run: | + export DOCKER_TAG="$(date +v%Y%m%d)-$(echo ${COMMIT_SHA} | head -c 8)" + export MANAGER_IMAGE="${DOCKER_IMAGE}:${DOCKER_TAG}" + make e2e-setup + make e2e-eventing-setup + + - name: Run e2e tests + run: | + make e2e-eventing + + - name: Cleanup Test Resources + run: | + make e2e-eventing-cleanup + make e2e-cleanup diff --git a/.github/workflows/run-upgrade-tests-reusable.yaml b/.github/workflows/run-upgrade-tests-reusable.yaml new file mode 100644 index 00000000..c9425f73 --- /dev/null +++ b/.github/workflows/run-upgrade-tests-reusable.yaml @@ -0,0 +1,109 @@ +name: Upgrade Tests Reusable Workflow + +env: + E2E_LOG_LEVEL: debug + KYMA_STABILITY: "unstable" + KYMA: "./hack/kyma" + +on: + workflow_call: + inputs: + pre-upgrade-image: + required: true + type: string + post-upgrade-image: + required: true + type: string + pre-upgrade-branch: + required: true + type: string + post-upgrade-branch: + required: true + type: string + build-job-name: + required: true + type: string + commit-sha: + required: true + type: string + +jobs: + e2e-upgrade: # This job tests the upgrade of Eventing module from latest image of the main branch to the current commit. + runs-on: ubuntu-latest + env: + BACKEND_TYPE: NATS + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ inputs.pre-upgrade-branch }} + + - name: Install k3d tools + run: imagemake -C hack/ci/ install-k3d-tools + + - name: Install Kyma CLI & setup k3d cluster using kyma CLI + run: | + make kyma + make -C hack/ci/ create-k3d + kubectl version + kubectl cluster-info + + - name: Create kyma-system namespace + run: | + make -C hack/ci/ create-kyma-system-ns + + - name: Install the latest released NATS manager + run: | + kubectl apply -f https://github.com/kyma-project/nats-manager/releases/latest/download/nats-manager.yaml + kubectl apply -f https://github.com/kyma-project/nats-manager/releases/latest/download/nats-default-cr.yaml + + - name: Wait for NATS module to be ready + run: | + make -C hack/ci/ wait-nats-cr-ready + + - name: Install Eventing Manager before Upgrade + run: | + make deploy IMG=${{ inputs.pre-upgrade-image }} + + - name: Create test resources and waits for eventing CR readiness + run: | + export MANAGER_IMAGE=${{ inputs.pre-upgrade-image }} + make e2e-setup + make e2e-eventing-setup + + - name: Wait for the ${{ inputs.build-job-name }} job to succeed + uses: kyma-project/wait-for-commit-status-action@2b3ffe09af8b6f40e1213d5fb7f91a7bd41ffb20 + with: + context: ${{ inputs.build-job-name }} + commit_ref: "${{ github.event.pull_request.head.sha }}" # Note: 'github.event.pull_request.head.sha' is not same as 'github.sha' on pull requests. + timeout: 600000 # 10 minutes in milliseconds + # The check interval is kept long otherwise it will exhaust the GitHub rate limit (More info: https://docs.github.com/en/rest/overview/resources-in-the-rest-api?apiVersion=2022-11-28#rate-limiting) + check_interval: 60000 # 1 minute in milliseconds + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + GITHUB_OWNER: "${{ github.repository_owner }}" + GITHUB_REPO: "eventing-manager" + + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.post-upgrade-branch }} + + - name: Install Eventing manager after Upgrade + run: | + make deploy IMG=${{ inputs.post-upgrade-image }} + + - name: Create test resources and waits for eventing CR readiness + run: | + export MANAGER_IMAGE=${{ inputs.post-upgrade-image }} + make e2e-setup + + - name: Run e2e tests + run: | + make e2e-eventing + + - name: Cleanup Test Resources + run: | + make e2e-eventing-cleanup + make e2e-cleanup +