diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a49d75b77f..f789abfb66 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -582,6 +582,17 @@ file-plug-in-tests: junit: "_log/import-tests.xml" expire_in: 2 days +meson-health: + extends: .default + rules: + - <<: *CI_MERGE + - <<: *CI_COMMIT + stage: analysis + script: + - apt-get update + - apt-get install -y git + - bash .gitlab/run_meson_health_diff.sh + clang-format: extends: .default rules: diff --git a/.gitlab/run_meson_health_diff.sh b/.gitlab/run_meson_health_diff.sh new file mode 100644 index 0000000000..4582c1a6a3 --- /dev/null +++ b/.gitlab/run_meson_health_diff.sh @@ -0,0 +1,141 @@ +#!/bin/bash + +source .gitlab/search-common-ancestor.sh + +diff=$(git diff -U0 --no-color "${newest_common_ancestor_sha}" -- '*.build' | grep -E '^\+[^+]' | sed 's/^+//') + + +#List of commonly used utilities on Unix world +#See the context: https://gitlab.gnome.org/GNOME/gimp/-/issues/11385 +coreutils_array=( + ".sh" + "'sh'" + "'bash'" + "'\['" + "'arch'" + "'awk'" + "'b2sum'" + "'base32'" + "'base64'" + "'basename'" + "'basenc'" + "'cat'" + "'chcon'" + "'chgrp'" + "'chmod'" + "'chown'" + "'chroot'" + "'cksum'" + "'comm'" + "'cp'" + "'csplit'" + "'cut'" + "'date'" + "'dd'" + "'df'" + "'dir'" + "'dircolors'" + "'dirname'" + "'du'" + "'echo'" + "'env'" + "'expand'" + "'expr'" + "'factor'" + "'false'" + "'find'" + "'fmt'" + "'fold'" + "'gkill'" + "'grep'" + "'groups'" + "'head'" + "'hostid'" + "'hostname'" + "'id'" + "'install'" + "'join'" + "'link'" + "'ln'" + "'logname'" + "'ls'" + "'md5sum'" + "'mkdir'" + "'mkfifo'" + "'mknod'" + "'mktemp'" + "'mv'" + "'nice'" + "'nl'" + "'nohup'" + "'nproc'" + "'numfmt'" + "'od'" + "'paste'" + "'pathchk'" + "'pinky'" + "'pr'" + "'printenv'" + "'printf'" + "'ptx'" + "'pwd'" + "'readlink'" + "'realpath'" + "'rm'" + "'rmdir'" + "'runcon'" + "'sed'" + "'seq'" + "'sha1sum'" + "'sha224sum'" + "'sha256sum'" + "'sha384sum'" + "'sha512sum'" + "'shred'" + "'shuf'" + "'sleep'" + "'sort'" + "'split'" + "'stat'" + "'stdbuf'" + "'stty'" + "'sum'" + "'sync'" + "'tac'" + "'tail'" + "'tee'" + "'test'" + "'timeout'" + "'touch'" + "'tr'" + "'true'" + "'truncate'" + "'tsort'" + "'tty'" + "'uname'" + "'unexpand'" + "'uniq'" + "'unlink'" + "'users'" + "'vdir'" + "'wc'" + "'who'" + "'whoami'" + "'yes'" +) + +for coreutil in "${coreutils_array[@]}"; do + if echo "$diff" | grep -q "$coreutil"; then + found_coreutils+=" $coreutil" + fi +done + +if [ "$found_coreutils" ]; then + echo -e '\033[31m(ERROR)\033[0m: Seems that you are trying to add an Unix-specific dependency to be called by Meson.' + echo " Please, port to Python (which is crossplatform), your use of:${found_coreutils}." + exit 1 +fi + + +echo 'Meson .build files are alright regarding crossplatform.' +exit 0 diff --git a/.gitlab/search-common-ancestor.sh b/.gitlab/search-common-ancestor.sh index d5394ffe8f..321b960e27 100644 --- a/.gitlab/search-common-ancestor.sh +++ b/.gitlab/search-common-ancestor.sh @@ -24,13 +24,13 @@ git fetch --shallow-since="$(date --date="${ancestor_horizon} days ago" +%Y-%m-% # fall back to `${CI_DEFAULT_BRANCH}` or `${CI_COMMIT_BRANCH}` respectively # otherwise. -# add mr-origin -git remote add mr-origin ${CI_MERGE_REQUEST_SOURCE_PROJECT_URL} +# add patch-origin +git remote add patch-origin ${CI_MERGE_REQUEST_SOURCE_PROJECT_URL:-${CI_PROJECT_URL}} source_branch="${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:-${CI_COMMIT_BRANCH}}" -git fetch --shallow-since="$(date --date="${ancestor_horizon} days ago" +%Y-%m-%d)" mr-origin "${source_branch}" &> ./fetch_origin.log +git fetch --shallow-since="$(date --date="${ancestor_horizon} days ago" +%Y-%m-%d)" patch-origin "${source_branch}" &> ./fetch_origin.log -newest_common_ancestor_sha=$(diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent "upstream/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-${CI_DEFAULT_BRANCH}}") <(git rev-list --first-parent "mr-origin/${source_branch}") | head -1) +newest_common_ancestor_sha=$(diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent "upstream/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-${CI_DEFAULT_BRANCH}}") <(git rev-list --first-parent "patch-origin/${source_branch}") | head -1) if [ -z "${newest_common_ancestor_sha}" ]; then echo "Couldn’t find common ancestor with upstream main branch. This typically" echo "happens if you branched from main a long time ago. Please update"