Skip to content

Commit

Permalink
debug ci
Browse files Browse the repository at this point in the history
Signed-off-by: tao.yang <[email protected]>
  • Loading branch information
ty-dc committed Jun 21, 2024
1 parent 1c0cd94 commit 7333c3b
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 47 deletions.
117 changes: 71 additions & 46 deletions .github/workflows/auto-upgrade-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -154,34 +161,28 @@ jobs:
ref=$( git show -s --format='format:%H')
echo "RUN_REF=${ref}" >> $GITHUB_ENV
call_build_ci_image:
call_build_old_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 }}
ref: ${{ needs.get_ref.outputs.old_version }}
push: false
imageTarName: old-image-tar
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]
call_build_new_ci_image:
needs: [get_ref]
if: ${{ needs.get_ref.outputs.run_upgrade_enabled == 'true' }}
uses: ./.github/workflows/trivy-scan-image.yaml
uses: ./.github/workflows/build-image-ci.yaml
with:
image_tag: ${{ needs.call_build_ci_image.outputs.imageTag }}
ref: ${{ needs.get_ref.outputs.ref }}
ref: ${{ needs.get_ref.outputs.new_version }}
push: false
imageTarName: new-image-tar
secrets: inherit

run_upgrade_tests_on_release_version:
needs: [call_build_ci_image, get_ref]
needs: [get_ref, call_build_old_ci_image, call_build_new_ci_image]
if: ${{ needs.get_ref.outputs.run_upgrade_enabled == 'true' }}
runs-on: ubuntu-latest
steps:
Expand All @@ -200,21 +201,7 @@ jobs:
uses: actions/checkout@v4
with:
persist-credentials: false
ref: ${{ needs.get_ref.outputs.new_version }}

- name: Prepare
id: prepare
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
TMP=` date +%m%d%H%M%S `
E2E_CLUSTER_NAME="spiderpool${TMP}"
echo "E2E_CLUSTER_NAME=${E2E_CLUSTER_NAME}" >> $GITHUB_ENV
ref: ${{ needs.get_ref.outputs.old_version }}

- name: Setup Golang
uses: actions/setup-go@v5
Expand All @@ -230,6 +217,41 @@ jobs:
run: |
bash ./test/scripts/install-tools.sh
- name: Download old spiderpool-agent image
if: ${{ needs.get_ref.outputs.build_old_image_tag == 'true' }}
uses: actions/download-artifact@v3
with:
name: old-image-tar-spiderpool-agent
path: test/.download

- name: Download old spiderpool-controller image
if: ${{ needs.get_ref.outputs.build_old_image_tag == 'true' }}
uses: actions/download-artifact@v3
with:
name: old-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}:${{ needs.call_build_old_ci_image.outputs.imageTag }}
done
- name: Prepare
id: prepare
run: |
echo "ref: ${{ inputs.ref }} "
echo "===== image "
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
- name: Setup Kind Cluster on oldVersion ${{ needs.get_ref.outputs.old_version }}
uses: nick-invision/retry@v2
with:
Expand All @@ -242,13 +264,16 @@ 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 }}
E2E_SPIDERPOOL_TAG=${{ needs.get_ref.outputs.old_version }}
SPIDERPOOL_AGENT_IMAGE_NAME=""
SPIDERPOOL_CONTROLLER_IMAGE_NAME=""
if ${{ needs.get_ref.outputs.build_old_image_tag == 'true' }} ; then
SPIDERPOOL_AGENT_IMAGE_NAME=spiderpool-agent-race
SPIDERPOOL_CONTROLLER_IMAGE_NAME=spiderpool-controller-race
fi
make e2e_init_underlay -e E2E_CLUSTER_NAME=${{ env.E2E_CLUSTER_NAME }} \
-e SPIDERPOOL_AGENT_IMAGE_NAME=${SPIDERPOOL_AGENT_IMAGE_NAME} \
-e SPIDERPOOL_CONTROLLER_IMAGE_NAME=${SPIDERPOOL_CONTROLLER_IMAGE_NAME} \
-e E2E_SPIDERPOOL_TAG=${E2E_SPIDERPOOL_TAG} \
-e PYROSCOPE_LOCAL_PORT="" \
-e INSTALL_KUBEVIRT=true \
Expand All @@ -265,24 +290,24 @@ jobs:
uses: actions/checkout@v4
with:
persist-credentials: false
ref: ${{ needs.get_ref.outputs.ref }}
ref: ${{ needs.get_ref.outputs.new_version }}
fetch-depth: 0

- name: Move kubeconfig from oldVersion ${{ needs.get_ref.outputs.old_version }} to the upgradeVersion ${{ needs.get_ref.outputs.new_version }}
run: |
mkdir -p ${{ env.KUBECONFIG_PATH }}/${{ env.E2E_CLUSTER_NAME }}/.kube/
cp -r /tmp/config ${{ env.KUBECONFIG_PATH }}/${{ env.E2E_CLUSTER_NAME }}/.kube/config
- name: Download spiderpool-agent image
- name: Download new spiderpool-agent image
uses: actions/download-artifact@v3
with:
name: image-tar-spiderpool-agent
name: new-image-tar-spiderpool-agent
path: test/.download

- name: Download spiderpool-controller image
- name: Download new spiderpool-controller image
uses: actions/download-artifact@v3
with:
name: image-tar-spiderpool-controller
name: new-image-tar-spiderpool-controller
path: test/.download

- name: Load Images
Expand All @@ -292,15 +317,15 @@ jobs:
for ITEM in $TAR_FILES ; do
IMAGE_NAME=${ITEM%*.tar}
echo ${IMAGE_NAME}
cat test/.download/${ITEM} | docker import - ${IMAGE_NAME}:${{ needs.call_build_ci_image.outputs.imageTag }}
cat test/.download/${ITEM} | docker import - ${IMAGE_NAME}:${{ needs.call_build_new_ci_image.outputs.imageTag }}
done
- name: Upgrade to version ${{ needs.get_ref.outputs.ref }}
id: upgrade
continue-on-error: true
run: |
make upgrade_e2e_spiderpool -e E2E_CLUSTER_NAME=${{ env.E2E_CLUSTER_NAME }} \
-e E2E_SPIDERPOOL_TAG=${{ needs.call_build_ci_image.outputs.imageTag }} \
-e E2E_SPIDERPOOL_TAG=${{ needs.call_build_new_ci_image.outputs.imageTag }} \
-e SPIDERPOOL_AGENT_IMAGE_NAME=spiderpool-agent-race \
-e SPIDERPOOL_CONTROLLER_IMAGE_NAME=spiderpool-controller-race
Expand Down Expand Up @@ -358,7 +383,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
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/build-image-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ on:
push:
required: true
type: string
imageTarName:
required: false
type: string
default: "image-tar"
outputs:
imageTag:
description: "tag of image ci"
Expand Down Expand Up @@ -256,7 +260,7 @@ jobs:
- name: Upload artifact race image tar
uses: actions/[email protected]
with:
name: image-tar-${{ matrix.name }}
name: ${{ inputs.imageTarName }}-${{ matrix.name }}
path: /tmp/${{ matrix.name }}-race.tar
retention-days: 1

Expand Down

0 comments on commit 7333c3b

Please sign in to comment.