From fed1acd8f61b228bc29602fe01a8f8c9e9aa3f64 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 22 Jan 2018 11:56:28 +0100 Subject: [PATCH] gitlab-ci: if running on a fork, only check the files in the fork To avoid confusing newbies, the CI should only run on the files that were changed in the fork. Sometimes lint/rewrite errors slip into the git repo, and the CI for all merge requests will fail until those are fixed. This changes that to make the merge request CI only fail if the files in the merge request are the ones with problems. The CI runs on the main repo should will check everything. --- .gitlab-ci.yml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1623a8bd2c..86481da815 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,13 +8,24 @@ before_script: lint: script: + # if this is a merge request fork, then only check relevant apps + - if [ "$CI_PROJECT_NAMESPACE" != "fdroid" ]; then + git fetch https://gitlab.com/fdroid/fdroiddata; + test -d build || mkdir build; + for f in `git diff --name-only FETCH_HEAD`; do + appid=`echo $f | sed -n -e 's,^metadata/\(.*\)\.txt,\1,p' + -e 's,^metadata/\(.*\)\.yml,\1,p'`; + export CHANGED="$CHANGED $appid"; + grep -q "^Repo *Type\W *git" $f && git -C build clone `sed -n "s,^Repo *:,,p" $f` $appid; + done; + fi - export EXITVALUE=0 - - fdroid lint -f || { + - fdroid lint -f $CHANGED || { export EXITVALUE=1; printf "\nThese files have lint issues:\n"; - fdroid rewritemeta -l; + fdroid rewritemeta -l $CHANGED; printf "\nThese are the formatting issues:\n"; - fdroid rewritemeta; + fdroid rewritemeta $CHANGED; git --no-pager diff --color=always; } - exit $EXITVALUE