From 907b9bde0206343f5c1ba16a6848ebda7ef607bd Mon Sep 17 00:00:00 2001 From: Emma Doyle Date: Sun, 19 Mar 2023 10:32:54 -0400 Subject: [PATCH] fix-config-changes: Debug env var (#36) * fix-config-changes: Debug env var * fix-config-changes: Debug * fix-config-changes: Compare to 1 * fix-config-changes: Test alpha * fix-config-changes: Change config * fix-config-changes: Config changes -> false * fix-config-changes: Works * fix-config-changes: Passing workflow * fix-config-changes: Undo scripts change --------- Co-authored-by: Emma Doyle --- src/scripts/filter.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/scripts/filter.sh b/src/scripts/filter.sh index c1fc4ea..b495e26 100755 --- a/src/scripts/filter.sh +++ b/src/scripts/filter.sh @@ -33,14 +33,14 @@ for f in .circleci/*.yaml; do done # If auto-detecting is enabled (or modules aren't set), check for configs in .circleci/. -if [ ! "$SH_AUTO_DETECT" ] || [ "$SH_MODULES" = "" ]; then +if [ "$SH_AUTO_DETECT" -eq 1 ] || [ "$SH_MODULES" = "" ]; then # We need to determine what the modules are, ignoring SH_MODULES if it is set. SH_MODULES="$(find .circleci/ -type f -name "*.yml" | grep -oP "(?<=.circleci/).*(?=.yml)" | grep -v config)" printf "Auto-detected the following modules:\\n\\n%s\\n\\n" "$SH_MODULES" fi # Add each module to `modules-filtered` if 1) `force-all` is set to `true`, or 2) there is a diff against master at HEAD, or 3) no workflow runs have occurred on the default branch for this project in the past $SH_REPORTING_WINDOW days. -if [ ! "$SH_FORCE_ALL" ] || { [ "$SH_REPORTING_WINDOW" != "" ] && [ "$(curl -s -X GET --url "https://circleci.com/api/v2/insights/${SH_PROJECT_TYPE}/${_CIRCLE_ORGANIZATION}/${CIRCLE_PROJECT_REPONAME}/workflows?reporting-window=${SH_REPORTING_WINDOW}" --header "Circle-Token: ${SH_CIRCLE_TOKEN}" | jq -r "[ .items[].name ] | length")" -eq "0" ]; }; then +if [ "$SH_FORCE_ALL" -eq 1 ] || { [ "$SH_REPORTING_WINDOW" != "" ] && [ "$(curl -s -X GET --url "https://circleci.com/api/v2/insights/${SH_PROJECT_TYPE}/${_CIRCLE_ORGANIZATION}/${CIRCLE_PROJECT_REPONAME}/workflows?reporting-window=${SH_REPORTING_WINDOW}" --header "Circle-Token: ${SH_CIRCLE_TOKEN}" | jq -r "[ .items[].name ] | length")" -eq "0" ]; }; then printf "Running all workflows.\\n" echo "$SH_MODULES" | awk NF | while read -r module; do module_dots="$(sed 's@\/@\.@g' <<< "$module")" @@ -79,12 +79,12 @@ else fi if [ "$CIRCLE_BRANCH" = "$SH_DEFAULT_BRANCH" ]; then - if [ ! "$SH_FORCE_ALL" ] || [ "$(git diff-tree --no-commit-id --name-only -r HEAD~"$SH_SQUASH_MERGE_LOOKBEHIND" "$SH_DEFAULT_BRANCH" "$module_dots" | awk NF | wildmatch -c ".circleci/$SH_ROOT_CONFIG.ignore")" != "" ] || ([ "$(git diff-tree --no-commit-id --name-only -r HEAD~"$SH_SQUASH_MERGE_LOOKBEHIND" "$SH_DEFAULT_BRANCH" ".circleci/$SH_ROOT_CONFIG.yml" | awk NF)" != "" ] && "$SH_INCLUDE_CONFIG_CHANGES"); then + if [ "$SH_FORCE_ALL" -eq 1 ] || [ "$(git diff-tree --no-commit-id --name-only -r HEAD~"$SH_SQUASH_MERGE_LOOKBEHIND" "$SH_DEFAULT_BRANCH" "$module_dots" | awk NF | wildmatch -c ".circleci/$SH_ROOT_CONFIG.ignore")" != "" ] || { [ "$(git diff-tree --no-commit-id --name-only -r HEAD~"$SH_SQUASH_MERGE_LOOKBEHIND" "$SH_DEFAULT_BRANCH" ".circleci/$SH_ROOT_CONFIG.yml" | awk NF)" != "" ] && [ "$SH_INCLUDE_CONFIG_CHANGES" -eq 1 ]; }; then echo "$module_dots" >> "$SH_MODULES_FILTERED" printf "%s\\n" "$module_slashes" fi else - if [ ! "$SH_FORCE_ALL" ] || [ "$(git diff-tree --no-commit-id --name-only -r HEAD "$SH_DEFAULT_BRANCH" "$module_dots" | awk NF | wildmatch -c ".circleci/$SH_ROOT_CONFIG.ignore")" != "" ] || ([ "$(git diff-tree --no-commit-id --name-only -r HEAD "$SH_DEFAULT_BRANCH" ".circleci/$SH_ROOT_CONFIG.yml" | awk NF)" != "" ] && "$SH_INCLUDE_CONFIG_CHANGES"); then + if [ "$SH_FORCE_ALL" -eq 1 ] || [ "$(git diff-tree --no-commit-id --name-only -r HEAD "$SH_DEFAULT_BRANCH" "$module_dots" | awk NF | wildmatch -c ".circleci/$SH_ROOT_CONFIG.ignore")" != "" ] || { [ "$(git diff-tree --no-commit-id --name-only -r HEAD "$SH_DEFAULT_BRANCH" ".circleci/$SH_ROOT_CONFIG.yml" | awk NF)" != "" ] && [ "$SH_INCLUDE_CONFIG_CHANGES" -eq 1 ]; }; then echo "$module_dots" >> "$SH_MODULES_FILTERED" printf "%s\\n" "$module_slashes" fi @@ -99,12 +99,12 @@ else fi if [ "$CIRCLE_BRANCH" = "$SH_DEFAULT_BRANCH" ]; then - if [ ! "$SH_FORCE_ALL" ] || [ "$(git diff-tree --no-commit-id --name-only -r HEAD~"$SH_SQUASH_MERGE_LOOKBEHIND" "$SH_DEFAULT_BRANCH" "$module_slashes" | awk NF | wildmatch -c ".circleci/${module_dots}.ignore")" != "" ] || ([ "$(git diff-tree --no-commit-id --name-only -r HEAD~"$SH_SQUASH_MERGE_LOOKBEHIND" "$SH_DEFAULT_BRANCH" .circleci/"$module_dots".yml | awk NF)" != "" ] && "$SH_INCLUDE_CONFIG_CHANGES"); then + if [ "$SH_FORCE_ALL" -eq 1 ] || [ "$(git diff-tree --no-commit-id --name-only -r HEAD~"$SH_SQUASH_MERGE_LOOKBEHIND" "$SH_DEFAULT_BRANCH" "$module_slashes" | awk NF | wildmatch -c ".circleci/${module_dots}.ignore")" != "" ] || { [ "$(git diff-tree --no-commit-id --name-only -r HEAD~"$SH_SQUASH_MERGE_LOOKBEHIND" "$SH_DEFAULT_BRANCH" .circleci/"$module_dots".yml | awk NF)" != "" ] && [ "$SH_INCLUDE_CONFIG_CHANGES" -eq 1 ]; }; then echo "$module_dots" >> "$SH_MODULES_FILTERED" printf "%s\\n" "$module_slashes" fi else - if [ ! "$SH_FORCE_ALL" ] || [ "$(git diff-tree --no-commit-id --name-only -r HEAD "$SH_DEFAULT_BRANCH" "$module_slashes" | awk NF | wildmatch -c ".circleci/${module_dots}.ignore")" != "" ] || ([ "$(git diff-tree --no-commit-id --name-only -r HEAD "$SH_DEFAULT_BRANCH" .circleci/"$module_dots".yml | awk NF)" != "" ] && "$SH_INCLUDE_CONFIG_CHANGES"); then + if [ "$SH_FORCE_ALL" -eq 1 ] || [ "$(git diff-tree --no-commit-id --name-only -r HEAD "$SH_DEFAULT_BRANCH" "$module_slashes" | awk NF | wildmatch -c ".circleci/${module_dots}.ignore")" != "" ] || { [ "$(git diff-tree --no-commit-id --name-only -r HEAD "$SH_DEFAULT_BRANCH" .circleci/"$module_dots".yml | awk NF)" != "" ] && [ "$SH_INCLUDE_CONFIG_CHANGES" -eq 1 ]; }; then echo "$module_dots" >> "$SH_MODULES_FILTERED" printf "%s\\n" "$module_slashes" fi