Skip to content

Commit 291eb16

Browse files
avargitster
authored andcommitted
CI: remove dead "tree skipping" code
Remove the code related to skipping CI runs if the tree was successfully tested before. With the GitHub CI this is done with the "ci-config" step, see e76eec3 (ci: allow per-branch config for GitHub Actions, 2020-05-07) and 7d78d5f (ci: skip GitHub workflow runs for already-tested commits/trees, 2020-10-08). This code hasn't been used since 4a6e4b9 (CI: remove Travis CI support, 2021-11-23), and before that for the retired Azure pipeline support removed in 6081d38 (ci: retire the Azure Pipelines definition, 2020-04-11). This change is needed because this and subsequent commits are turning "ci/lib.sh" into a dumber library that'll only be tasked with setting variables for CI jobs, or for specific steps within those jobs. Now we don't need to worry about it potentially skipping the run on its own. This change also removes a subtle potential logic error introduced in 0e7696c (ci: disallow directional formatting, 2021-11-04). The "ci/check-directional-formatting.bash" script would have been made to run after the "save_good_tree" in invoked in "ci/run-static-analysis.sh". So if e.g. the "make coccicheck" failed we'd still mark the tree as good. I.e. the addition of "ci/check-directional-formatting.bash" didn't take into account that the various users of the "save_good_tree" function in ci/*.sh made a hard assumption that they're the only ci/*.sh script that's being run (and they use "set -e"). This is entirely academic since we weren't actually running this code, but is something to be careful of if anyone ever needs to resurrect parts of this. Finally, the cache_dir="$HOME/none" added in a3f2eec (ci/lib: allow running in GitHub Actions, 2020-04-08) for the GitHub CI can be removed. It appears to have been added to appease the subsequent 'mkdir -p "$cache_dir"', which wasn't needed in GitHub CI. 1. https://lore.kernel.org/git/patch-1.1-eec0a8c3164-20211217T000418Z-avarab@gmail.com/ Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent e42b0f9 commit 291eb16

File tree

4 files changed

+0
-97
lines changed

4 files changed

+0
-97
lines changed

ci/lib.sh

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -13,75 +13,6 @@ then
1313
exit 1
1414
fi
1515

16-
skip_branch_tip_with_tag () {
17-
# Sometimes, a branch is pushed at the same time the tag that points
18-
# at the same commit as the tip of the branch is pushed, and building
19-
# both at the same time is a waste.
20-
#
21-
# When the build is triggered by a push to a tag, $CI_BRANCH will
22-
# have that tagname, e.g. v2.14.0. Let's see if $CI_BRANCH is
23-
# exactly at a tag, and if so, if it is different from $CI_BRANCH.
24-
# That way, we can tell if we are building the tip of a branch that
25-
# is tagged and we can skip the build because we won't be skipping a
26-
# build of a tag.
27-
28-
if TAG=$(git describe --exact-match "$CI_BRANCH" 2>/dev/null) &&
29-
test "$TAG" != "$CI_BRANCH"
30-
then
31-
echo "$(tput setaf 2)Tip of $CI_BRANCH is exactly at $TAG$(tput sgr0)"
32-
exit 0
33-
fi
34-
}
35-
36-
# Save some info about the current commit's tree, so we can skip the build
37-
# job if we encounter the same tree again and can provide a useful info
38-
# message.
39-
save_good_tree () {
40-
echo "$(git rev-parse $CI_COMMIT^{tree}) $CI_COMMIT $CI_JOB_NUMBER $CI_JOB_ID" >>"$good_trees_file"
41-
# limit the file size
42-
tail -1000 "$good_trees_file" >"$good_trees_file".tmp
43-
mv "$good_trees_file".tmp "$good_trees_file"
44-
}
45-
46-
# Skip the build job if the same tree has already been built and tested
47-
# successfully before (e.g. because the branch got rebased, changing only
48-
# the commit messages).
49-
skip_good_tree () {
50-
if test true = "$GITHUB_ACTIONS"
51-
then
52-
return
53-
fi
54-
55-
if ! good_tree_info="$(grep "^$(git rev-parse $CI_COMMIT^{tree}) " "$good_trees_file")"
56-
then
57-
# Haven't seen this tree yet, or no cached good trees file yet.
58-
# Continue the build job.
59-
return
60-
fi
61-
62-
echo "$good_tree_info" | {
63-
read tree prev_good_commit prev_good_job_number prev_good_job_id
64-
65-
if test "$CI_JOB_ID" = "$prev_good_job_id"
66-
then
67-
cat <<-EOF
68-
$(tput setaf 2)Skipping build job for commit $CI_COMMIT.$(tput sgr0)
69-
This commit has already been built and tested successfully by this build job.
70-
To force a re-build delete the branch's cache and then hit 'Restart job'.
71-
EOF
72-
else
73-
cat <<-EOF
74-
$(tput setaf 2)Skipping build job for commit $CI_COMMIT.$(tput sgr0)
75-
This commit's tree has already been built and tested successfully in build job $prev_good_job_number for commit $prev_good_commit.
76-
The log of that build job is available at $SYSTEM_TASKDEFINITIONSURI$SYSTEM_TEAMPROJECT/_build/results?buildId=$prev_good_job_id
77-
To force a re-build delete the branch's cache and then hit 'Restart job'.
78-
EOF
79-
fi
80-
}
81-
82-
exit 0
83-
}
84-
8516
check_unignored_build_artifacts ()
8617
{
8718
! git ls-files --other --exclude-standard --error-unmatch \
@@ -102,16 +33,8 @@ if test -n "$SYSTEM_COLLECTIONURI" || test -n "$SYSTEM_TASKDEFINITIONSURI"
10233
then
10334
CI_TYPE=azure-pipelines
10435
# We are running in Azure Pipelines
105-
CI_BRANCH="$BUILD_SOURCEBRANCH"
106-
CI_COMMIT="$BUILD_SOURCEVERSION"
107-
CI_JOB_ID="$BUILD_BUILDID"
108-
CI_JOB_NUMBER="$BUILD_BUILDNUMBER"
10936
CC="${CC:-gcc}"
11037

111-
# use a subdirectory of the cache dir (because the file share is shared
112-
# among *all* phases)
113-
cache_dir="$HOME/test-cache/$SYSTEM_PHASENAME"
114-
11538
export GIT_PROVE_OPTS="--timer --jobs 10 --state=failed,slow,save"
11639
export GIT_TEST_OPTS="--verbose-log -x --write-junit-xml"
11740
MAKEFLAGS="$MAKEFLAGS --jobs=10"
@@ -120,13 +43,7 @@ then
12043
elif test true = "$GITHUB_ACTIONS"
12144
then
12245
CI_TYPE=github-actions
123-
CI_BRANCH="$GITHUB_REF"
124-
CI_COMMIT="$GITHUB_SHA"
125-
CI_JOB_ID="$GITHUB_RUN_ID"
12646
CC="${CC:-gcc}"
127-
DONT_SKIP_TAGS=t
128-
129-
cache_dir="$HOME/none"
13047

13148
export GIT_PROVE_OPTS="--timer --jobs 10"
13249
export GIT_TEST_OPTS="--verbose-log -x"
@@ -139,14 +56,6 @@ else
13956
exit 1
14057
fi
14158

142-
good_trees_file="$cache_dir/good-trees"
143-
144-
mkdir -p "$cache_dir"
145-
146-
test -n "${DONT_SKIP_TAGS-}" ||
147-
skip_branch_tip_with_tag
148-
skip_good_tree
149-
15059
export DEVELOPER=1
15160
export DEFAULT_TEST_TARGET=prove
15261
export GIT_TEST_CLONE_2GB=true

ci/run-build-and-tests.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,3 @@ esac
4545
# start running tests.
4646
make $MAKE_TARGETS
4747
check_unignored_build_artifacts
48-
49-
save_good_tree

ci/run-static-analysis.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,3 @@ fi
2828

2929
make hdr-check ||
3030
exit 1
31-
32-
save_good_tree

ci/test-documentation.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,3 @@ grep '<meta name="generator" content="Asciidoctor ' Documentation/git.html
4141

4242
rm -f stdout.log stderr.log stderr.raw
4343
check_unignored_build_artifacts
44-
45-
save_good_tree

0 commit comments

Comments
 (0)