ci: remove legacy Gerrit handling from local CI
The `GERRIT_` variables used by the `clone_repos.sh` script used to be
passed by a Jenkins job when triggering the CI scripts from the legacy
CI. This is now dead code, as this script is used exclusively by the
local CI.
Change-Id: If1598f5015335209e73067e6e84db3769fdf6d21
Signed-off-by: Chris Kay <chris.kay@arm.com>
diff --git a/script/clone_repos.sh b/script/clone_repos.sh
index bf6cb3d..ebb1b05 100755
--- a/script/clone_repos.sh
+++ b/script/clone_repos.sh
@@ -7,11 +7,6 @@
#
# Clone and sync all Trusted Firmware repositories.
#
-# The main repository is checked out at the required refspec (GERRIT_REFSPEC).
-# The rest of repositories are attempted to sync to the topic of that refspec
-# (as pointed to by GERRIT_TOPIC). 'repo_under_test' must be set to a
-# GERRIT_PROJECT for sync to work.
-#
# For every cloned repository, set its location to a variable so that the
# checked out location can be passed down to sub-jobs.
#
@@ -25,7 +20,6 @@
clone_log="$workspace/clone_repos.log"
clone_data="$workspace/clone.data"
override_data="$workspace/override.data"
-gerrit_data="$workspace/gerrit.data"
inject_data="$workspace/inject.data"
# File containing parameters for sub jobs
@@ -80,36 +74,12 @@
return 0
}
-post_gerrit_comment() {
- local gerrit_url="${gerrit_url:-$GERRIT_HOST}"
- gerrit_url="${gerrit_url:?}"
-
- # Posting comments to gerrit.oss.arm.com does not require any special
- # credentials, review.trustedfirmware.org does. Provide the ci-bot-user
- # account credentials for the latter.
- if [ "$gerrit_url" == "review.trustedfirmware.org" ]; then
- ssh -p 29418 -i "$tforg_key" "$tforg_user@$gerrit_url" gerrit \
- review "$GERRIT_CHANGE_NUMBER,$GERRIT_PATCHSET_NUMBER" \
- --message "'$(cat ${msg_file:?})'"
- else
- ssh -p 29418 "$gerrit_url" gerrit review \
- "$GERRIT_CHANGE_NUMBER,$GERRIT_PATCHSET_NUMBER" \
- --message "'$(cat ${msg_file:?})'"
- fi
-}
-
-# Whether we've synchronized branches or not
-has_synched=0
-
# Whether we've overridden some CI environment variables.
has_overrides=0
# Whether we've injected environment via. Jenkins
has_env_inject=0
-# Default Gerrit failure message file
-gerrit_fail_msg_file="$workspace/gerrit-fail"
-
clone_and_sync() {
local stat
local topic
@@ -118,38 +88,10 @@
local reference_dir="$project_filer/ref-repos/${name?}"
local ref_repo
local ret
- local gerrit_server
- local gerrit_user
- local gerrit_keyfile
strip_var refspec
strip_var url
- case "$url" in
- *${arm_gerrit_url}*)
- gerrit_server="arm"
- ;;
-
- *${tforg_gerrit_url}*)
- # SSH authentication is required on trustedfirmware.org.
- gerrit_server="tforg"
- gerrit_user="$tforg_user"
- gerrit_keyfile="$tforg_key"
- ;;
-
- *)
- # The project to clone might not be hosted on a Gerrit
- # server at all (e.g. Github).
- ;;
- esac
-
- # Refspec translation is supported for Gerrit patches only.
- if [ "$gerrit_server" ]; then
- refspec="$($ci_root/script/translate_refspec.py \
- -p "$name" -s "$gerrit_server" -u "$gerrit_user" \
- -k "$gerrit_keyfile" "$refspec")"
- fi
-
# Clone in the filter workspace
mkdir -p "$ci_scratch"
pushd "$ci_scratch"
@@ -181,47 +123,6 @@
if echo "$refspec" | grep -qv '^[a-f0-9]\+$'; then
git branch -f "$refspec" FETCH_HEAD
fi
- elif [ "$name" = "$repo_under_test" ]; then
- # Main repository under test
- if [ "$GERRIT_REFSPEC" ]; then
- # Fetch and checkout GERRIT_REFSPEC
- git fetch -q origin "$GERRIT_REFSPEC" \
- &>"$clone_log"
- git checkout -q FETCH_HEAD &>"$clone_log"
- refspec="$GERRIT_REFSPEC"
- stat="refspec $refspec"
- git branch "$refspec" FETCH_HEAD
- fi
- elif [ "$GERRIT_TOPIC" ]; then
- # Auxiliary repository: it's already on master when cloned above.
- topic="$GERRIT_TOPIC"
-
- # Check first if there's a Gerrit topic matching the topic of
- # the main repository under test
- ret=0
- refspec="$("$ci_root/script/translate_refspec.py" -p "$name" \
- -u "$gerrit_user" -k "$gerrit_keyfile" \
- -s "$gerrit_server" "topic:$topic" 2>/dev/null)" \
- || ret="$?"
- if [ "$ret" = 0 ]; then
- {
- git fetch -q origin "$refspec"
- git checkout -q FETCH_HEAD
- } &>"$clone_log"
- stat="gerrit topic $topic"
- git branch "$refspec" FETCH_HEAD
-
- has_synched=1
- elif git fetch -q origin "topics/$topic" &>"$clone_log"; then
- # If there's a remote branch matching the Gerrit topic
- # name, checkout to that; otherwise, stay on master.
- git checkout -q FETCH_HEAD &>"$clone_log"
- refspec="topics/$topic"
- stat="on branch $refspec"
- git branch "$refspec" FETCH_HEAD
-
- has_synched=1
- fi
fi
code_cov_emit_param "${name}" "REFSPEC" "${refspec}"
@@ -248,69 +149,8 @@
emit_env "$loc" "$ci_scratch/$name"
emit_env "$ref" "$refspec"
-
- # If this repository is being tested under a Gerrit trigger, set the
- # Gerrit test groups.
- if [ "$name" = "$repo_under_test" ]; then
- # For a Gerrit trigger, it's possible that users publish patch
- # sets in quick succession. If the CI is already busy, this
- # leads to more and more triggers queuing up. Also, it's likey
- # that older patch sets are tested before new ones. But because
- # there are newer patch sets already in queue, we should avoid
- # running tests on older ones as their results will be discarded
- # anyway.
- pushd "$ci_scratch/$name"
-
- change_id="$(git show -q --format=%b | awk '/Change-Id/{print $2}')"
- commit_id="$(git show -q --format=%H)"
- latest_commit_id="$($ci_root/script/translate_refspec.py \
- -p "$name" -u "$gerrit_user" -k "$gerrit_keyfile" \
- -s "$gerrit_server" "change:$change_id")"
-
- if [ "$commit_id" != "$latest_commit_id" ]; then
- # Overwrite Gerrit failure message
- cat <<EOF >"$gerrit_fail_msg_file"
-Patch set $GERRIT_PATCHSET_NUMBER is not the latest; not tested.
-Please await results for the latest patch set.
-EOF
-
- cat "$gerrit_fail_msg_file"
- echo
- die
- fi
-
- # Run nominations on this repository
- rules_file="$ci_root/script/$name.nomination.py"
- if [ -f "$rules_file" ]; then
- "$ci_root/script/gen_nomination.py" "$rules_file" > "$nom_file"
- if [ -s "$nom_file" ]; then
- emit_env "NOMINATION_FILE" "$nom_file"
- echo "$name has $(wc -l < $nom_file) test nominations."
- fi
- fi
-
- popd
-
- # Allow for groups to be overridden
- GERRIT_BUILD_GROUPS="${GERRIT_BUILD_GROUPS-$gerrit_build_groups}"
- if [ "$GERRIT_BUILD_GROUPS" ]; then
- emit_env "GERRIT_BUILD_GROUPS" "$GERRIT_BUILD_GROUPS"
- fi
-
- GERRIT_TEST_GROUPS="${GERRIT_TEST_GROUPS-$gerrit_test_groups}"
- if [ "$GERRIT_TEST_GROUPS" ]; then
- emit_env "GERRIT_TEST_GROUPS" "$GERRIT_TEST_GROUPS"
- fi
- fi
}
-# When triggered from Gerrit, the main repository that is under test. Can be
-# either TF, TFTF, SCP or CI.
-if [ "$GERRIT_REFSPEC" ]; then
- repo_under_test="${repo_under_test:-$REPO_UNDER_TEST}"
- repo_under_test="${repo_under_test:?}"
-fi
-
# Environment file in Java property file format, that's soured in Jenkins job
env_file="$workspace/env"
rm -f "$env_file"
@@ -334,9 +174,6 @@
fi
mkdir -p "$ci_scratch"
-# Nomination file
-nom_file="$ci_scratch/nominations"
-
# Set CI_SCRATCH so that it'll be injected when sub-jobs are triggered.
emit_param "CI_SCRATCH" "$ci_scratch"
@@ -368,35 +205,11 @@
has_env_inject=1
fi
-if [ "$GERRIT_BRANCH" ]; then
- # Overrides targeting a specific Gerrit branch.
- target_branch_override="$ci_overrides/branch/$GERRIT_BRANCH/env"
- if [ -f "$target_branch_override" ]; then
- display_override "$target_branch_override"
-
- {
- echo
- echo "Target branch overrides:"
- prefix_tab "$target_branch_override"
- echo
- } >> "$override_data"
-
- cat "$override_data"
-
- source "$target_branch_override"
- cat "$target_branch_override" >> "$env_file"
-
- has_overrides=1
- fi
-fi
-
TF_REFSPEC="${tf_refspec:-$TF_REFSPEC}"
if not_upon "$no_tf"; then
# Clone Trusted Firmware repository
url="$tf_src_repo_url" name="trusted-firmware" ref="TF_REFSPEC" \
loc="TF_CHECKOUT_LOC" \
- gerrit_build_groups="tf-gerrit-build" \
- gerrit_test_groups="tf-gerrit-tests tf-gerrit-tftf" \
clone_and_sync
fi
@@ -405,7 +218,6 @@
# Clone Trusted Firmware TF repository
url="$tftf_src_repo_url" name="trusted-firmware-tf" ref="TFTF_REFSPEC" \
loc="TFTF_CHECKOUT_LOC" \
- gerrit_test_groups="tftf-l1-build tftf-l1-fvp" \
clone_and_sync
fi
@@ -463,8 +275,7 @@
if not_upon "$no_ci"; then
# Clone Trusted Firmware CI repository
url="$tf_ci_repo_url" name="trusted-firmware-ci" ref="CI_REFSPEC" \
- loc="CI_ROOT" gerrit_test_groups="ci-l1" \
- clone_and_sync
+ loc="CI_ROOT" clone_and_sync
fi
TF_M_TESTS_REFSPEC="${tf_m_tests_refspec:-$TF_M_TESTS_REFSPEC}"
@@ -485,32 +296,6 @@
loc="RMM_PATH" clone_and_sync
fi
-if [ "$GERRIT_BRANCH" ]; then
- # If this CI run was in response to a Gerrit commit, post a comment back
- # to the patch set calling out everything that we've done so far. This
- # reassures both the developer and the reviewer about CI refspecs used
- # for CI testing.
- #
- # Note the extra quoting for the message, which Gerrit requires.
- if upon "$has_synched"; then
- echo "Branches synchronized:" >> "$gerrit_data"
- echo >> "$gerrit_data"
- cat "$clone_data" >> "$gerrit_data"
- fi
-
- if upon "$has_overrides"; then
- cat "$override_data" >> "$gerrit_data"
- fi
-
- if upon "$has_env_inject"; then
- cat "$inject_data" >> "$gerrit_data"
- fi
-
- if [ -s "$gerrit_data" ]; then
- msg_file="$gerrit_data" post_gerrit_comment
- fi
-fi
-
echo "SCP_TOOLS_COMMIT=$SCP_TOOLS_COMMIT" >> "$param_file"
# Copy environment file to ci_scratch for sub-jobs' access