ci/lib.sh: encapsulate Travis-specific things

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. Also, the configurations of the available agents are different. For example, Travis' and Azure Pipelines' macOS agents are set up differently, so that on Travis, we have to install the git-lfs and gettext Homebrew packages, and on Azure Pipelines we do not need to. Likewise, Azure Pipelines' Ubuntu agents already have asciidoctor installed. Finally, on Azure Pipelines the natural way is not to base64-encode tar files of the trash directories of failed tests, but to publish build artifacts instead. Therefore, that code to log those base64-encoded tar files is guarded to be Travis-specific. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Jan 27, 2019 at 15:26 UTC b011fabd6e07f200ed3a0a117caa409e44aba10f
4 files changed +43 -14
ci/install-dependencies.sh
+2 -1
@@ -37,7 +37,8 @@ osx-clang|osx-gcc)
37 brew update --quiet
38 # Uncomment this if you want to run perf tests:
39 # brew install gnu-time
40 - brew install git-lfs gettext
40 + test -z "$BREW_INSTALL_PACKAGES" ||
41 + brew install $BREW_INSTALL_PACKAGES
42 brew link --force gettext
43 brew install caskroom/cask/perforce
44 ;;
ci/lib.sh
+32 -13
@@ -24,7 +24,7 @@ skip_branch_tip_with_tag () {
24 # job if we encounter the same tree again and can provide a useful info
25 # message.
26 save_good_tree () {
27 - echo "$(git rev-parse $TRAVIS_COMMIT^{tree}) $TRAVIS_COMMIT $TRAVIS_JOB_NUMBER $TRAVIS_JOB_ID" >>"$good_trees_file"
27 + echo "$(git rev-parse $CI_COMMIT^{tree}) $CI_COMMIT $CI_JOB_NUMBER $CI_JOB_ID" >>"$good_trees_file"
28 # limit the file size
29 tail -1000 "$good_trees_file" >"$good_trees_file".tmp
30 mv "$good_trees_file".tmp "$good_trees_file"
@@ -34,7 +34,7 @@ save_good_tree () {
34 # successfully before (e.g. because the branch got rebased, changing only
35 # the commit messages).
36 skip_good_tree () {
37 - if ! good_tree_info="$(grep "^$(git rev-parse $TRAVIS_COMMIT^{tree}) " "$good_trees_file")"
37 + if ! good_tree_info="$(grep "^$(git rev-parse $CI_COMMIT^{tree}) " "$good_trees_file")"
38 then
39 # Haven't seen this tree yet, or no cached good trees file yet.
40 # Continue the build job.
@@ -44,18 +44,18 @@ skip_good_tree () {
44 echo "$good_tree_info" | {
45 read tree prev_good_commit prev_good_job_number prev_good_job_id
46
47 - if test "$TRAVIS_JOB_ID" = "$prev_good_job_id"
47 + if test "$CI_JOB_ID" = "$prev_good_job_id"
48 then
49 cat <<-EOF
50 - $(tput setaf 2)Skipping build job for commit $TRAVIS_COMMIT.$(tput sgr0)
50 + $(tput setaf 2)Skipping build job for commit $CI_COMMIT.$(tput sgr0)
51 This commit has already been built and tested successfully by this build job.
52 To force a re-build delete the branch's cache and then hit 'Restart job'.
53 EOF
54 else
55 cat <<-EOF
56 - $(tput setaf 2)Skipping build job for commit $TRAVIS_COMMIT.$(tput sgr0)
56 + $(tput setaf 2)Skipping build job for commit $CI_COMMIT.$(tput sgr0)
57 This commit's tree has already been built and tested successfully in build job $prev_good_job_number for commit $prev_good_commit.
58 - The log of that build job is available at https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$prev_good_job_id
58 + The log of that build job is available at $(url_for_job_id $prev_good_job_id)
59 To force a re-build delete the branch's cache and then hit 'Restart job'.
60 EOF
61 fi
@@ -80,11 +80,32 @@ check_unignored_build_artifacts ()
80 # and installing dependencies.
81 set -ex
82
83 -# When building a PR, TRAVIS_BRANCH refers to the *target* branch. Not what we
84 -# want here. We want the source branch instead.
85 -CI_BRANCH="${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"
83 +if test true = "$TRAVIS"
84 +then
85 + CI_TYPE=travis
86 + # When building a PR, TRAVIS_BRANCH refers to the *target* branch. Not
87 + # what we want here. We want the source branch instead.
88 + CI_BRANCH="${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"
89 + CI_COMMIT="$TRAVIS_COMMIT"
90 + CI_JOB_ID="$TRAVIS_JOB_ID"
91 + CI_JOB_NUMBER="$TRAVIS_JOB_NUMBER"
92 + CI_OS_NAME="$TRAVIS_OS_NAME"
93 + CI_REPO_SLUG="$TRAVIS_REPO_SLUG"
94 +
95 + cache_dir="$HOME/travis-cache"
96 +
97 + url_for_job_id () {
98 + echo "https://travis-ci.org/$CI_REPO_SLUG/jobs/$1"
99 + }
100 +
101 + BREW_INSTALL_PACKAGES="git-lfs gettext"
102 + export GIT_PROVE_OPTS="--timer --jobs 3 --state=failed,slow,save"
103 + export GIT_TEST_OPTS="--verbose-log -x --immediate"
104 +else
105 + echo "Could not identify CI type" >&2
106 + exit 1
107 +fi
108
87 -cache_dir="$HOME/travis-cache"
109 good_trees_file="$cache_dir/good-trees"
110
111 mkdir -p "$cache_dir"
@@ -94,13 +115,11 @@ skip_good_tree
115
116 if test -z "$jobname"
117 then
97 - jobname="$TRAVIS_OS_NAME-$CC"
118 + jobname="$CI_OS_NAME-$CC"
119 fi
120
121 export DEVELOPER=1
122 export DEFAULT_TEST_TARGET=prove
102 -export GIT_PROVE_OPTS="--timer --jobs 3 --state=failed,slow,save"
103 -export GIT_TEST_OPTS="--verbose-log -x --immediate"
123 export GIT_TEST_CLONE_2GB=YesPlease
124 if [ "$jobname" = linux-gcc ]; then
125 export CC=gcc-8
ci/print-test-failures.sh
+8
@@ -38,6 +38,14 @@ do
38 test_name="${TEST_EXIT%.exit}"
39 test_name="${test_name##*/}"
40 trash_dir="trash directory.$test_name"
41 + case "$CI_TYPE" in
42 + travis)
43 + ;;
44 + *)
45 + echo "Unhandled CI type: $CI_TYPE" >&2
46 + exit 1
47 + ;;
48 + esac
49 trash_tgz_b64="trash.$test_name.base64"
50 if [ -d "$trash_dir" ]
51 then
ci/test-documentation.sh
+1
@@ -5,6 +5,7 @@
5
6 . ${0%/*}/lib.sh
7
8 +test -n "$ALREADY_HAVE_ASCIIDOCTOR" ||
9 gem install asciidoctor
10
11 make check-builtins