From 983ca7196c5fab1874a6afa96d7c52ddea7aa909 Mon Sep 17 00:00:00 2001 From: Hang Date: Thu, 7 Nov 2024 15:04:34 +0800 Subject: [PATCH] test --- .github/workflows/push-release.yml | 225 +++++++++++++++++++---------- .github/workflows/unit-test.yml | 10 +- 2 files changed, 151 insertions(+), 84 deletions(-) diff --git a/.github/workflows/push-release.yml b/.github/workflows/push-release.yml index 59610add839..3306bf1443f 100644 --- a/.github/workflows/push-release.yml +++ b/.github/workflows/push-release.yml @@ -253,76 +253,76 @@ jobs: retention-days: 4 overwrite: false build-server-arm64: - # runs-on: test-runner-dind - runs-on: [self-hosted, Linux, ARM64] - # runs-on: runs-on,runner=4cpu-${{ matrix.os }}-${{ matrix.arch }},image=ubuntu22-full-${{ matrix.arch }},run-id=${{ github.run_id }} - strategy: - matrix: - os: [linux] - arch: [arm64] - env: - ARCH: ${{ matrix.arch }} - steps: - - name: Arch environment variable - shell: bash - run: | - if [[ "$ARCH" == "x64" ]]; then - echo "ARCH=amd64" >> $GITHUB_ENV - fi - - name: Checkout code - uses: actions/checkout@v4 - - name: install yq - shell: bash - run: sudo snap install yq - - name: Setup Environment Variables - uses: ./.github/actions/setup-tag-env - - id: env - name: Setup Dependencies Env Variables - uses: ./.github/actions/setup-build-env - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.IMAGE }} - flavor: | - latest=false - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Create k3s images file - uses: ./.github/actions/k3s-images - with: - k3s_version: ${{ steps.env.outputs.CATTLE_K3S_VERSION }} - - name: Download data.json - run: curl -sLf https://releases.rancher.com/kontainer-driver-metadata/${{ steps.env.outputs.CATTLE_KDM_BRANCH }}/data.json > ./data.json - - name: Build and export server - id: build - uses: docker/build-push-action@v5 - with: - push: false - build-args: | - "VERSION=${{ env.TAG }}" - "COMMIT=${{ env.COMMIT }}" - "RKE_VERSION=${{ steps.env.outputs.RKE_VERSION }}" - "ARCH=${{ env.ARCH }}" - "CATTLE_RANCHER_WEBHOOK_VERSION=${{ steps.env.outputs.CATTLE_RANCHER_WEBHOOK_VERSION }}" - "CATTLE_CSP_ADAPTER_MIN_VERSION=${{ steps.env.outputs.CATTLE_CSP_ADAPTER_MIN_VERSION }}" - "CATTLE_FLEET_VERSION=${{ steps.env.outputs.CATTLE_FLEET_VERSION }}" - tags: ${{ env.IMAGE }}:${{ env.TAG }}-${{ env.ARCH }} - context: . - platforms: "${{ matrix.os }}/${{ env.ARCH }}" - file: ./package/Dockerfile - labels: "${{ steps.meta.outputs.labels }}" - outputs: type=docker,dest=/tmp/rancher-${{ matrix.os }}-${{ env.ARCH }}.tar - - name: Upload image - uses: actions/upload-artifact@v4 - with: - name: "rancher-${{ matrix.os }}-${{ env.ARCH }}" - path: /tmp/rancher-${{ matrix.os }}-${{ env.ARCH }}.tar - if-no-files-found: error - retention-days: 4 - overwrite: false + # runs-on: test-runner-dind + runs-on: [self-hosted, Linux, ARM64] + # runs-on: runs-on,runner=4cpu-${{ matrix.os }}-${{ matrix.arch }},image=ubuntu22-full-${{ matrix.arch }},run-id=${{ github.run_id }} + strategy: + matrix: + os: [linux] + arch: [arm64] + env: + ARCH: ${{ matrix.arch }} + steps: + - name: Arch environment variable + shell: bash + run: | + if [[ "$ARCH" == "x64" ]]; then + echo "ARCH=amd64" >> $GITHUB_ENV + fi + - name: Checkout code + uses: actions/checkout@v4 + - name: install yq + shell: bash + run: sudo snap install yq + - name: Setup Environment Variables + uses: ./.github/actions/setup-tag-env + - id: env + name: Setup Dependencies Env Variables + uses: ./.github/actions/setup-build-env + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.IMAGE }} + flavor: | + latest=false + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Create k3s images file + uses: ./.github/actions/k3s-images + with: + k3s_version: ${{ steps.env.outputs.CATTLE_K3S_VERSION }} + - name: Download data.json + run: curl -sLf https://releases.rancher.com/kontainer-driver-metadata/${{ steps.env.outputs.CATTLE_KDM_BRANCH }}/data.json > ./data.json + - name: Build and export server + id: build + uses: docker/build-push-action@v5 + with: + push: false + build-args: | + "VERSION=${{ env.TAG }}" + "COMMIT=${{ env.COMMIT }}" + "RKE_VERSION=${{ steps.env.outputs.RKE_VERSION }}" + "ARCH=${{ env.ARCH }}" + "CATTLE_RANCHER_WEBHOOK_VERSION=${{ steps.env.outputs.CATTLE_RANCHER_WEBHOOK_VERSION }}" + "CATTLE_CSP_ADAPTER_MIN_VERSION=${{ steps.env.outputs.CATTLE_CSP_ADAPTER_MIN_VERSION }}" + "CATTLE_FLEET_VERSION=${{ steps.env.outputs.CATTLE_FLEET_VERSION }}" + tags: ${{ env.IMAGE }}:${{ env.TAG }}-${{ env.ARCH }} + context: . + platforms: "${{ matrix.os }}/${{ env.ARCH }}" + file: ./package/Dockerfile + labels: "${{ steps.meta.outputs.labels }}" + outputs: type=docker,dest=/tmp/rancher-${{ matrix.os }}-${{ env.ARCH }}.tar + - name: Upload image + uses: actions/upload-artifact@v4 + with: + name: "rancher-${{ matrix.os }}-${{ env.ARCH }}" + path: /tmp/rancher-${{ matrix.os }}-${{ env.ARCH }}.tar + if-no-files-found: error + retention-days: 4 + overwrite: false build-agent-arm64: needs: [build-server-arm64] strategy: @@ -447,7 +447,7 @@ jobs: # docker push ${{ env.REGISTRY }}/${{ env.IMAGE_AGENT }}:${{ env.TAG }}-windows-${{ matrix.version }} # shell: bash push-images: - needs: [unit-tests, build-agent-amd64, build-agent-arm64] + needs: [build-agent-amd64, build-agent-arm64] strategy: matrix: os: [linux] @@ -577,8 +577,8 @@ jobs: # docker manifest push ${{ env.REGISTRY }}/${{ env.IMAGE_AGENT }}:${{ env.TAG }} docker buildx imagetools create -t ${{ env.REGISTRY }}/${{ env.IMAGE_AGENT }}:${{ env.TAG }} \ - --append ${{ env.REGISTRY }}/${{ env.IMAGE_AGENT }}:${{ env.TAG }}-amd64 \ - --append ${{ env.REGISTRY }}/${{ env.IMAGE_AGENT }}:${{ env.TAG }}-arm64 + ${{ env.REGISTRY }}/${{ env.IMAGE_AGENT }}:${{ env.TAG }}-amd64 \ + ${{ env.REGISTRY }}/${{ env.IMAGE_AGENT }}:${{ env.TAG }}-arm64 if [[ "${{ github.ref_name }}" == release/v* ]]; then # docker manifest create ${{ env.REGISTRY }}/${{ env.IMAGE_AGENT }}:${{ env.HEAD_TAG }} \ @@ -587,13 +587,13 @@ jobs: # docker manifest push ${{ env.REGISTRY }}/${{ env.IMAGE_AGENT }}:${{ env.HEAD_TAG }} docker buildx imagetools create -t ${{ env.REGISTRY }}/${{ env.IMAGE_AGENT }}:${{ env.HEAD_TAG }} \ - --append ${{ env.REGISTRY }}/${{ env.IMAGE_AGENT }}:${{ env.TAG }}-amd64 \ - --append ${{ env.REGISTRY }}/${{ env.IMAGE_AGENT }}:${{ env.TAG }}-arm64 + ${{ env.REGISTRY }}/${{ env.IMAGE_AGENT }}:${{ env.TAG }}-amd64 \ + ${{ env.REGISTRY }}/${{ env.IMAGE_AGENT }}:${{ env.TAG }}-arm64 fi - name: Inspect image run: | docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.IMAGE_AGENT }}:${{ env.TAG }} - build-installer: + build-installer-amd64: needs: [build-publish-chart, merge-server-manifest] strategy: matrix: @@ -659,10 +659,77 @@ jobs: platforms: "${{ matrix.os }}/${{ env.ARCH }}" file: ./package/Dockerfile.installer labels: "${{ steps.meta.outputs.labels }}" + build-installer-arm64: + needs: [build-publish-chart, merge-server-manifest] + strategy: + matrix: + os: [linux] + arch: [arm64] + # runs-on: test-runner-dind + runs-on: [self-hosted, Linux, ARM64] + # runs-on: runs-on,runner=4cpu-${{ matrix.os }}-${{ matrix.arch }},image=ubuntu22-full-${{ matrix.arch }},run-id=${{ github.run_id }} + permissions: + contents: read + id-token: write + env: + ARCH: ${{ matrix.arch }} + steps: + - name: Environment variables + shell: bash + run: | + if [[ "$ARCH" == "x64" ]]; then + echo "ARCH=amd64" >> $GITHUB_ENV + fi + - name: Checkout code + uses: actions/checkout@v4 + - name: Setup Environment Variables + uses: ./.github/actions/setup-tag-env + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.IMAGE }} + flavor: | + latest=false + # - name: Load Secrets from Vault + # uses: rancher-eio/read-vault-secrets@main + # with: + # secrets: | + # secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKER_USERNAME ; + # secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKER_PASSWORD + - name: Docker Registry Login + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Download chart + uses: actions/download-artifact@v4 + with: + name: chart + path: ./chart + - name: Build and export agent + id: build + uses: docker/build-push-action@v5 + with: + push: true + build-args: | + "VERSION=${{ env.TAG }}" + "ARCH=${{ matrix.arch }}" + "RANCHER_TAG=${{ env.TAG }}" + "RANCHER_REPO=${{ env.REPOSITORY_OWNER }}" + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_INSTALLER }}:${{ env.TAG }}-${{ env.ARCH }} + context: . + platforms: "${{ matrix.os }}/${{ env.ARCH }}" + file: ./package/Dockerfile.installer + labels: "${{ steps.meta.outputs.labels }}" merge-installer-manifest: runs-on: test-runner-dind # runs-on: runs-on,runner=2cpu-linux-x64,image=ubuntu22-full-x64,run-id=${{ github.run_id }} - needs: [build-installer] + needs: [build-installer-amd64, build-installer-arm64] permissions: contents: read id-token: write @@ -791,9 +858,9 @@ jobs: gh release edit -R ${{ github.repository }} ${{ env.TAG }} --notes "$NOTES" docker-image-digests: if: github.event_name == 'push' && contains(github.ref, 'tags/') # Only run on tag - runs-on: test-runner-default + runs-on: test-runner-1 # runs-on: org-${{ github.repository_owner_id }}-amd64-k8s - # container: registry.suse.com/bci/bci-base:latest + container: registry.suse.com/bci/bci-base:latest needs: [create-images-files, merge-agent-manifest, merge-server-manifest] permissions: contents: write diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 0f9cf00e935..3c90c2abd91 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -4,7 +4,7 @@ jobs: unit-test: env: GOLANG_VERSION: '1.22' - runs-on: test-runner-default + runs-on: ubuntu-latest timeout-minutes: 60 steps: # - name: Install tools @@ -18,10 +18,10 @@ jobs: # git config --global --add safe.directory '*' - name: Checkout code uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: "${{ env.GOLANG_VERSION }}" + # - name: Set up Go + # uses: actions/setup-go@v5 + # with: + # go-version: "${{ env.GOLANG_VERSION }}" - name: Run unit tests run: go test -cover -tags=test ./pkg/...