From 6d966ff5241b282387340162eba89daceee9480b Mon Sep 17 00:00:00 2001 From: Yutong Zhang <90831468+yutongzhang-microsoft@users.noreply.github.com> Date: Mon, 6 Jan 2025 15:06:57 +0800 Subject: [PATCH] Optimize feature folder retrieval in Impacted Area Based PR Testing (#16345) What is the motivation for this PR? In the Impacted Area Based PR testing, we identify the modified feature folders for the changes in a PR. Previously, the code retrieved the same feature folder multiple times if multiple modified scripts were located within it. However, we only need to retrieve each feature folder once. This PR optimizes the process to eliminate redundant retrievals. How did you do it? Implement a check to skip retrieval if the feature folder has already been processed. How did you verify/test it? I modified three scripts under the same feature folder and verified that the feature folder was only retrieved once --- .../impacted_area_testing/get-impacted-area.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.azure-pipelines/impacted_area_testing/get-impacted-area.yml b/.azure-pipelines/impacted_area_testing/get-impacted-area.yml index 4b133152156..6bee00aeee6 100644 --- a/.azure-pipelines/impacted_area_testing/get-impacted-area.yml +++ b/.azure-pipelines/impacted_area_testing/get-impacted-area.yml @@ -39,10 +39,12 @@ steps: FEATURE=$(echo "$FEATURE" | cut -d'/' -f1-2) fi + FEATURE=${FEATURE#tests/} + if [[ -z "$FINAL_FEATURES" ]]; then - FINAL_FEATURES="${FEATURE#tests/}" - else - FINAL_FEATURES="$FINAL_FEATURES,${FEATURE#tests/}" + FINAL_FEATURES="$FEATURE" + elif [[ ! "$FINAL_FEATURES" == *$FEATURE* ]]; then + FINAL_FEATURES="$FINAL_FEATURES,$FEATURE" fi # If changes related to other folders excpet tests, we also consider them as common part.