diff --git a/.github/workflows/add-pr-sizing-label.yaml b/.github/workflows/add-pr-sizing-label.yaml index b972616fa6..2fd0abc647 100644 --- a/.github/workflows/add-pr-sizing-label.yaml +++ b/.github/workflows/add-pr-sizing-label.yaml @@ -23,7 +23,14 @@ jobs: - name: Checkout code uses: actions/checkout@v3 with: - ref: ${{ github.event.pull_request.merge_commit_sha }} + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + + - name: Rebase atop of the latest target branch + run: | + ./tests/git-helper.sh "rebase-atop-of-the-latest-target-branch" + env: + TARGET_BRANCH: ${{ github.event.pull_request.base.ref }} - name: Install PR sizing label script run: | diff --git a/.github/workflows/build-kata-static-tarball-amd64.yaml b/.github/workflows/build-kata-static-tarball-amd64.yaml index 869d49bc60..67020ae609 100644 --- a/.github/workflows/build-kata-static-tarball-amd64.yaml +++ b/.github/workflows/build-kata-static-tarball-amd64.yaml @@ -16,6 +16,10 @@ on: commit-hash: required: false type: string + target-branch: + required: false + type: string + default: "" jobs: build-asset: @@ -66,6 +70,12 @@ jobs: ref: ${{ inputs.commit-hash }} fetch-depth: 0 # This is needed in order to keep the commit ids history + - name: Rebase atop of the latest target branch + run: | + ./tests/git-helper.sh "rebase-atop-of-the-latest-target-branch" + env: + TARGET_BRANCH: ${{ inputs.target-branch }} + - name: Build ${{ matrix.asset }} run: | make "${KATA_ASSET}-tarball" @@ -92,6 +102,12 @@ jobs: - uses: actions/checkout@v3 with: ref: ${{ inputs.commit-hash }} + fetch-depth: 0 + - name: Rebase atop of the latest target branch + run: | + ./tests/git-helper.sh "rebase-atop-of-the-latest-target-branch" + env: + TARGET_BRANCH: ${{ inputs.target-branch }} - name: get-artifacts uses: actions/download-artifact@v3 with: diff --git a/.github/workflows/build-kata-static-tarball-arm64.yaml b/.github/workflows/build-kata-static-tarball-arm64.yaml index cafc6e0200..689ec04c99 100644 --- a/.github/workflows/build-kata-static-tarball-arm64.yaml +++ b/.github/workflows/build-kata-static-tarball-arm64.yaml @@ -16,6 +16,10 @@ on: commit-hash: required: false type: string + target-branch: + required: false + type: string + default: "" jobs: build-asset: @@ -52,6 +56,13 @@ jobs: with: ref: ${{ inputs.commit-hash }} fetch-depth: 0 # This is needed in order to keep the commit ids history + + - name: Rebase atop of the latest target branch + run: | + ./tests/git-helper.sh "rebase-atop-of-the-latest-target-branch" + env: + TARGET_BRANCH: ${{ inputs.target-branch }} + - name: Build ${{ matrix.asset }} run: | make "${KATA_ASSET}-tarball" @@ -82,6 +93,12 @@ jobs: - uses: actions/checkout@v3 with: ref: ${{ inputs.commit-hash }} + fetch-depth: 0 + - name: Rebase atop of the latest target branch + run: | + ./tests/git-helper.sh "rebase-atop-of-the-latest-target-branch" + env: + TARGET_BRANCH: ${{ inputs.target-branch }} - name: get-artifacts uses: actions/download-artifact@v3 with: diff --git a/.github/workflows/build-kata-static-tarball-s390x.yaml b/.github/workflows/build-kata-static-tarball-s390x.yaml index 0fe7e9200d..75856e7e49 100644 --- a/.github/workflows/build-kata-static-tarball-s390x.yaml +++ b/.github/workflows/build-kata-static-tarball-s390x.yaml @@ -16,6 +16,10 @@ on: commit-hash: required: false type: string + target-branch: + required: false + type: string + default: "" jobs: build-asset: @@ -48,6 +52,13 @@ jobs: with: ref: ${{ inputs.commit-hash }} fetch-depth: 0 # This is needed in order to keep the commit ids history + + - name: Rebase atop of the latest target branch + run: | + ./tests/git-helper.sh "rebase-atop-of-the-latest-target-branch" + env: + TARGET_BRANCH: ${{ inputs.target-branch }} + - name: Build ${{ matrix.asset }} run: | make "${KATA_ASSET}-tarball" @@ -79,6 +90,12 @@ jobs: - uses: actions/checkout@v3 with: ref: ${{ inputs.commit-hash }} + fetch-depth: 0 + - name: Rebase atop of the latest target branch + run: | + ./tests/git-helper.sh "rebase-atop-of-the-latest-target-branch" + env: + TARGET_BRANCH: ${{ inputs.target-branch }} - name: get-artifacts uses: actions/download-artifact@v3 with: diff --git a/.github/workflows/ci-on-push.yaml b/.github/workflows/ci-on-push.yaml index f37f1b91ca..59a297b784 100644 --- a/.github/workflows/ci-on-push.yaml +++ b/.github/workflows/ci-on-push.yaml @@ -25,7 +25,8 @@ jobs: if: ${{ contains(github.event.pull_request.labels.*.name, 'ok-to-test') }} uses: ./.github/workflows/ci.yaml with: - commit-hash: ${{ github.event.pull_request.merge_commit_sha }} + commit-hash: ${{ github.event.pull_request.head.sha }} pr-number: ${{ github.event.pull_request.number }} tag: ${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }} + target-branch: ${{ github.event.pull_request.base.ref }} secrets: inherit diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d627ce7887..b80a3f322e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -11,6 +11,10 @@ on: tag: required: true type: string + target-branch: + required: false + type: string + default: "" jobs: build-kata-static-tarball-amd64: @@ -28,6 +32,7 @@ jobs: repo: ${{ github.repository_owner }}/kata-deploy-ci tag: ${{ inputs.tag }}-amd64 commit-hash: ${{ inputs.commit-hash }} + target-branch: ${{ inputs.target-branch }} secrets: inherit build-and-publish-tee-confidential-unencrypted-image: @@ -37,6 +42,13 @@ jobs: uses: actions/checkout@v3 with: ref: ${{ inputs.commit-hash }} + fetch-depth: 0 + + - name: Rebase atop of the latest target branch + run: | + ./tests/git-helper.sh "rebase-atop-of-the-latest-target-branch" + env: + TARGET_BRANCH: ${{ inputs.target-branch }} - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -69,6 +81,7 @@ jobs: tag: ${{ inputs.tag }}-amd64 commit-hash: ${{ inputs.commit-hash }} pr-number: ${{ inputs.pr-number }} + target-branch: ${{ inputs.target-branch }} secrets: inherit run-kata-deploy-tests-on-tdx: @@ -80,6 +93,7 @@ jobs: tag: ${{ inputs.tag }}-amd64 commit-hash: ${{ inputs.commit-hash }} pr-number: ${{ inputs.pr-number }} + target-branch: ${{ inputs.target-branch }} run-k8s-tests-on-aks: needs: publish-kata-deploy-payload-amd64 @@ -90,6 +104,7 @@ jobs: tag: ${{ inputs.tag }}-amd64 commit-hash: ${{ inputs.commit-hash }} pr-number: ${{ inputs.pr-number }} + target-branch: ${{ inputs.target-branch }} secrets: inherit run-k8s-tests-on-garm: @@ -112,6 +127,7 @@ jobs: tag: ${{ inputs.tag }}-amd64 commit-hash: ${{ inputs.commit-hash }} pr-number: ${{ inputs.pr-number }} + target-branch: ${{ inputs.target-branch }} run-k8s-tests-on-snp: needs: [publish-kata-deploy-payload-amd64, build-and-publish-tee-confidential-unencrypted-image] @@ -122,6 +138,7 @@ jobs: tag: ${{ inputs.tag }}-amd64 commit-hash: ${{ inputs.commit-hash }} pr-number: ${{ inputs.pr-number }} + target-branch: ${{ inputs.target-branch }} run-k8s-tests-on-tdx: needs: [publish-kata-deploy-payload-amd64, build-and-publish-tee-confidential-unencrypted-image] @@ -132,6 +149,7 @@ jobs: tag: ${{ inputs.tag }}-amd64 commit-hash: ${{ inputs.commit-hash }} pr-number: ${{ inputs.pr-number }} + target-branch: ${{ inputs.target-branch }} run-metrics-tests: needs: build-kata-static-tarball-amd64 @@ -139,6 +157,7 @@ jobs: with: tarball-suffix: -${{ inputs.tag }} commit-hash: ${{ inputs.commit-hash }} + target-branch: ${{ inputs.target-branch }} run-cri-containerd-tests: needs: build-kata-static-tarball-amd64 @@ -146,6 +165,7 @@ jobs: with: tarball-suffix: -${{ inputs.tag }} commit-hash: ${{ inputs.commit-hash }} + target-branch: ${{ inputs.target-branch }} run-nydus-tests: needs: build-kata-static-tarball-amd64 @@ -153,6 +173,7 @@ jobs: with: tarball-suffix: -${{ inputs.tag }} commit-hash: ${{ inputs.commit-hash }} + target-branch: ${{ inputs.target-branch }} run-vfio-tests: needs: build-kata-static-tarball-amd64 @@ -160,3 +181,4 @@ jobs: with: tarball-suffix: -${{ inputs.tag }} commit-hash: ${{ inputs.commit-hash }} + target-branch: ${{ inputs.target-branch }} diff --git a/.github/workflows/move-issues-to-in-progress.yaml b/.github/workflows/move-issues-to-in-progress.yaml index 2c4c3d2c88..23819e18c4 100644 --- a/.github/workflows/move-issues-to-in-progress.yaml +++ b/.github/workflows/move-issues-to-in-progress.yaml @@ -40,7 +40,15 @@ jobs: if: ${{ !contains(github.event.pull_request.labels.*.name, 'force-skip-ci') }} uses: actions/checkout@v3 with: - ref: ${{ github.event.pull_request.merge_commit_sha }} + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + + - name: Rebase atop of the latest target branch + if: ${{ !contains(github.event.pull_request.labels.*.name, 'force-skip-ci') }} + run: | + ./tests/git-helper.sh "rebase-atop-of-the-latest-target-branch" + env: + TARGET_BRANCH: ${{ github.event.pull_request.base.ref }} - name: Move issue to "In progress" if: ${{ !contains(github.event.pull_request.labels.*.name, 'force-skip-ci') }} diff --git a/.github/workflows/require-pr-porting-labels.yaml b/.github/workflows/require-pr-porting-labels.yaml index a06bbbf96e..4f799c4ba8 100644 --- a/.github/workflows/require-pr-porting-labels.yaml +++ b/.github/workflows/require-pr-porting-labels.yaml @@ -38,7 +38,15 @@ jobs: if: ${{ !contains(github.event.pull_request.labels.*.name, 'force-skip-ci') }} uses: actions/checkout@v3 with: - ref: ${{ github.event.pull_request.merge_commit_sha }} + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + + - name: Rebase atop of the latest target branch + if: ${{ !contains(github.event.pull_request.labels.*.name, 'force-skip-ci') }} + run: | + ./tests/git-helper.sh "rebase-atop-of-the-latest-target-branch" + env: + TARGET_BRANCH: ${{ github.event.pull_request.base.ref }} - name: Install porting checker script run: | diff --git a/.github/workflows/run-cri-containerd-tests.yaml b/.github/workflows/run-cri-containerd-tests.yaml index 19e8687ea6..2055613918 100644 --- a/.github/workflows/run-cri-containerd-tests.yaml +++ b/.github/workflows/run-cri-containerd-tests.yaml @@ -8,6 +8,10 @@ on: commit-hash: required: false type: string + target-branch: + required: false + type: string + default: "" jobs: run-cri-containerd: @@ -28,6 +32,13 @@ jobs: - uses: actions/checkout@v3 with: ref: ${{ inputs.commit-hash }} + fetch-depth: 0 + + - name: Rebase atop of the latest target branch + run: | + ./tests/git-helper.sh "rebase-atop-of-the-latest-target-branch" + env: + TARGET_BRANCH: ${{ inputs.target-branch }} - name: Install dependencies run: bash tests/integration/cri-containerd/gha-run.sh install-dependencies diff --git a/.github/workflows/run-k8s-tests-on-aks.yaml b/.github/workflows/run-k8s-tests-on-aks.yaml index 261454bb2f..c7b2f90811 100644 --- a/.github/workflows/run-k8s-tests-on-aks.yaml +++ b/.github/workflows/run-k8s-tests-on-aks.yaml @@ -17,6 +17,10 @@ on: commit-hash: required: false type: string + target-branch: + required: false + type: string + default: "" jobs: run-k8s-tests: @@ -46,6 +50,13 @@ jobs: - uses: actions/checkout@v3 with: ref: ${{ inputs.commit-hash }} + fetch-depth: 0 + + - name: Rebase atop of the latest target branch + run: | + ./tests/git-helper.sh "rebase-atop-of-the-latest-target-branch" + env: + TARGET_BRANCH: ${{ inputs.target-branch }} - name: Download Azure CLI run: bash tests/integration/kubernetes/gha-run.sh install-azure-cli diff --git a/.github/workflows/run-k8s-tests-on-garm.yaml b/.github/workflows/run-k8s-tests-on-garm.yaml index 4588be335e..22e9925d3c 100644 --- a/.github/workflows/run-k8s-tests-on-garm.yaml +++ b/.github/workflows/run-k8s-tests-on-garm.yaml @@ -17,6 +17,10 @@ on: commit-hash: required: false type: string + target-branch: + required: false + type: string + default: "" jobs: run-k8s-tests: @@ -45,6 +49,13 @@ jobs: - uses: actions/checkout@v3 with: ref: ${{ inputs.commit-hash }} + fetch-depth: 0 + + - name: Rebase atop of the latest target branch + run: | + ./tests/git-helper.sh "rebase-atop-of-the-latest-target-branch" + env: + TARGET_BRANCH: ${{ inputs.target-branch }} - name: Deploy ${{ matrix.k8s }} run: bash tests/integration/kubernetes/gha-run.sh deploy-k8s diff --git a/.github/workflows/run-k8s-tests-on-sev.yaml b/.github/workflows/run-k8s-tests-on-sev.yaml index 4260f43357..df105974a7 100644 --- a/.github/workflows/run-k8s-tests-on-sev.yaml +++ b/.github/workflows/run-k8s-tests-on-sev.yaml @@ -17,6 +17,10 @@ on: commit-hash: required: false type: string + target-branch: + required: false + type: string + default: "" jobs: run-k8s-tests: @@ -39,6 +43,13 @@ jobs: - uses: actions/checkout@v3 with: ref: ${{ inputs.commit-hash }} + fetch-depth: 0 + + - name: Rebase atop of the latest target branch + run: | + ./tests/git-helper.sh "rebase-atop-of-the-latest-target-branch" + env: + TARGET_BRANCH: ${{ inputs.target-branch }} - name: Deploy Kata timeout-minutes: 10 diff --git a/.github/workflows/run-k8s-tests-on-snp.yaml b/.github/workflows/run-k8s-tests-on-snp.yaml index 34cb5e6cba..80e146795a 100644 --- a/.github/workflows/run-k8s-tests-on-snp.yaml +++ b/.github/workflows/run-k8s-tests-on-snp.yaml @@ -17,6 +17,10 @@ on: commit-hash: required: false type: string + target-branch: + required: false + type: string + default: "" jobs: run-k8s-tests: @@ -39,6 +43,13 @@ jobs: - uses: actions/checkout@v3 with: ref: ${{ inputs.commit-hash }} + fetch-depth: 0 + + - name: Rebase atop of the latest target branch + run: | + ./tests/git-helper.sh "rebase-atop-of-the-latest-target-branch" + env: + TARGET_BRANCH: ${{ inputs.target-branch }} - name: Deploy Kata timeout-minutes: 10 diff --git a/.github/workflows/run-k8s-tests-on-tdx.yaml b/.github/workflows/run-k8s-tests-on-tdx.yaml index 1e15dd5a61..f9b14bc9d0 100644 --- a/.github/workflows/run-k8s-tests-on-tdx.yaml +++ b/.github/workflows/run-k8s-tests-on-tdx.yaml @@ -17,6 +17,10 @@ on: commit-hash: required: false type: string + target-branch: + required: false + type: string + default: "" jobs: run-k8s-tests: @@ -38,6 +42,13 @@ jobs: - uses: actions/checkout@v3 with: ref: ${{ inputs.commit-hash }} + fetch-depth: 0 + + - name: Rebase atop of the latest target branch + run: | + ./tests/git-helper.sh "rebase-atop-of-the-latest-target-branch" + env: + TARGET_BRANCH: ${{ inputs.target-branch }} - name: Deploy Kata timeout-minutes: 10 diff --git a/.github/workflows/run-kata-deploy-tests-on-aks.yaml b/.github/workflows/run-kata-deploy-tests-on-aks.yaml index 951e6e9328..8962fcf329 100644 --- a/.github/workflows/run-kata-deploy-tests-on-aks.yaml +++ b/.github/workflows/run-kata-deploy-tests-on-aks.yaml @@ -17,6 +17,10 @@ on: commit-hash: required: false type: string + target-branch: + required: false + type: string + default: "" jobs: run-kata-deploy-tests: @@ -45,6 +49,13 @@ jobs: - uses: actions/checkout@v3 with: ref: ${{ inputs.commit-hash }} + fetch-depth: 0 + + - name: Rebase atop of the latest target branch + run: | + ./tests/git-helper.sh "rebase-atop-of-the-latest-target-branch" + env: + TARGET_BRANCH: ${{ inputs.target-branch }} - name: Download Azure CLI run: bash tests/functional/kata-deploy/gha-run.sh install-azure-cli diff --git a/.github/workflows/run-kata-deploy-tests-on-tdx.yaml b/.github/workflows/run-kata-deploy-tests-on-tdx.yaml index f4029b6e9e..b9e7e0588d 100644 --- a/.github/workflows/run-kata-deploy-tests-on-tdx.yaml +++ b/.github/workflows/run-kata-deploy-tests-on-tdx.yaml @@ -17,6 +17,10 @@ on: commit-hash: required: false type: string + target-branch: + required: false + type: string + default: "" jobs: run-kata-deploy-tests: @@ -37,6 +41,13 @@ jobs: - uses: actions/checkout@v3 with: ref: ${{ inputs.commit-hash }} + fetch-depth: 0 + + - name: Rebase atop of the latest target branch + run: | + ./tests/git-helper.sh "rebase-atop-of-the-latest-target-branch" + env: + TARGET_BRANCH: ${{ inputs.target-branch }} - name: Run tests run: bash tests/functional/kata-deploy/gha-run.sh run-tests diff --git a/.github/workflows/run-metrics.yaml b/.github/workflows/run-metrics.yaml index d2e5ab64e2..08cbef9048 100644 --- a/.github/workflows/run-metrics.yaml +++ b/.github/workflows/run-metrics.yaml @@ -8,6 +8,10 @@ on: commit-hash: required: false type: string + target-branch: + required: false + type: string + default: "" jobs: setup-kata: @@ -19,6 +23,13 @@ jobs: - uses: actions/checkout@v3 with: ref: ${{ inputs.commit-hash }} + fetch-depth: 0 + + - name: Rebase atop of the latest target branch + run: | + ./tests/git-helper.sh "rebase-atop-of-the-latest-target-branch" + env: + TARGET_BRANCH: ${{ inputs.target-branch }} - name: get-kata-tarball uses: actions/download-artifact@v3 diff --git a/.github/workflows/run-nydus-tests.yaml b/.github/workflows/run-nydus-tests.yaml index 10ff1cc9a8..54c8cf8644 100644 --- a/.github/workflows/run-nydus-tests.yaml +++ b/.github/workflows/run-nydus-tests.yaml @@ -8,6 +8,10 @@ on: commit-hash: required: false type: string + target-branch: + required: false + type: string + default: "" jobs: run-nydus: @@ -28,6 +32,13 @@ jobs: - uses: actions/checkout@v3 with: ref: ${{ inputs.commit-hash }} + fetch-depth: 0 + + - name: Rebase atop of the latest target branch + run: | + ./tests/git-helper.sh "rebase-atop-of-the-latest-target-branch" + env: + TARGET_BRANCH: ${{ inputs.target-branch }} - name: Install dependencies run: bash tests/integration/nydus/gha-run.sh install-dependencies diff --git a/.github/workflows/run-vfio-tests.yaml b/.github/workflows/run-vfio-tests.yaml index 6a42a1b4e1..b5aa739cec 100644 --- a/.github/workflows/run-vfio-tests.yaml +++ b/.github/workflows/run-vfio-tests.yaml @@ -8,6 +8,10 @@ on: commit-hash: required: false type: string + target-branch: + required: false + type: string + default: "" jobs: run-vfio: @@ -23,6 +27,13 @@ jobs: - uses: actions/checkout@v3 with: ref: ${{ inputs.commit-hash }} + fetch-depth: 0 + + - name: Rebase atop of the latest target branch + run: | + ./tests/git-helper.sh "rebase-atop-of-the-latest-target-branch" + env: + TARGET_BRANCH: ${{ inputs.target-branch }} - name: Install dependencies run: bash tests/functional/vfio/gha-run.sh install-dependencies diff --git a/tests/git-helper.sh b/tests/git-helper.sh new file mode 100755 index 0000000000..81ec53cfa1 --- /dev/null +++ b/tests/git-helper.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# +# Copyright (c) 2023 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# + +set -o errexit +set -o nounset +set -o pipefail + +function add_kata_bot_info() { + echo "Adding user name and email to the local git repo" + + git config user.email "katacontainersbot@gmail.com" + git config user.name "Kata Containers Bot" +} + +function rebase_atop_of_the_latest_target_branch() { + if [ -n "${TARGET_BRANCH}" ]; then + echo "Rebasing atop of the latest ${TARGET_BRANCH}" + git rebase origin/${TARGET_BRANCH} + fi +} + +function main() { + action="${1:-}" + + add_kata_bot_info + + case "${action}" in + rebase-atop-of-the-latest-target-branch) rebase_atop_of_the_latest_target_branch;; + *) >&2 echo "Invalid argument"; exit 2 ;; + esac +} + +main "$@"