Skip to content

Commit

Permalink
Fix changed file detect issue (opea-project#1103)
Browse files Browse the repository at this point in the history
Signed-off-by: chensuyue <suyue.chen@intel.com>
  • Loading branch information
chensuyue authored Jan 3, 2025
1 parent f57e30d commit 6419ace
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/push-image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/scripts/get_test_matrix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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-)
Expand All @@ -110,15 +110,15 @@ 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
sleep 1s
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
Expand Down

0 comments on commit 6419ace

Please sign in to comment.