Merge branch 'js/macos-gettext-build'
[gitweb.git] / ci / lib.sh
index 3f286d86a63eeb32c5590e3426e25e430d68b165..288a5b3884ad825c99601ba5dc62ee81c62d7d64 100755 (executable)
--- a/ci/lib.sh
+++ b/ci/lib.sh
@@ -74,6 +74,9 @@ check_unignored_build_artifacts ()
        }
 }
 
+# Clear MAKEFLAGS that may come from the outside world.
+export MAKEFLAGS=
+
 # Set 'exit on error' for all CI scripts to let the caller know that
 # something went wrong.
 # Set tracing executed commands, primarily setting environment variables
@@ -101,6 +104,34 @@ then
        BREW_INSTALL_PACKAGES="git-lfs gettext"
        export GIT_PROVE_OPTS="--timer --jobs 3 --state=failed,slow,save"
        export GIT_TEST_OPTS="--verbose-log -x --immediate"
+       MAKEFLAGS="$MAKEFLAGS --jobs=2"
+elif test -n "$SYSTEM_COLLECTIONURI" || test -n "$SYSTEM_TASKDEFINITIONSURI"
+then
+       CI_TYPE=azure-pipelines
+       # We are running in Azure Pipelines
+       CI_BRANCH="$BUILD_SOURCEBRANCH"
+       CI_COMMIT="$BUILD_SOURCEVERSION"
+       CI_JOB_ID="$BUILD_BUILDID"
+       CI_JOB_NUMBER="$BUILD_BUILDNUMBER"
+       CI_OS_NAME="$(echo "$AGENT_OS" | tr A-Z a-z)"
+       test darwin != "$CI_OS_NAME" || CI_OS_NAME=osx
+       CI_REPO_SLUG="$(expr "$BUILD_REPOSITORY_URI" : '.*/\([^/]*/[^/]*\)$')"
+       CC="${CC:-gcc}"
+
+       # use a subdirectory of the cache dir (because the file share is shared
+       # among *all* phases)
+       cache_dir="$HOME/test-cache/$SYSTEM_PHASENAME"
+
+       url_for_job_id () {
+               echo "$SYSTEM_TASKDEFINITIONSURI$SYSTEM_TEAMPROJECT/_build/results?buildId=$1"
+       }
+
+       BREW_INSTALL_PACKAGES=gcc@8
+       export GIT_PROVE_OPTS="--timer --jobs 10 --state=failed,slow,save"
+       export GIT_TEST_OPTS="--verbose-log -x --write-junit-xml"
+       MAKEFLAGS="$MAKEFLAGS --jobs=10"
+       test windows_nt != "$CI_OS_NAME" ||
+       GIT_TEST_OPTS="--no-chain-lint --no-bin-wrappers $GIT_TEST_OPTS"
 else
        echo "Could not identify CI type" >&2
        exit 1
@@ -121,12 +152,14 @@ fi
 export DEVELOPER=1
 export DEFAULT_TEST_TARGET=prove
 export GIT_TEST_CLONE_2GB=YesPlease
-if [ "$jobname" = linux-gcc ]; then
-       export CC=gcc-8
-fi
 
 case "$jobname" in
 linux-clang|linux-gcc)
+       if [ "$jobname" = linux-gcc ]
+       then
+               export CC=gcc-8
+       fi
+
        export GIT_TEST_HTTPD=YesPlease
 
        # The Linux build installs the defined dependency versions below.
@@ -140,6 +173,11 @@ linux-clang|linux-gcc)
        export PATH="$GIT_LFS_PATH:$P4_PATH:$PATH"
        ;;
 osx-clang|osx-gcc)
+       if [ "$jobname" = osx-gcc ]
+       then
+               export CC=gcc-8
+       fi
+
        # t9810 occasionally fails on Travis CI OS X
        # t9816 occasionally fails with "TAP out of sequence errors" on
        # Travis CI OS X
@@ -149,3 +187,5 @@ GIT_TEST_GETTEXT_POISON)
        export GIT_TEST_GETTEXT_POISON=YesPlease
        ;;
 esac
+
+MAKEFLAGS="$MAKEFLAGS CC=${CC:-cc}"