mirror of https://github.com/status-im/consul.git
ci: fix file parsing in conditional-skip script (#21343)
Ensure files are split rather than compared as a single list for accuracy and easier debugging. Also adopt minor changes and file name from introduction of similar check `consul-dataplane` and `consul-k8s` for clarity.
This commit is contained in:
parent
a16bfc6a3c
commit
830d1bf77f
|
@ -16,27 +16,34 @@ set -euo pipefail
|
||||||
files_to_check=$(git diff --name-only "$(git merge-base origin/$SKIP_CHECK_BRANCH HEAD~)"...HEAD)
|
files_to_check=$(git diff --name-only "$(git merge-base origin/$SKIP_CHECK_BRANCH HEAD~)"...HEAD)
|
||||||
|
|
||||||
# Define the directories to check
|
# Define the directories to check
|
||||||
skipped_directories=("docs/" "ui/" "website/" "grafana/")
|
skipped_directories=("docs/" "ui/" "website/" "grafana/" ".changelog/")
|
||||||
|
|
||||||
# Loop through the changed files and find directories/files outside the skipped ones
|
# Loop through the changed files and find directories/files outside the skipped ones
|
||||||
for file_to_check in "${files_to_check[@]}"; do
|
files_to_check_array=($files_to_check)
|
||||||
|
for file_to_check in "${files_to_check_array[@]}"; do
|
||||||
file_is_skipped=false
|
file_is_skipped=false
|
||||||
|
echo "checking file: $file_to_check"
|
||||||
|
|
||||||
|
# Allow changes to:
|
||||||
|
# - This script
|
||||||
|
# - Files in the skipped directories
|
||||||
|
# - Markdown files
|
||||||
for dir in "${skipped_directories[@]}"; do
|
for dir in "${skipped_directories[@]}"; do
|
||||||
if [[ "$file_to_check" == "$dir"* ]] || [[ "$file_to_check" == *.md && "$dir" == *"/" ]]; then
|
if [[ "$file_to_check" == */check_skip_ci.sh ]] ||
|
||||||
|
[[ "$file_to_check" == "$dir"* ]] ||
|
||||||
|
[[ "$file_to_check" == *.md ]]; then
|
||||||
file_is_skipped=true
|
file_is_skipped=true
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$file_is_skipped" != "true" ]; then
|
if [ "$file_is_skipped" != "true" ]; then
|
||||||
echo -e $file_to_check
|
echo -e "non-skippable file changed: $file_to_check"
|
||||||
SKIP_CI=false
|
echo "Changes detected in non-documentation files - will not skip tests and build"
|
||||||
echo "Changes detected in non-documentation files - skip-ci: $SKIP_CI"
|
echo "skip-ci=false" >> "$GITHUB_OUTPUT"
|
||||||
echo "skip-ci=$SKIP_CI" >> "$GITHUB_OUTPUT"
|
|
||||||
exit 0 ## if file is outside of the skipped_directory exit script
|
exit 0 ## if file is outside of the skipped_directory exit script
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo -e "$files_to_check"
|
echo "Changes detected in only documentation files - skipping tests and build"
|
||||||
SKIP_CI=true
|
echo "skip-ci=true" >> "$GITHUB_OUTPUT"
|
||||||
echo "Changes detected in only documentation files - skip-ci: $SKIP_CI"
|
|
||||||
echo "skip-ci=$SKIP_CI" >> "$GITHUB_OUTPUT"
|
|
|
@ -41,7 +41,7 @@ jobs:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Get changed files
|
- name: Get changed files
|
||||||
id: read-files
|
id: read-files
|
||||||
run: ./.github/scripts/filter_changed_files_go_test.sh
|
run: ./.github/scripts/check_skip_ci.sh
|
||||||
|
|
||||||
setup:
|
setup:
|
||||||
needs: [conditional-skip]
|
needs: [conditional-skip]
|
||||||
|
|
|
@ -27,7 +27,7 @@ jobs:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Get changed files
|
- name: Get changed files
|
||||||
id: read-files
|
id: read-files
|
||||||
run: ./.github/scripts/filter_changed_files_go_test.sh
|
run: ./.github/scripts/check_skip_ci.sh
|
||||||
|
|
||||||
setup:
|
setup:
|
||||||
needs: [conditional-skip]
|
needs: [conditional-skip]
|
||||||
|
|
|
@ -42,7 +42,7 @@ jobs:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Get changed files
|
- name: Get changed files
|
||||||
id: read-files
|
id: read-files
|
||||||
run: ./.github/scripts/filter_changed_files_go_test.sh
|
run: ./.github/scripts/check_skip_ci.sh
|
||||||
|
|
||||||
setup:
|
setup:
|
||||||
needs: [conditional-skip]
|
needs: [conditional-skip]
|
||||||
|
|
Loading…
Reference in New Issue