Subject: Re: [PATCH v4 03/21] ci/lib.sh: encapsulate Travis-specific things

From: SZEDER Gábor <[email-masked]>
Date: Fri, 25 Jan 2019 14:51:27 +0100

On Wed, Jan 23, 2019 at 06:40:16AM -0800, Johannes Schindelin via GitGitGadget wrote:
> From: Johannes Schindelin <[email-masked]>
> 
> The upcoming patches will allow building git.git via Azure Pipelines
> (i.e. Azure DevOps' Continuous Integration), where variable names and
> URLs look a bit different than in Travis CI.
> 
> Signed-off-by: Johannes Schindelin <[email-masked]>
> ---

> diff --git a/ci/lib.sh b/ci/lib.sh
> index c26bb6a274..4456dbbcb0 100755
> --- a/ci/lib.sh
> +++ b/ci/lib.sh
> @@ -1,8 +1,26 @@
>  # Library of functions shared by all CI scripts
>  
> -# When building a PR, TRAVIS_BRANCH refers to the *target* branch. Not what we
> -# want here. We want the source branch instead.
> -CI_BRANCH="${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"
> +if test true = "$TRAVIS"
> +then
> +	# When building a PR, TRAVIS_BRANCH refers to the *target* branch. Not
> +	# what we want here. We want the source branch instead.
> +	CI_BRANCH="${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"
> +	CI_COMMIT="$TRAVIS_COMMIT"
> +	CI_JOB_ID="$TRAVIS_JOB_ID"
> +	CI_JOB_NUMBER="$TRAVIS_JOB_NUMBER"
> +	CI_OS_NAME="$TRAVIS_OS_NAME"
> +	CI_REPO_SLUG="$TRAVIS_REPO_SLUG"
> +
> +	cache_dir="$HOME/travis-cache"
> +
> +	url_for_job_id () {
> +		echo "https://travis-ci.org/$CI_REPO_SLUG/jobs/$1"
> +	}
> +
> +	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"
> +fi

Please set these variables after 'set -x' has been turned on, so the
values will be visible in the logs.

https://public-inbox.org/git/[email-masked]/

> diff --git a/ci/print-test-failures.sh b/ci/print-test-failures.sh
> index 7aef39a2fd..d2045b63a6 100755
> --- a/ci/print-test-failures.sh
> +++ b/ci/print-test-failures.sh
> @@ -69,7 +69,7 @@ do
>  	fi
>  done
>  
> -if [ $combined_trash_size -gt 0 ]
> +if [ -n "$TRAVIS_JOB_ID" -a $combined_trash_size -gt 0 ]

Nit: if [ -n "$TRAVIS_JOB_ID" ] && [ $combined_trash_size -gt 0 ]

More importantly: is this necessary, because on Azure Pipelines there
is no URL from where the logs could be downloaded conveniently and
reliably?  I wonder whether it's worth to spend the extra effort in
preparing the base64-encoded trash directories of failed tests in the
first place.

>  then
>  	echo "------------------------------------------------------------------------"
>  	echo "Trash directories embedded in this log can be extracted by running:"