Skip to content

Commit

Permalink
Create Upgrade jobs for PR and main merge (#401)
Browse files Browse the repository at this point in the history
* Create e2e test upgrade job

* Job tests upgrade from main branch to the current PR version

* Use different MANAGER images for PR and main branch tests

* Use reusable GH wokrflow

* Use for PR ugprade job
* Use for main merge upgrade job

* Use resulable wokflow for release push job

Upgrade test from the latest to release to main commit uses reusable workflow

* Test push job with push event

* Debug Get release tag job

* Use current PR branch

* Use curl directly

* Improve reusable workflow

* Use only docker tags
* Identify dev repo with PR tag
* Set default values to branches

* Use image if branch name is not set

* Don't checkout PR branh as it is already done

* Use image tag as branches

* Rename reusable job and reconfigure push job

* Improve review comments

* Rename reusable workflow file name
  • Loading branch information
muralov authored Jan 31, 2024
1 parent 10ccfd6 commit 74cb2a1
Show file tree
Hide file tree
Showing 4 changed files with 178 additions and 0 deletions.
110 changes: 110 additions & 0 deletions .github/workflows/e2e-upgrade-test-reusable.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Upgrade Tests Workflow (reusable)

env:
E2E_LOG_LEVEL: debug
KYMA_STABILITY: "unstable"
KYMA: "./hack/kyma"

on:
workflow_call:
inputs:
# image tag before upgrade
pre-upgrade-image-tag:
required: true
type: string
# image tag after upgrade
post-upgrade-image-tag:
required: true
type: string
# job name of the prow build job
build-job-name:
type: string
# commit sha of the PR or main branch commit
build-job-commit-sha:
type: string

jobs:
e2e-upgrade: # This job tests the upgrade of Eventing module from the 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: Pre-upgrade checkout
run: git checkout -b ${{ inputs.pre-upgrade-image-tag }}

- 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: |
make -C hack/ci/ wait-nats-cr-ready
- name: Install Eventing manager before upgrade
run: |
pre_upgrade_image=$(./hack/ci/build-full-image-path.sh ${{ inputs.pre-upgrade-image-tag }})
echo "Pre-upgrade image: $pre_upgrade_image"
make deploy IMG=$pre_upgrade_image
- name: Create test resources and wait for eventing CR readiness
run: |
export MANAGER_IMAGE=$(./hack/ci/build-full-image-path.sh ${{ inputs.pre-upgrade-image-tag }})
make e2e-setup
make e2e-eventing-setup
- name: Wait for the ${{ inputs.build-job-name }} job to succeed
if: ${{ inputs.build-job-name != '' }}
uses: kyma-project/wait-for-commit-status-action@2b3ffe09af8b6f40e1213d5fb7f91a7bd41ffb20
with:
context: ${{ inputs.build-job-name }}
commit_ref: "${{ inputs.build-job-commit-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
- name: Post-upgrade checkout
run: git checkout -b ${{ inputs.post-upgrade-image-tag }}

- name: Install Eventing manager after upgrade
run: |
post_upgrade_image=$(./hack/ci/build-full-image-path.sh ${{ inputs.post-upgrade-image-tag }})
echo "Post-upgrade image: $post_upgrade_image"
make deploy IMG=$post_upgrade_image
- name: Create test resources and waits for eventing CR readiness
run: |
export MANAGER_IMAGE=$(./hack/ci/build-full-image-path.sh ${{ inputs.post-upgrade-image-tag }})
make e2e-setup
- name: Run e2e tests
run: |
make e2e-eventing
- name: Cleanup test resources
run: |
make e2e-eventing-cleanup
make e2e-cleanup
19 changes: 19 additions & 0 deletions .github/workflows/pull-e2e-upgrade-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: pull-e2e-upgrade-test

on:
pull_request:
branches: [ "main" ]
paths-ignore:
- 'docs/**'
- '**.md'
- 'sec-scanners-config.yaml'

jobs:
upgrade-test:
uses: ./.github/workflows/e2e-upgrade-test-reusable.yaml
with:
pre-upgrade-image-tag: main
post-upgrade-image-tag: PR-${{ github.event.number }}
build-job-name: pull-eventing-manager-build
build-job-commit-sha: ${{ github.event.pull_request.head.sha }}
secrets: inherit
33 changes: 33 additions & 0 deletions .github/workflows/push-e2e-upgrade-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: post-e2e-upgrade-test

on:
push:
branches: [ "main" ]
paths-ignore:
- 'docs/**'
- '**.md'
- 'sec-scanners-config.yaml'

jobs:
get-latest-release:
runs-on: ubuntu-latest
outputs:
latest_release_tag: ${{ steps.get-latest-release-tag.outputs.latest_release_tag }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get latest release tag
id: get-latest-release-tag
run: |
echo "latest_release_tag=$(curl -s https://api.github.com/repos/kyma-project/eventing-manager/releases/latest | jq -r '.tag_name')" >> "$GITHUB_OUTPUT"
upgrade-test:
uses: ./.github/workflows/e2e-upgrade-test-reusable.yaml
needs: get-latest-release
with:
pre-upgrade-image-tag: ${{ needs.get-latest-release.outputs.latest_release_tag }}
post-upgrade-image-tag: main
build-job-name: push-eventing-manager-build
build-job-commit-sha: ${{ github.sha }}
secrets: inherit
16 changes: 16 additions & 0 deletions hack/ci/build-full-image-path.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# builds full image path given dev and prod image repos and tag. If tag starts with PR, then it's a dev image.

DOCKER_IMAGE_REPO=europe-docker.pkg.dev/kyma-project/prod/eventing-manager
DOCKER_IMAGE_REPO_DEV=europe-docker.pkg.dev/kyma-project/dev/eventing-manager

image_tag=$1

if [[ $image_tag == PR* ]]; then
full_image_path=$DOCKER_IMAGE_REPO_DEV:$image_tag
else
full_image_path=$DOCKER_IMAGE_REPO:$image_tag
fi

echo $full_image_path

0 comments on commit 74cb2a1

Please sign in to comment.