From 7184e397b763d91d4d433caf931893cd71857d44 Mon Sep 17 00:00:00 2001 From: huangzhangshu Date: Thu, 12 Sep 2024 12:51:39 +0800 Subject: [PATCH] chore: change pr pre check --- .github/workflows/cicd-pull-request.yml | 107 ++---------------------- .github/workflows/cicd-push.yml | 44 +--------- .github/workflows/release-version.yml | 33 ++------ Makefile | 2 +- 4 files changed, 17 insertions(+), 169 deletions(-) diff --git a/.github/workflows/cicd-pull-request.yml b/.github/workflows/cicd-pull-request.yml index 98e3ccf3d72..77103d5de58 100644 --- a/.github/workflows/cicd-pull-request.yml +++ b/.github/workflows/cicd-pull-request.yml @@ -19,7 +19,6 @@ jobs: runs-on: ubuntu-latest outputs: trigger-mode: ${{ steps.get_trigger_mode.outputs.trigger_mode }} - matrix: ${{ steps.get_trigger_mode.outputs.matrix }} git-commit: ${{ steps.get_git_info.outputs.git_commit }} git-version: ${{ steps.get_git_info.outputs.git_version }} steps: @@ -48,15 +47,6 @@ jobs: echo $TRIGGER_MODE echo trigger_mode=$TRIGGER_MODE >> $GITHUB_OUTPUT - TEST_PACKAGES=`bash .github/utils/utils.sh --type 16 \ - --trigger-type "$TRIGGER_MODE" \ - --test-pkgs "${{ vars.TEST_PKGS }}" \ - --test-check "${{ vars.TEST_CHECK }}" \ - --test-pkgs-first "${{ vars.TEST_PKGS_FIRST }}" \ - --ignore-pkgs "${{ vars.SKIP_CHECK_PKG }}"` - echo "$TEST_PACKAGES" - echo "matrix={\"include\":[$TEST_PACKAGES]}" >> $GITHUB_OUTPUT - - name: get git info id: get_git_info run: | @@ -65,54 +55,14 @@ jobs: echo git_commit=$GIT_COMMIT >> $GITHUB_OUTPUT echo git_version=$GIT_VERSION >> $GITHUB_OUTPUT - test-parallel: - name: test - needs: trigger-mode - if: ${{ contains(needs.trigger-mode.outputs.trigger-mode, '[test]') && github.event.pull_request.head.repo.full_name == github.repository }} - runs-on: ubuntu-latest - strategy: - fail-fast: true - matrix: ${{ fromJSON(needs.trigger-mode.outputs.matrix) }} - steps: - - uses: actions/checkout@v4 - - name: install lib - run: | - sudo rm /etc/apt/sources.list.d/microsoft-prod.list - sudo apt-get update - sudo apt-get install -y --no-install-recommends \ - libbtrfs-dev \ - libdevmapper-dev - - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: "${{ env.GO_VERSION }}" - - - name: Install golangci-lint - if: matrix.ops == 'lint' - run: | - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2 - - - name: make ${{ matrix.ops }} - if: ${{ ! contains(matrix.ops, '/') }} - run: | - make ${{ matrix.ops }} - - - name: make test ${{ matrix.ops }} - if: ${{ contains(matrix.ops, '/') }} - run: | - if [[ -d "./${{ matrix.ops }}" ]]; then - make test TEST_PACKAGES=./${{ matrix.ops }}/... - fi - pr-pre-check: needs: trigger-mode - if: ${{ contains(needs.trigger-mode.outputs.trigger-mode, '[test]') && github.event.pull_request.head.repo.full_name != github.repository }} + if: ${{ contains(needs.trigger-mode.outputs.trigger-mode, '[test]') }} runs-on: ubuntu-latest strategy: fail-fast: true matrix: - ops: [ 'manifests', 'mod-vendor', 'generate', 'lint', 'staticcheck' ] + ops: [ 'manifests', 'mod-vendor', 'generate', 'lint', 'staticcheck', 'test' ] steps: - uses: actions/checkout@v4 - name: install lib @@ -143,25 +93,15 @@ jobs: exit 1 fi - pr-make-test: - needs: trigger-mode - if: ${{ contains(needs.trigger-mode.outputs.trigger-mode, '[test]') && github.event.pull_request.head.repo.full_name != github.repository }} - outputs: - runner-name: ${{ steps.get_runner_name.outputs.runner_name }} - runs-on: [ self-hosted, gke-runner-go1.21 ] - steps: - - uses: actions/checkout@v4 - - name: make test - run: | - make test - - name: ignore cover pkgs + if: matrix.ops == 'test' run: | bash .github/utils/utils.sh --type 14 \ --file cover.out \ --ignore-pkgs "${{ vars.IGNORE_COVERAGE_PKG }}" - name: upload coverage report + if: matrix.ops == 'test' uses: codecov/codecov-action@v3 continue-on-error: true with: @@ -171,25 +111,6 @@ jobs: name: codecov-report verbose: true - - name: kill kube-apiserver and etcd - id: get_runner_name - if: ${{ always() }} - run: | - echo runner_name=${RUNNER_NAME} >> $GITHUB_OUTPUT - bash .github/utils/utils.sh --type 8 - - remove-runner: - needs: [ trigger-mode, pr-make-test ] - runs-on: ubuntu-latest - if: ${{ contains(needs.trigger-mode.outputs.trigger-mode, '[test]') && github.event.pull_request.head.repo.full_name != github.repository && always() }} - steps: - - uses: actions/checkout@v4 - - name: remove runner - run: | - bash .github/utils/utils.sh --type 9 \ - --github-token ${{ env.GITHUB_TOKEN }} \ - --runner-name ${{ needs.pr-make-test.outputs.runner-name }} - check-image: needs: trigger-mode if: contains(needs.trigger-mode.outputs.trigger-mode, '[docker]') @@ -255,35 +176,17 @@ jobs: pr-check: name: make test - needs: [ trigger-mode, test-parallel, pr-pre-check, pr-make-test, - check-image, check-tools-image, check-datascript-image, check-dataprotection-image, check-helm ] + needs: [ trigger-mode, pr-pre-check, check-image, check-tools-image, check-datascript-image, check-dataprotection-image, check-helm ] if: ${{ github.event.action == 'labeled' && (github.event.label.name == 'approved' || github.event.label.name == 'pre-approve') && always() }} runs-on: ubuntu-latest steps: - - name: test parallel check - if: github.event.pull_request.head.repo.full_name == github.repository - run: | - if [[ "${{ needs.test-parallel.result }}" == "failure" || "${{ needs.test-parallel.result }}" == "cancelled" ]]; then - echo "test parallel fail" - exit 1 - fi - - name: pr pre check - if: github.event.pull_request.head.repo.full_name != github.repository run: | if [[ "${{ needs.pr-pre-check.result }}" == "failure" || "${{ needs.pr-pre-check.result }}" == "cancelled" ]]; then echo "make test fail" exit 1 fi - - name: make test check - if: github.event.pull_request.head.repo.full_name != github.repository - run: | - if [[ "${{ needs.pr-make-test.result }}" == "failure" || "${{ needs.pr-make-test.result }}" == "cancelled" ]]; then - echo "make test fail" - exit 1 - fi - - name: release image check run: | if [[ "${{ needs.check-image.result }}" == "failure" || "${{ needs.check-image.result }}" == "cancelled" ]]; then diff --git a/.github/workflows/cicd-push.yml b/.github/workflows/cicd-push.yml index fb4ea0886e5..eb531e97775 100644 --- a/.github/workflows/cicd-push.yml +++ b/.github/workflows/cicd-push.yml @@ -105,7 +105,7 @@ jobs: strategy: fail-fast: true matrix: - ops: [ 'manifests', 'mod-vendor', 'generate', 'lint', 'staticcheck' ] + ops: [ 'manifests', 'mod-vendor', 'generate', 'lint', 'staticcheck', 'test' ] steps: - uses: actions/checkout@v4 - name: install lib @@ -136,25 +136,15 @@ jobs: exit 1 fi - push-make-test: - needs: trigger-mode - runs-on: [self-hosted, gke-runner-go1.21] - if: contains(needs.trigger-mode.outputs.trigger-mode, '[test]') - outputs: - runner-name: ${{ steps.get_runner_name.outputs.runner_name }} - steps: - - uses: actions/checkout@v4 - - name: make test - run: | - make test - - name: ignore cover pkgs + if: matrix.ops == 'test' run: | bash .github/utils/utils.sh --type 14 \ --file cover.out \ --ignore-pkgs "${{ vars.IGNORE_COVERAGE_PKG }}" - name: upload coverage report + if: matrix.ops == 'test' uses: codecov/codecov-action@v3 continue-on-error: true with: @@ -164,25 +154,6 @@ jobs: name: codecov-report verbose: true - - name: kill kube-apiserver and etcd - id: get_runner_name - if: ${{ always() }} - run: | - echo runner_name=${RUNNER_NAME} >> $GITHUB_OUTPUT - bash .github/utils/utils.sh --type 8 - - remove-runner: - needs: [ trigger-mode, push-make-test ] - runs-on: ubuntu-latest - if: ${{ contains(needs.trigger-mode.outputs.trigger-mode, '[test]') && always() }} - steps: - - uses: actions/checkout@v4 - - name: remove runner - run: | - bash .github/utils/utils.sh --type 9 \ - --github-token "${{ env.GITHUB_TOKEN }}" \ - --runner-name ${{ needs.push-make-test.outputs.runner-name }} - check-image: needs: trigger-mode if: ${{ contains(needs.trigger-mode.outputs.trigger-mode, '[docker]') }} @@ -312,7 +283,7 @@ jobs: push-check: name: make-test - needs: [ trigger-mode, push-pre-check, push-make-test, check-image, check-tools-image, + needs: [ trigger-mode, push-pre-check, check-image, check-tools-image, check-datascript-image, check-dataprotection-image, check-helm, apis-doc, check-license-header ] if: ${{ always() }} runs-on: ubuntu-latest @@ -324,13 +295,6 @@ jobs: exit 1 fi - - name: make test check - run: | - if [[ "${{ needs.push-make-test.result }}" == "failure" || "${{ needs.push-make-test.result }}" == "cancelled" ]]; then - echo "make test fail" - exit 1 - fi - - name: release image check run: | if [[ "${{ needs.check-image.result }}" == "failure" || "${{ needs.check-image.result }}" == "cancelled" ]]; then diff --git a/.github/workflows/release-version.yml b/.github/workflows/release-version.yml index 03ddcaf8250..290e0a6e067 100644 --- a/.github/workflows/release-version.yml +++ b/.github/workflows/release-version.yml @@ -23,29 +23,12 @@ jobs: APECD_REF: "v0.1.38" secrets: inherit - trigger-mode: - runs-on: ubuntu-latest - outputs: - matrix: ${{ steps.get_trigger_mode.outputs.matrix }} - steps: - - uses: actions/checkout@v4 - - name: release message - id: get_trigger_mode - run: | - TEST_PACKAGES=`bash .github/utils/utils.sh --type 16 \ - --trigger-type "[test]" \ - --test-pkgs "${{ vars.TEST_PKGS }}" \ - --test-check "${{ vars.TEST_CHECK }}" \ - --test-pkgs-first "${{ vars.TEST_PKGS_FIRST }}" \ - --ignore-pkgs "${{ vars.SKIP_CHECK_PKG }}"` - echo "matrix={\"include\":[$TEST_PACKAGES]}" >> $GITHUB_OUTPUT - release-test: - needs: [ trigger-mode ] runs-on: ubuntu-latest strategy: fail-fast: true - matrix: ${{ fromJSON(needs.trigger-mode.outputs.matrix) }} + matrix: + ops: [ 'manifests', 'mod-vendor', 'generate', 'lint', 'staticcheck', 'test' ] steps: - uses: actions/checkout@v4 - name: install lib @@ -67,15 +50,13 @@ jobs: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2 - name: make ${{ matrix.ops }} - if: ${{ ! contains(matrix.ops, '/') }} run: | make ${{ matrix.ops }} - - - name: make test ${{ matrix.ops }} - if: ${{ contains(matrix.ops, '/') }} - run: | - if [[ -d "./${{ matrix.ops }}" ]]; then - make test TEST_PACKAGES=./${{ matrix.ops }}/... + FILE_CHANGES=`git diff --name-only ${{ github.sha }}` + if [[ ("${{ matrix.ops }}" == 'generate' || "${{ matrix.ops }}" == 'manifests') && -n "$FILE_CHANGES" ]]; then + echo $FILE_CHANGES + echo "make "${{ matrix.ops }}" causes inconsistent files" + exit 1 fi release-branch: diff --git a/Makefile b/Makefile index 2c4273ef198..d995d6a6523 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ # Variables # ################################################################################ APP_NAME = kubeblocks -VERSION ?= 0.8.0-alpha.0 +VERSION ?= 0.9.0 GITHUB_PROXY ?= INIT_ENV ?= false TEST_TYPE ?= wesql