Skip to content

Commit

Permalink
chore: get test pkgs from gh vars (#5552)
Browse files Browse the repository at this point in the history
  • Loading branch information
JashBook authored Oct 20, 2023
1 parent 14c9524 commit 3657e54
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
27 changes: 21 additions & 6 deletions .github/utils/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -615,15 +615,30 @@ set_size_label() {
fi
}

skip_check_pkg() {
check_pkg=${1:-""}
skip="false"
if [[ -z "$check_pkg" ]]; then
echo "$skip"
return
fi
for skip_pkg in $(echo "$IGNORE_PKGS" | sed 's/|/ /g'); do
if [[ "$check_pkg" == "$skip_pkg" ]]; then
skip="true"
break
fi
done
echo "$skip"
}

set_test_packages() {
pkgs_dir=$1
if ( find $pkgs_dir -maxdepth 1 -type f -name '*_test.go' ) > /dev/null; then
# skip check
case $pkgs_dir in
pkg/client)
return
;;
esac
skip_check=$(skip_check_pkg "$pkgs_dir")
if [[ "$skip_check" == "true" ]]; then
echo "skip check pkg:$pkgs_dir"
return
fi
if [[ -z "$TEST_PACKAGES" ]]; then
TEST_PACKAGES="{\"ops\":\"$pkgs_dir\"}"
else
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/cicd-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ jobs:
TEST_PACKAGES=`bash .github/utils/utils.sh --type 16 \
--trigger-type "$TRIGGER_MODE" \
--test-pkgs "pkg|apis|controllers|cmd|lorry" \
--test-check "mod-vendor|lint|staticcheck"`
--test-pkgs "${{ vars.TEST_PKGS }}" \
--test-check "${{ vars.TEST_CHECK }}" \
--ignore-pkgs "${{ vars.SKIP_CHECK_PKG }}"`
echo "$TEST_PACKAGES"
echo "matrix={\"include\":[$TEST_PACKAGES]}" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -109,7 +110,7 @@ jobs:
run: |
bash .github/utils/utils.sh --type 14 \
--file cover.out \
--ignore-pkgs "cmd/|pkg/cli|pkg/client|pkg/controller/model|controllers/k8score"
--ignore-pkgs "${{ vars.IGNORE_COVERAGE_PKG }}"
- name: upload coverage report
uses: codecov/codecov-action@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cicd-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ jobs:
run: |
bash .github/utils/utils.sh --type 14 \
--file cover.out \
--ignore-pkgs "cmd/|pkg/cli|pkg/client|pkg/controller/model|controllers/k8score"
--ignore-pkgs "${{ vars.IGNORE_COVERAGE_PKG }}"
- name: upload coverage report
uses: codecov/codecov-action@v3
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/release-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ jobs:
TEST_PACKAGES=`bash .github/utils/utils.sh --type 16 \
--trigger-type "[test]" \
--test-pkgs "internal|apis|controllers|cmd" \
--test-check "mod-vendor|lint"`
--test-pkgs "${{ vars.TEST_PKGS }}" \
--test-check "${{ vars.TEST_CHECK }}" \
--ignore-pkgs "${{ vars.SKIP_CHECK_PKG }}"`
echo "matrix={\"include\":[$TEST_PACKAGES]}" >> $GITHUB_OUTPUT
release-test:
Expand Down

0 comments on commit 3657e54

Please sign in to comment.