From 6419ace56c8ca0c8f3ed8ea66d1ee7481bc85dc0 Mon Sep 17 00:00:00 2001 From: "chen, suyue" Date: Fri, 3 Jan 2025 11:24:19 +0800 Subject: [PATCH] Fix changed file detect issue (#1103) Signed-off-by: chensuyue --- .github/workflows/push-image-build.yml | 4 ++-- .github/workflows/scripts/get_test_matrix.sh | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/push-image-build.yml b/.github/workflows/push-image-build.yml index ca58f34543..503907770d 100644 --- a/.github/workflows/push-image-build.yml +++ b/.github/workflows/push-image-build.yml @@ -33,8 +33,8 @@ jobs: run: | base_commit=$(git rev-parse HEAD~1) merged_commit=$(git log -1 --format='%H') - changed_files="$(git diff --name-only ${base_commit} ${merged_commit} | grep 'comps/' | grep -vE '*.md|*.txt|comps/cores')" || true - services=$(printf '%s\n' "${changed_files[@]}" | cut -d'/' -f2 | grep -vE '*.py' | sort -u | jq -R '.' | jq -sc '.') || true + changed_files="$(git diff --name-only ${base_commit} ${merged_commit} | grep 'comps/' | grep -vE '\.md|\.txt|comps/cores')" || true + services=$(printf '%s\n' "${changed_files[@]}" | cut -d'/' -f2 | grep -vE '\.py' | sort -u | jq -R '.' | jq -sc '.') || true echo "services=$services" echo "services=$services" >> $GITHUB_OUTPUT diff --git a/.github/workflows/scripts/get_test_matrix.sh b/.github/workflows/scripts/get_test_matrix.sh index d58b4fae43..9dc3aa5975 100644 --- a/.github/workflows/scripts/get_test_matrix.sh +++ b/.github/workflows/scripts/get_test_matrix.sh @@ -16,14 +16,14 @@ function find_test_1() { local n=$2 local all_service=$3 - common_file_change=$(printf '%s\n' "${changed_files[@]}"| grep ${pre_service_path} | cut -d'/' -f$n | grep -E '*.py' | grep -vE '__init__.py|version.py' | sort -u) || true + common_file_change=$(printf '%s\n' "${changed_files[@]}"| grep ${pre_service_path} | cut -d'/' -f$n | grep -E '\.py' | grep -vE '__init__.py|version.py' | sort -u) || true if [ "$common_file_change" ] || [ "$all_service" = "true" ]; then # if common files changed, run all services - services=$(ls ${pre_service_path} | cut -d'/' -f$n | grep -vE '*.md|*.py|*.sh|*.yaml|*.yml|*.pdf' | sort -u) || true + services=$(ls ${pre_service_path} | cut -d'/' -f$n | grep -vE '\.md|\.py|\.sh|\.yaml|\.yml|\.pdf' | sort -u) || true all_service="true" else # if specific service files changed, only run the specific service - services=$(printf '%s\n' "${changed_files[@]}"| grep ${pre_service_path} | cut -d'/' -f$n | grep -vE '*.py|*.sh|*.yaml|*.yml|*.pdf' | sort -u) || true + services=$(printf '%s\n' "${changed_files[@]}"| grep ${pre_service_path} | cut -d'/' -f$n | grep -vE '\.py|\.sh|\.yaml|\.yml|\.pdf' | sort -u) || true fi for service in ${services}; do @@ -99,7 +99,7 @@ function _fill_in_matrix() { # add test case when test scripts code change function find_test_2() { - test_files=$(printf '%s\n' "${changed_files[@]}" | grep -E "*.sh") || true + test_files=$(printf '%s\n' "${changed_files[@]}" | grep -E "\.sh") || true for test_file in ${test_files}; do if [ -f $test_file ]; then _service=$(echo $test_file | cut -d'/' -f3 | cut -d'.' -f1 | cut -c6-) @@ -110,7 +110,7 @@ function find_test_2() { function main() { - changed_files=$(printf '%s\n' "${changed_files_full[@]}" | grep 'comps/' | grep -vE '*.md|comps/cores|comps/3rd_parties|deployment|*.yaml') || true + changed_files=$(printf '%s\n' "${changed_files_full[@]}" | grep 'comps/' | grep -vE '\.md|comps/cores|comps/3rd_parties|deployment|\.yaml') || true echo "===========start find_test_1============" echo "changed_files=${changed_files}" find_test_1 "comps" 2 false @@ -118,7 +118,7 @@ function main() { echo "run_matrix=${run_matrix}" echo "===========finish find_test_1============" - changed_files=$(printf '%s\n' "${changed_files_full[@]}" | grep 'tests/' | grep -vE '*.md|*.txt|tests/cores') || true + changed_files=$(printf '%s\n' "${changed_files_full[@]}" | grep 'tests/' | grep -vE '\.md|\.txt|tests/cores') || true echo "===========start find_test_2============" echo "changed_files=${changed_files}" find_test_2