forked from spidernet-io/spiderpool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: tao.yang <[email protected]>
- Loading branch information
Showing
1 changed file
with
55 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,7 @@ jobs: | |
e2e_enabled: ${{ env.RUN_E2E_ENABLED }} | ||
run_upgrade_enabled: ${{ env.RUN_UPGRADE_ENABLED }} | ||
skip_create_pr: ${{ env.SKIP_CREATE_PR }} | ||
build_old_image_tag: ${{ env.BUILD_OLD_IMAGE_TAG }} | ||
steps: | ||
- name: Check Code Changes | ||
uses: dorny/[email protected] | ||
|
@@ -79,6 +80,7 @@ jobs: | |
echo "OLD_VERSION=${{ github.event.inputs.old_version }}" >> $GITHUB_ENV | ||
echo "NEW_VERSION=${{ github.event.inputs.ref }}" >> $GITHUB_ENV | ||
echo "SKIP_CREATE_PR=true" >> $GITHUB_ENV | ||
echo "BUILD_OLD_IMAGE_TAG=false" >> $GITHUB_ENV | ||
if ${{ github.event.inputs.e2e_enabled == 'true' }}; then | ||
echo "RUN_E2E_ENABLED=true" >> $GITHUB_ENV | ||
else | ||
|
@@ -90,6 +92,7 @@ jobs: | |
echo "NEW_VERSION=${{ inputs.dest_tag }}" >> $GITHUB_ENV | ||
echo "RUN_E2E_ENABLED=true" >> $GITHUB_ENV | ||
echo "SKIP_CREATE_PR=true" >> $GITHUB_ENV | ||
echo "BUILD_OLD_IMAGE_TAG=false" >> $GITHUB_ENV | ||
YBranchName=` grep -Eo "v[0-9]+\.[0-9]+" <<< "${{ inputs.dest_tag }}" ` | ||
# Get the previous minor version of version y | ||
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])" | grep ${YBranchName} | sort -r | head -n 1) | ||
|
@@ -107,15 +110,18 @@ jobs: | |
echo "RUN_TAG=${{ github.sha }}" >> $GITHUB_ENV | ||
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 | ||
echo "OLD_VERSION: ${{ github.event.pull_request.base.sha }}" | ||
echo "RUN_E2E_ENABLED=true" >> $GITHUB_ENV | ||
echo "SKIP_CREATE_PR=false" >> $GITHUB_ENV | ||
echo "BUILD_OLD_IMAGE_TAG=true" >> $GITHUB_ENV | ||
elif ${{ github.event_name == 'pull_request_target' }} ; then | ||
echo "trigger by pull_request_target" | ||
echo "RUN_TAG=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV | ||
echo "NEW_VERSION=${{ github.event.pull_request.head.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 | ||
echo "BUILD_OLD_IMAGE_TAG=true" >> $GITHUB_ENV | ||
echo "OLD_VERSION=${{ github.event.pull_request.base.sha }}" >> $GITHUB_ENV | ||
echo "OLD_VERSION: ${{ github.event.pull_request.base.sha }}" | ||
echo "SKIP_CREATE_PR=true" >> $GITHUB_ENV | ||
if ${{ steps.filter_pr.outputs.run_upgrade == 'true' }} ; then | ||
echo "RUN_UPGRADE_ENABLED=true" >> $GITHUB_ENV | ||
|
@@ -128,6 +134,7 @@ jobs: | |
echo "trigger by schedule" | ||
echo "RUN_TAG=main" >> $GITHUB_ENV | ||
echo "NEW_VERSION=main" >> $GITHUB_ENV | ||
echo "BUILD_OLD_IMAGE_TAG=false" >> $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}) | ||
echo "SKIP_CREATE_PR=false" >> $GITHUB_ENV | ||
|
@@ -154,34 +161,8 @@ jobs: | |
ref=$( git show -s --format='format:%H') | ||
echo "RUN_REF=${ref}" >> $GITHUB_ENV | ||
call_build_ci_image: | ||
needs: [get_ref] | ||
if: ${{ needs.get_ref.outputs.run_upgrade_enabled == 'true' }} | ||
uses: ./.github/workflows/build-image-ci.yaml | ||
with: | ||
ref: ${{ needs.get_ref.outputs.ref }} | ||
push: false | ||
secrets: inherit | ||
|
||
lint_chart_against_release_image: | ||
needs: get_ref | ||
if: ${{ needs.get_ref.outputs.run_upgrade_enabled == 'true' }} | ||
uses: ./.github/workflows/call-lint-chart.yaml | ||
with: | ||
ref: ${{ needs.get_ref.outputs.ref }} | ||
secrets: inherit | ||
|
||
trivy_scan_images: | ||
needs: [call_build_ci_image, get_ref] | ||
if: ${{ needs.get_ref.outputs.run_upgrade_enabled == 'true' }} | ||
uses: ./.github/workflows/trivy-scan-image.yaml | ||
with: | ||
image_tag: ${{ needs.call_build_ci_image.outputs.imageTag }} | ||
ref: ${{ needs.get_ref.outputs.ref }} | ||
secrets: inherit | ||
|
||
run_upgrade_tests_on_release_version: | ||
needs: [call_build_ci_image, get_ref] | ||
needs: [get_ref] | ||
if: ${{ needs.get_ref.outputs.run_upgrade_enabled == 'true' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
@@ -196,6 +177,40 @@ jobs: | |
docker-images: true | ||
swap-storage: true | ||
|
||
- name: call_build_ci_image | ||
id: call_build_ci_image | ||
if: ${{ needs.get_ref.outputs.build_old_image_tag == 'true' }} | ||
uses: ./.github/workflows/build-image-ci.yaml | ||
with: | ||
ref: ${{ needs.get_ref.outputs.old_version }} | ||
push: false | ||
secrets: inherit | ||
|
||
- name: Download spiderpool-agent image | ||
if: ${{ needs.get_ref.outputs.build_old_image_tag == 'true' }} | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: image-tar-spiderpool-agent | ||
path: test/.download | ||
|
||
- name: Download spiderpool-controller image | ||
if: ${{ needs.get_ref.outputs.build_old_image_tag == 'true' }} | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: image-tar-spiderpool-controller | ||
path: test/.download | ||
|
||
- name: Load Images | ||
if: ${{ needs.get_ref.outputs.build_old_image_tag == 'true' }} | ||
run: | | ||
TAR_FILES=` ls test/.download ` | ||
echo $TAR_FILES | ||
for ITEM in $TAR_FILES ; do | ||
IMAGE_NAME=${ITEM%*.tar} | ||
echo ${IMAGE_NAME} | ||
cat test/.download/${ITEM} | docker import - ${IMAGE_NAME}:${{ steps.call_build_ci_image.outputs.imageTag }} | ||
done | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
|
@@ -207,11 +222,7 @@ jobs: | |
run: | | ||
echo "ref: ${{ inputs.ref }} " | ||
echo "===== image " | ||
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 | ||
echo "ci image tag: ghcr.io/${{ github.repository }}/spiderpool-controller:${{ needs.get_ref.outputs.old_version }}" | ||
TMP=` date +%m%d%H%M%S ` | ||
E2E_CLUSTER_NAME="spiderpool${TMP}" | ||
echo "E2E_CLUSTER_NAME=${E2E_CLUSTER_NAME}" >> $GITHUB_ENV | ||
|
@@ -242,12 +253,7 @@ 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 | ||
E2E_SPIDERPOOL_TAG=${{ needs.get_ref.outputs.old_version }} | ||
make e2e_init_underlay -e E2E_CLUSTER_NAME=${{ env.E2E_CLUSTER_NAME }} \ | ||
-e E2E_SPIDERPOOL_TAG=${E2E_SPIDERPOOL_TAG} \ | ||
-e PYROSCOPE_LOCAL_PORT="" \ | ||
|
@@ -273,6 +279,14 @@ jobs: | |
mkdir -p ${{ env.KUBECONFIG_PATH }}/${{ env.E2E_CLUSTER_NAME }}/.kube/ | ||
cp -r /tmp/config ${{ env.KUBECONFIG_PATH }}/${{ env.E2E_CLUSTER_NAME }}/.kube/config | ||
- name: call_build_ci_image | ||
if: ${{ github.event_name == 'pull_request_target' || github.event_name == 'push' }} | ||
uses: ./.github/workflows/build-image-ci.yaml | ||
with: | ||
ref: ${{ needs.get_ref.outputs.ref }} | ||
push: false | ||
secrets: inherit | ||
|
||
- name: Download spiderpool-agent image | ||
uses: actions/download-artifact@v3 | ||
with: | ||
|
@@ -358,7 +372,7 @@ jobs: | |
creat_issue: | ||
runs-on: ubuntu-latest | ||
needs: [run_upgrade_tests_on_release_version, trivy_scan_images, get_ref] | ||
needs: [run_upgrade_tests_on_release_version, get_ref] | ||
if: ${{ always() && needs.run_upgrade_tests_on_release_version.result == 'failure' && needs.get_ref.outputs.skip_create_pr == 'false' }} | ||
steps: | ||
- name: echo | ||
|