git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCHv2 0/3] Travis CI: skip commits with successfully built and tested trees

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Dec 31, 2017, 10:12 UTC
Message-ID
<20171231101205.7466-1-szeder.dev@gmail.com>
In-Reply-To
<20171227164905.13872-1-szeder.dev@gmail.com>

This is the second iteration of 'sg/travis-skip-identical-test', addressing the comments of Lars and Jonathan:

  - Colorize the "Tip of $TRAVIS_BRANCH is exactly at $TAG" message
    in the new patch 1/3.
  - Create the cache directory at the beginning of the build process
    (patch 2/3).
  - Limit the the cached good trees file size to 1000 records, to
    prevent it from growing too large for git/git's forever living
    integration branches (patch 3/3).
  - Colorize the first line of the "skip build job because this tree has
    been tested".  Green it is (3/3).
  - Removed stray whitespace (3/3).
  - Updated an in-code comment, to make clear which code path deals with
    a non-existing good trees file (3/3).
SZEDER Gábor (3):
  travis-ci: print the "tip of branch is exactly at tag" message in
    color
  travis-ci: create the cache directory early in the build process
  travis-ci: record and skip successfully built trees
 ci/lib-travisci.sh        | 51 ++++++++++++++++++++++++++++++++++++++++++++++-
 ci/run-linux32-docker.sh  |  2 ++
 ci/run-static-analysis.sh |  2 ++
 ci/run-tests.sh           |  3 ++-
 ci/run-windows-build.sh   |  2 ++
 ci/test-documentation.sh  |  2 ++
 6 files changed, 60 insertions(+), 2 deletions(-)
-- 
2.16.0.rc0.67.g3a46dbca7


diff --git a/ci/lib-travisci.sh b/ci/lib-travisci.sh
index 05e73123f..bade71617 100755
--- a/ci/lib-travisci.sh
+++ b/ci/lib-travisci.sh
@@ -16,7 +16,7 @@ skip_branch_tip_with_tag () {
 	if TAG=$(git describe --exact-match "$TRAVIS_BRANCH" 2>/dev/null) &&
 		test "$TAG" != "$TRAVIS_BRANCH"
 	then
-		echo "Tip of $TRAVIS_BRANCH is exactly at $TAG"
+		echo "$(tput setaf 2)Tip of $TRAVIS_BRANCH is exactly at $TAG$(tput sgr0)"
 		exit 0
 	fi
 }
@@ -28,6 +28,9 @@ good_trees_file="$HOME/travis-cache/good-trees"
 # message.
 save_good_tree () {
 	echo "$(git rev-parse $TRAVIS_COMMIT^{tree}) $TRAVIS_COMMIT $TRAVIS_JOB_NUMBER $TRAVIS_JOB_ID" >>"$good_trees_file"
+	# limit the file size
+	tail -1000 "$good_trees_file" >"$good_trees_file".tmp
+	mv "$good_trees_file".tmp "$good_trees_file"
 }
 
 # Skip the build job if the same tree has already been built and tested
@@ -36,23 +39,24 @@ save_good_tree () {
 skip_good_tree () {
 	if ! good_tree_info="$(grep "^$(git rev-parse $TRAVIS_COMMIT^{tree}) " "$good_trees_file")"
 	then
-		# haven't seen this tree yet; continue the build job
+		# Haven't seen this tree yet, or no cached good trees file yet.
+		# Continue the build job.
 		return
 	fi
 
 	echo "$good_tree_info" | {
 		read tree prev_good_commit prev_good_job_number prev_good_job_id
 
-		if test "$TRAVIS_JOB_ID" =  "$prev_good_job_id"
+		if test "$TRAVIS_JOB_ID" = "$prev_good_job_id"
 		then
 			cat <<-EOF
-			Skipping build job for commit $TRAVIS_COMMIT.
+			$(tput setaf 2)Skipping build job for commit $TRAVIS_COMMIT.$(tput sgr0)
 			This commit has already been built and tested successfully by this build job.
 			To force a re-build delete the branch's cache and then hit 'Restart job'.
 			EOF
 		else
 			cat <<-EOF
-			Skipping build job for commit $TRAVIS_COMMIT.
+			$(tput setaf 2)Skipping build job for commit $TRAVIS_COMMIT.$(tput sgr0)
 			This commit's tree has already been built and tested successfully in build job $prev_good_job_number for commit $prev_good_commit.
 			The log of that build job is available at https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$prev_good_job_id
 			To force a re-build delete the branch's cache and then hit 'Restart job'.
@@ -69,6 +73,8 @@ skip_good_tree () {
 # and installing dependencies.
 set -ex
 
+mkdir -p "$HOME/travis-cache"
+
 skip_branch_tip_with_tag
 skip_good_tree
 
Previous: Jonathan NiederNext: SZEDER Gábor
Message 18 of 22 in “Travis CI: skip commits with successfully built and tested trees”
  1. 0/2 Travis CI: skip commits with successfully built and tested treesSZEDER Gábor, Dec 27, 2017
  2. 2/2 travis-ci: record and skip successfully built treesSZEDER Gábor, Dec 27, 2017
  3. Lars SchneiderDec 27, 2017
  4. SZEDER GáborDec 27, 2017
  5. SZEDER GáborDec 27, 2017
  6. Lars SchneiderDec 28, 2017
  7. SZEDER GáborDec 29, 2017
  8. SZEDER GáborDec 29, 2017
  9. Lars SchneiderDec 30, 2017
  10. Lars SchneiderDec 27, 2017
  11. SZEDER GáborDec 28, 2017
  12. Lars SchneiderDec 28, 2017
  13. Junio C HamanoDec 28, 2017
  14. 1/2 travis-ci: don't try to create the cache directory unnecessarilySZEDER Gábor, Dec 27, 2017
  15. Jonathan NiederDec 27, 2017
  16. SZEDER GáborDec 28, 2017
  17. Jonathan NiederDec 28, 2017
  18. 0/3 Travis CI: skip commits with successfully built and tested treesSZEDER Gábor, Dec 31, 2017
  19. 1/3 travis-ci: print the "tip of branch is exactly at tag" message in colorSZEDER Gábor, Dec 31, 2017
  20. 2/3 travis-ci: create the cache directory early in the build processSZEDER Gábor, Dec 31, 2017
  21. 3/3 travis-ci: record and skip successfully built treesSZEDER Gábor, Dec 31, 2017
  22. Lars SchneiderDec 31, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.