From 4552707b2efaa5034404cffbf033c723304336f1 Mon Sep 17 00:00:00 2001 From: newborn22 <953950914@qq.com> Date: Thu, 14 Nov 2024 20:16:03 +0800 Subject: [PATCH 1/8] fix: update ci Signed-off-by: newborn22 <953950914@qq.com> --- .github/workflows/build_image.yml | 11 ++++++++++- .github/workflows/cluster_endtoend_mtr_docker.yml | 4 +++- .github/workflows/pick-and-release.yaml | 9 +++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_image.yml b/.github/workflows/build_image.yml index 8cdb2e4efc..e85d4b482e 100644 --- a/.github/workflows/build_image.yml +++ b/.github/workflows/build_image.yml @@ -26,6 +26,14 @@ on: type: string default: 'latest' description: 'Image tags (comma-separated)' + want_push: + required: false + type: boolean + default: true + want_load: + required: false + type: boolean + default: true jobs: build-and-push: @@ -67,7 +75,8 @@ jobs: context: . file: docker/wesqlscale/Dockerfile.release platforms: ${{ inputs.platforms }} - push: true + push: ${{ inputs.want_push }} + load: ${{ inputs.want_load }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha diff --git a/.github/workflows/cluster_endtoend_mtr_docker.yml b/.github/workflows/cluster_endtoend_mtr_docker.yml index f8ccb3f687..4b41e0559a 100644 --- a/.github/workflows/cluster_endtoend_mtr_docker.yml +++ b/.github/workflows/cluster_endtoend_mtr_docker.yml @@ -33,6 +33,8 @@ jobs: tags: test-${{ github.sha }} registry: ghcr.io platforms: linux/amd64 + want_push: false + want_load: false setup: name: "MTR Test - Ubuntu Docker Cluster" @@ -65,7 +67,7 @@ jobs: - name: Set up cluster run: | MYSQL_IMG="mysql/mysql-server:${{ env.MYSQL_VERSION }}" - WESCALE_CI_IMAGE="${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}" + WESCALE_CI_IMAGE="localhost/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}" docker network create wescale-network diff --git a/.github/workflows/pick-and-release.yaml b/.github/workflows/pick-and-release.yaml index 7502867d2e..363262753e 100644 --- a/.github/workflows/pick-and-release.yaml +++ b/.github/workflows/pick-and-release.yaml @@ -10,6 +10,11 @@ jobs: if: github.event.issue.pull_request != null && contains(github.event.comment.body, '/pick-and-release') runs-on: ubuntu-latest + permissions: + contents: write + issues: write + pull-requests: write + steps: - name: Checkout Repository uses: actions/checkout@v4 @@ -25,6 +30,8 @@ jobs: - name: Add Tag to Target Branch id: add_tag + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | COMMENT="${{ github.event.comment.body }}" TARGET_BRANCH=$(echo "$COMMENT" | awk '{print $2}') @@ -72,6 +79,8 @@ jobs: --body "🤖 says: tagged branch $TARGET_BRANCH with $TAG_NAME successfully." - name: Trigger Image Release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | TAG_NAME="${{ steps.add_tag.outputs.tag_name }}" From 29dd4808e43b7704e0c04e6bac8d74d9f01401de Mon Sep 17 00:00:00 2001 From: newborn22 <953950914@qq.com> Date: Thu, 14 Nov 2024 20:21:29 +0800 Subject: [PATCH 2/8] fix: update name Signed-off-by: newborn22 <953950914@qq.com> --- .github/workflows/build_image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_image.yml b/.github/workflows/build_image.yml index e85d4b482e..c602bb1fd7 100644 --- a/.github/workflows/build_image.yml +++ b/.github/workflows/build_image.yml @@ -36,7 +36,7 @@ on: default: true jobs: - build-and-push: + build-image: runs-on: ubuntu-latest permissions: contents: read From 9b7a7f40f07617894f2d48819905a735cd3bad04 Mon Sep 17 00:00:00 2001 From: newborn22 <953950914@qq.com> Date: Thu, 14 Nov 2024 20:31:00 +0800 Subject: [PATCH 3/8] fix: fix image name Signed-off-by: newborn22 <953950914@qq.com> --- .github/workflows/build_image.yml | 2 +- .github/workflows/cluster_endtoend_mtr_docker.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_image.yml b/.github/workflows/build_image.yml index c602bb1fd7..3486aee889 100644 --- a/.github/workflows/build_image.yml +++ b/.github/workflows/build_image.yml @@ -69,7 +69,7 @@ jobs: tags: | type=raw,value=${{ inputs.tags }} - - name: Build and push + - name: Build Image uses: docker/build-push-action@v5 with: context: . diff --git a/.github/workflows/cluster_endtoend_mtr_docker.yml b/.github/workflows/cluster_endtoend_mtr_docker.yml index 4b41e0559a..7cbdd52e1a 100644 --- a/.github/workflows/cluster_endtoend_mtr_docker.yml +++ b/.github/workflows/cluster_endtoend_mtr_docker.yml @@ -67,7 +67,7 @@ jobs: - name: Set up cluster run: | MYSQL_IMG="mysql/mysql-server:${{ env.MYSQL_VERSION }}" - WESCALE_CI_IMAGE="localhost/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}" + WESCALE_CI_IMAGE="${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}" docker network create wescale-network From 7f6e2b1de46cb73d9248f5ba81273e0b5d34697a Mon Sep 17 00:00:00 2001 From: newborn22 <953950914@qq.com> Date: Thu, 14 Nov 2024 20:53:21 +0800 Subject: [PATCH 4/8] fix: use artifact to transfer Signed-off-by: newborn22 <953950914@qq.com> --- .github/workflows/build_image.yml | 25 ++++++++++++++++++- .../workflows/cluster_endtoend_mtr_docker.yml | 14 ++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_image.yml b/.github/workflows/build_image.yml index 3486aee889..7bba822fb9 100644 --- a/.github/workflows/build_image.yml +++ b/.github/workflows/build_image.yml @@ -34,6 +34,15 @@ on: required: false type: boolean default: true + want_artifact: + required: false + type: boolean + default: false + artifact_path: + required: false + type: string + default: '/tmp/image.tar' + jobs: build-image: @@ -81,4 +90,18 @@ jobs: labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max - provenance: false \ No newline at end of file + provenance: false + + - name: Save Docker image + if: inputs.want_artifact + run: | + IMAGE_NAME="${{ steps.meta.outputs.tags }}" + docker save $IMAGE_NAME > ${{ inputs.artifact_path }} + + - name: Upload artifact + if: inputs.want_artifact + uses: actions/upload-artifact@v3 + with: + name: docker-image + path: ${{ inputs.artifact_path }} + retention-days: 1 \ No newline at end of file diff --git a/.github/workflows/cluster_endtoend_mtr_docker.yml b/.github/workflows/cluster_endtoend_mtr_docker.yml index 7cbdd52e1a..43598ec1b6 100644 --- a/.github/workflows/cluster_endtoend_mtr_docker.yml +++ b/.github/workflows/cluster_endtoend_mtr_docker.yml @@ -31,10 +31,11 @@ jobs: branch: ${{ github.ref }} image_name: ${{ github.repository_owner }}/wescale_ci_image tags: test-${{ github.sha }} - registry: ghcr.io platforms: linux/amd64 want_push: false want_load: false + want_artifact: true + artifact_path: '/tmp/image.tar' setup: name: "MTR Test - Ubuntu Docker Cluster" @@ -63,6 +64,17 @@ jobs: username: ${{ github.actor }} password: ${{ github.token }} + - name: Download Docker image + uses: actions/download-artifact@v3 + with: + name: docker-image + path: /tmp/image.tar + + - name: Load Docker image + run: | + docker load < /tmp/image.tar + echo "Verifying image loaded:" + docker images - name: Set up cluster run: | From 5ffe65940ad7fa80d9ae306e2b4b69186aafcf05 Mon Sep 17 00:00:00 2001 From: newborn22 <953950914@qq.com> Date: Thu, 14 Nov 2024 21:11:55 +0800 Subject: [PATCH 5/8] fix: fix Signed-off-by: newborn22 <953950914@qq.com> --- .github/workflows/cluster_endtoend_mtr_docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cluster_endtoend_mtr_docker.yml b/.github/workflows/cluster_endtoend_mtr_docker.yml index 43598ec1b6..f0f6ff2efe 100644 --- a/.github/workflows/cluster_endtoend_mtr_docker.yml +++ b/.github/workflows/cluster_endtoend_mtr_docker.yml @@ -33,7 +33,7 @@ jobs: tags: test-${{ github.sha }} platforms: linux/amd64 want_push: false - want_load: false + want_load: true want_artifact: true artifact_path: '/tmp/image.tar' From 68cfc7c3a123481efb965d428227fc55e6e63b88 Mon Sep 17 00:00:00 2001 From: newborn22 <953950914@qq.com> Date: Thu, 14 Nov 2024 21:29:57 +0800 Subject: [PATCH 6/8] fix: fix Signed-off-by: newborn22 <953950914@qq.com> --- .github/workflows/build_image.yml | 6 +++--- .github/workflows/cluster_endtoend_mtr_docker.yml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_image.yml b/.github/workflows/build_image.yml index 7bba822fb9..b3df944c7f 100644 --- a/.github/workflows/build_image.yml +++ b/.github/workflows/build_image.yml @@ -41,7 +41,7 @@ on: artifact_path: required: false type: string - default: '/tmp/image.tar' + default: '/tmp' jobs: @@ -102,6 +102,6 @@ jobs: if: inputs.want_artifact uses: actions/upload-artifact@v3 with: - name: docker-image - path: ${{ inputs.artifact_path }} + name: image.tar + path: /tmp/image.tar retention-days: 1 \ No newline at end of file diff --git a/.github/workflows/cluster_endtoend_mtr_docker.yml b/.github/workflows/cluster_endtoend_mtr_docker.yml index f0f6ff2efe..254dac6e5d 100644 --- a/.github/workflows/cluster_endtoend_mtr_docker.yml +++ b/.github/workflows/cluster_endtoend_mtr_docker.yml @@ -67,8 +67,8 @@ jobs: - name: Download Docker image uses: actions/download-artifact@v3 with: - name: docker-image - path: /tmp/image.tar + name: image.tar + path: /tmp - name: Load Docker image run: | From b27e24b1666f1de99d41c6728648c065094d0284 Mon Sep 17 00:00:00 2001 From: newborn22 <953950914@qq.com> Date: Thu, 14 Nov 2024 21:43:28 +0800 Subject: [PATCH 7/8] fix: fix Signed-off-by: newborn22 <953950914@qq.com> --- .github/workflows/build_image.yml | 8 ++++---- .github/workflows/cluster_endtoend_mtr_docker.yml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_image.yml b/.github/workflows/build_image.yml index b3df944c7f..dda51f892c 100644 --- a/.github/workflows/build_image.yml +++ b/.github/workflows/build_image.yml @@ -38,10 +38,10 @@ on: required: false type: boolean default: false - artifact_path: + artifact_name: required: false type: string - default: '/tmp' + default: 'image.tar' jobs: @@ -96,12 +96,12 @@ jobs: if: inputs.want_artifact run: | IMAGE_NAME="${{ steps.meta.outputs.tags }}" - docker save $IMAGE_NAME > ${{ inputs.artifact_path }} + docker save $IMAGE_NAME > /tmp/image.tar - name: Upload artifact if: inputs.want_artifact uses: actions/upload-artifact@v3 with: - name: image.tar + name: ${{ inputs.artifact_name }} path: /tmp/image.tar retention-days: 1 \ No newline at end of file diff --git a/.github/workflows/cluster_endtoend_mtr_docker.yml b/.github/workflows/cluster_endtoend_mtr_docker.yml index 254dac6e5d..675101ed14 100644 --- a/.github/workflows/cluster_endtoend_mtr_docker.yml +++ b/.github/workflows/cluster_endtoend_mtr_docker.yml @@ -35,7 +35,7 @@ jobs: want_push: false want_load: true want_artifact: true - artifact_path: '/tmp/image.tar' + artifact_name: 'image.tar' setup: name: "MTR Test - Ubuntu Docker Cluster" @@ -79,7 +79,7 @@ jobs: - name: Set up cluster run: | MYSQL_IMG="mysql/mysql-server:${{ env.MYSQL_VERSION }}" - WESCALE_CI_IMAGE="${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}" + WESCALE_CI_IMAGE="${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}" docker network create wescale-network From f8b07f00e6f2f3e4a120c17469d5c326c17267e8 Mon Sep 17 00:00:00 2001 From: newborn22 <953950914@qq.com> Date: Thu, 14 Nov 2024 21:56:27 +0800 Subject: [PATCH 8/8] fix: fix Signed-off-by: newborn22 <953950914@qq.com> --- .../workflows/cluster_endtoend_mtr_docker.yml | 37 +------------------ 1 file changed, 1 insertion(+), 36 deletions(-) diff --git a/.github/workflows/cluster_endtoend_mtr_docker.yml b/.github/workflows/cluster_endtoend_mtr_docker.yml index 675101ed14..edbf62991e 100644 --- a/.github/workflows/cluster_endtoend_mtr_docker.yml +++ b/.github/workflows/cluster_endtoend_mtr_docker.yml @@ -135,39 +135,4 @@ jobs: fi - name: Print Wescale logs run: | - docker logs wescale - - - name: Clean up - if: always() - run: | - TOKEN="${{ github.token }}" - OWNER="${{ github.repository_owner }}" - PACKAGE_NAME="${{ env.IMAGE_NAME }}" - TAG="${{ env.IMAGE_TAG }}" - - VERSIONS_JSON=$(curl -s \ - -H "Authorization: Bearer $TOKEN" \ - -H "Accept: application/vnd.github+json" \ - "https://api.github.com/orgs/$OWNER/packages/container/$PACKAGE_NAME/versions") - - PACKAGE_VERSION_ID=$(echo "$VERSIONS_JSON" | jq -r ".[] | select(.metadata.container.tags[] | contains(\"$TAG\")) | .id") - - if [ ! -z "$PACKAGE_VERSION_ID" ]; then - echo "Found image version ID: $PACKAGE_VERSION_ID" - - DELETE_RESPONSE=$(curl -X DELETE -s -H "Authorization: Bearer $TOKEN" \ - -H "Accept: application/vnd.github+json" \ - "https://api.github.com/orgs/$OWNER/packages/container/$PACKAGE_NAME/versions/$PACKAGE_VERSION_ID") - - if [ -z "$DELETE_RESPONSE" ]; then - echo "✅ Successfully deleted image version: $PACKAGE_VERSION_ID" - else - echo "❌ Failed to delete image version. Response: $DELETE_RESPONSE" - exit 1 - fi - else - echo "❌ Could not find image version with tag: $TAG" - echo "Available versions:" - echo "$VERSIONS_JSON" | jq -r '.[].names' - exit 1 - fi \ No newline at end of file + docker logs wescale \ No newline at end of file