diff options
author | Joseph Herlant <aerostitch@users.noreply.github.com> | 2019-11-04 09:18:57 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-04 09:18:57 -0800 |
commit | 39f745bc282c45443deef8e13b381f207207da58 (patch) | |
tree | 50217fca64be4ccdcbe3871df72f34ebddc121f2 /scripts | |
parent | f334e21516af6c1cb0b96d0d341d262586c33b9b (diff) | |
download | navit-39f745bc282c45443deef8e13b381f207207da58.tar.gz |
update:CI: skip the build steps if the change is only for documentation (#941)
* update:CI: skip the build steps if the change is only for documentation
* Use spaces not comma to separate array elements (codefactor)
* unrelated: fix missing checkstyle result storage
* Testing if the circleci command works in our custom images
* Make sure git is installed on certain steps
* local -n is not supported everywhere
* git package on the old image for wince is called git-core
* Just do an exit 1 when we are on a tag
* Revert the testing part. Now ready for merge
* Fix some variables names forgotten in the refactoring
* Revert the testing part. Now ready for merge
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/check_need_build.sh | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/check_need_build.sh b/scripts/check_need_build.sh new file mode 100755 index 000000000..124722e9a --- /dev/null +++ b/scripts/check_need_build.sh @@ -0,0 +1,35 @@ +#!/bin/bash -e +# ################################################################################################################### # +# This file exits 1 if there are files of interest that should trigger a build and exits normally otherwise. # +# The idea is also to build if the exit code is different from 0 as it means we cannot get a filtered list properly. # +# ################################################################################################################### # + +# If we are on a tag, just exit 1 as we want to go on with the build +git describe --exact-match --tags HEAD 2>&1 2>/dev/null && exit 1 || echo "Not on a tag, checking files diff" + +# This block constructs the list of files that differ from the trunk branch. +# Note that if you are on the trunk or master branch it will return the files modified by the last commit. +declare -a file_list=$(git diff --name-only refs/remotes/origin/trunk) +# If there is no diff that might just mean that you are on the trunk or master branch +# so you just want to check the last commit. This way we still have that check more +# or less working when pushing directly to trunk or when merging in master. +if [[ -z "$file_list" ]]; then + file_list=$(git diff --name-only HEAD^) +fi + +# This block filters out those don't match the pattern we use to exclude files that should not trigger a build. +declare -a filters=('^docs/.*' '.*\.md$' '.*\.rst$') +for f in ${file_list[@]}; do + for filter in "${filters[@]}" ; do + echo "checking $f with filter $filter" + if [[ "$f" =~ $filter ]]; then + # This removes the element from the element matching the filter + file_list=(${file_list[@]/$f}) + echo "filtering out $f" + break + fi + done +done + +# exits with a 0 if the list is empty +[[ -z "${file_list}" ]] |