Skip to content

Commit

Permalink
chore: change pr pre check
Browse files Browse the repository at this point in the history
  • Loading branch information
JashBook committed Sep 12, 2024
1 parent c8b0b84 commit 7184e39
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 169 deletions.
107 changes: 5 additions & 102 deletions .github/workflows/cicd-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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: |
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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]')
Expand Down Expand Up @@ -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
Expand Down
44 changes: 4 additions & 40 deletions .github/workflows/cicd-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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]') }}
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
33 changes: 7 additions & 26 deletions .github/workflows/release-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7184e39

Please sign in to comment.