Skip to content

Commit

Permalink
optimizate upgrade
Browse files Browse the repository at this point in the history
Signed-off-by: tao.yang <[email protected]>
  • Loading branch information
ty-dc committed May 13, 2024
1 parent b103d38 commit 8b55c7c
Showing 1 changed file with 51 additions and 12 deletions.
63 changes: 51 additions & 12 deletions .github/workflows/auto-upgrade-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ env:
on:
schedule:
- cron: "0 20 * * *"
pull_request_target:
types:
- opened
- synchronize
- reopened
workflow_call:
inputs:
dest_tag:
Expand Down Expand Up @@ -74,28 +79,53 @@ jobs:
echo "LATEST_RELEASE_VERISON: ${LATEST_RELEASE_VERISON} "
echo "OLD_VERSION=${LATEST_RELEASE_VERISON}" >> $GITHUB_ENV
fi
elif ${{ github.event_name == 'push' }} ; then
echo "trigger by push"
echo "RUN_TAG=${{ github.sha }}" >> $GITHUB_ENV
elif ${{ github.event_name == 'pull_request_target' }} ; then
echo "trigger by pull_request_target"
echo "RUN_TAG=${{ github.sha }}" >> $GITHUB_ENV
else
# schedule event
# use main sha for ci image tag
echo "trigger by schedule"
echo "RUN_TAG=main" >> $GITHUB_ENV
echo "NEW_VERSION=main" >> $GITHUB_ENV
LATEST_RELEASE_VERISON=$(curl -s https://api.github.com/repos/spidernet-io/spiderpool/releases | grep '"tag_name":' | grep -Eo "v([0-9]+\.[0-9]+\.[0-9])" | sort -r | head -n 1)
echo "OLD_VERSION=${LATEST_RELEASE_VERISON}" >> $GITHUB_ENV
LATEST_RELEASE_VERISON=$(curl -s https://api.github.com/repos/spidernet-io/spiderpool/releases | grep '"tag_name":' | sort -r | head -n 1)
rc_version=$(grep -Eo 'v[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]' <<< ${LATEST_RELEASE_VERISON})
if [ -z ${rc_version} ]; then
echo "the latest released version is not an 'rc: ${LATEST_RELEASE_VERISON}' version."
echo "OLD_VERSION=$(grep -Eo "v([0-9]+\.[0-9]+\.[0-9])" <<< ${LATEST_RELEASE_VERISON})" >> $GITHUB_ENV
else
echo "The latest released version is an 'rc: ${LATEST_RELEASE_VERISON}' version."
echo "OLD_VERSION=${rc_version}" >> $GITHUB_ENV
fi
echo "RUN_E2E_ENABLED=true" >> $GITHUB_ENV
fi
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
ref: ${{ env.RUN_TAG }}

- name: Result Ref
id: result
run: |
ref=$( git show -s --format='format:%H')
echo "RUN_REF=${ref}" >> $GITHUB_ENV
if ${{ github.event_name == 'push' }} ; then
echo "trigger by push"
echo "NEW_VERSION=${{ github.sha }}" >> $GITHUB_ENV
# for PR scenarios, the latest version of the main branch will be used as old-version
echo "OLD_VERSION=main" >> $GITHUB_ENV
elif ${{ github.event_name == 'pull_request_target' }} ; then
echo "trigger by pull_request_target"
echo "NEW_VERSION=${{ github.sha }}" >> $GITHUB_ENV
# for PR scenarios, the latest version of the main branch will be used as old-version
echo "OLD_VERSION=main" >> $GITHUB_ENV
fi
call_build_ci_image:
needs: [get_ref]
Expand Down Expand Up @@ -146,7 +176,11 @@ jobs:
run: |
echo "ref: ${{ inputs.ref }} "
echo "===== image "
echo "ci image tag: ghcr.io/${{ github.repository }}/spiderpool-controller:${{ needs.get_ref.outputs.old_version }}"
if ${{ needs.get_ref.outputs.old_version == 'main' }} ; then
echo "ci image tag: ghcr.io/${{ github.repository }}/spiderpool-controller:latest"
else
echo "ci image tag: ghcr.io/${{ github.repository }}/spiderpool-controller:${{ needs.get_ref.outputs.old_version }}"
fi
TMP=` date +%m%d%H%M%S `
E2E_CLUSTER_NAME="spiderpool${TMP}"
echo "E2E_CLUSTER_NAME=${E2E_CLUSTER_NAME}" >> $GITHUB_ENV
Expand Down Expand Up @@ -177,9 +211,20 @@ jobs:
echo "restart docker before trying again"
systemctl restart docker
command: |
E2E_SPIDERPOOL_TAG=""
if ${{ needs.get_ref.outputs.old_version == 'main' }} ; then
E2E_SPIDERPOOL_TAG=latest
else
E2E_SPIDERPOOL_TAG=${{ needs.get_ref.outputs.old_version }}
fi
make e2e_init_underlay -e E2E_CLUSTER_NAME=${{ env.E2E_CLUSTER_NAME }} \
-e E2E_SPIDERPOOL_TAG=${{ needs.get_ref.outputs.old_version }} \
-e PYROSCOPE_LOCAL_PORT=""
-e E2E_SPIDERPOOL_TAG=${E2E_SPIDERPOOL_TAG} \
-e PYROSCOPE_LOCAL_PORT="" \
-e INSTALL_KUBEVIRT=true \
-e INSTALL_KRUISE=true \
-e INSTALL_KDOCTOR=true \
-e INSTALL_RDMA=true \
-e INSTALL_SRIOV=true
- name: backup kubeconfig from olderVersion ${{ needs.get_ref.outputs.old_version }}
run: |
Expand Down Expand Up @@ -225,13 +270,7 @@ jobs:
run: |
make upgrade_e2e_spiderpool -e E2E_SPIDERPOOL_TAG=${{ needs.call_build_ci_image.outputs.imageTag }} \
-e SPIDERPOOL_AGENT_IMAGE_NAME=spiderpool-agent-race \
-e SPIDERPOOL_CONTROLLER_IMAGE_NAME=spiderpool-controller-race \
-e INSTALL_KUBEVIRT=true \
-e INSTALL_KRUISE=true \
-e INSTALL_KDOCTOR=true \
-e INSTALL_OVS=${INSTALL_OVS_VALUE} \
-e INSTALL_RDMA=true \
-e INSTALL_SRIOV=true
-e SPIDERPOOL_CONTROLLER_IMAGE_NAME=spiderpool-controller-race
- name: Run e2e Test on ${{ needs.get_ref.outputs.ref }}
id: run_e2e
Expand Down

0 comments on commit 8b55c7c

Please sign in to comment.