Sync 'scratch_scripts' with internal CI
Sync the scripts with open-ci commit:
539c151d0cd99a5e6ca6c0e6966f6d8579fe864e
Signed-off-by: Zelalem <zelalem.aweke@arm.com>
Change-Id: Id9acd8b411b97b4b0df4c011350fcbd5e3e3fed1
diff --git a/script/scratch_scripts/README b/script/scratch_scripts/README
index 590071b..394a793 100644
--- a/script/scratch_scripts/README
+++ b/script/scratch_scripts/README
@@ -7,3 +7,7 @@
The scripts in this folder are a copy of the scripts in the projectscratch
folder. They should be kept in sync, deploy_scratch.sh is a helper script
to copy them over.
+The integrity of the files in the projectscratch folder is checked by the
+check_scratch.sh script called by the tf-merge-watcher job. Please do not
+create any additional files or modify existing ones in the projectscratch
+directory without having these changes in the git repository.
diff --git a/script/scratch_scripts/fast-forward-master.sh b/script/scratch_scripts/fast-forward-master.sh
new file mode 100755
index 0000000..176712d
--- /dev/null
+++ b/script/scratch_scripts/fast-forward-master.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+#
+# Copyright (c) 2020, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+# Fast forward master branch with integration
+
+set -e
+
+git clone ssh://$CI_BOT_USERNAME@review.trustedfirmware.org:29418/TF-A/trusted-firmware-a
+cd trusted-firmware-a
+git checkout master
+git merge --ff-only origin/integration
+git push origin master
+cd ..
+rm -rf trusted-firmware-a
diff --git a/script/scratch_scripts/initial_clone.sh b/script/scratch_scripts/initial_clone.sh
index 94c9de5..3f96e36 100755
--- a/script/scratch_scripts/initial_clone.sh
+++ b/script/scratch_scripts/initial_clone.sh
@@ -59,7 +59,7 @@
# Clone CI repository and move to the refspec
git clone -q --depth 1 \
- http://ssg-sw.cambridge.arm.com/gerrit/pdswinf/ci/pdcs-platforms/platform-ci
+ https://gerrit.oss.arm.com/pdswinf/ci/pdcs-platforms/platform-ci
if [ "$CI_REFSPEC" ]; then
# Only recent Git versions support fetching refs via. commit IDs.
diff --git a/script/scratch_scripts/initial_clone_temp.sh b/script/scratch_scripts/initial_clone_temp.sh
index ef762bf..b0858bf 100755
--- a/script/scratch_scripts/initial_clone_temp.sh
+++ b/script/scratch_scripts/initial_clone_temp.sh
@@ -69,7 +69,7 @@
then
git clone -q --depth 1 \
--reference /arm/projectscratch/ssg/trusted-fw/ref-repos/trusted-firmware-ci \
- http://ssg-sw.cambridge.arm.com/gerrit/pdswinf/ci/pdcs-platforms/platform-ci
+ https://gerrit.oss.arm.com/pdswinf/ci/pdcs-platforms/platform-ci
else
pushd platform-ci
git fetch
diff --git a/script/scratch_scripts/initial_clone_v2.5.sh b/script/scratch_scripts/initial_clone_v2.5.sh
index 5630831..7c112d2 100755
--- a/script/scratch_scripts/initial_clone_v2.5.sh
+++ b/script/scratch_scripts/initial_clone_v2.5.sh
@@ -75,7 +75,7 @@
then
git clone -q --depth 1 \
--reference /arm/projectscratch/ssg/trusted-fw/ref-repos/trusted-firmware-ci \
- http://ssg-sw.cambridge.arm.com/gerrit/pdswinf/ci/pdcs-platforms/platform-ci
+ https://gerrit.oss.arm.com/pdswinf/ci/pdcs-platforms/platform-ci
else
pushd platform-ci
git fetch
diff --git a/script/scratch_scripts/initial_clone_v2.6.sh b/script/scratch_scripts/initial_clone_v2.6.sh
new file mode 100755
index 0000000..a7cb826
--- /dev/null
+++ b/script/scratch_scripts/initial_clone_v2.6.sh
@@ -0,0 +1,158 @@
+#!/bin/bash
+#
+# Copyright (c) 2019, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+# This script is meant to be run from Jenkins to make an initial clone of the
+# CI repository.
+#
+# - If CI_SCRATCH is set, we assume that a parent job has already cloned
+# required repositories; so we skip further cloning.
+#
+# - Otherwise, we call clone_repos.sh to have all required repositories to be
+# cloned.
+#
+# Note that, since this file resides in the repository itself, a copy of this
+# file must be 'wget'. I.e., any changes to to this file must be committed first
+# to the CI repository master for it to take effect!
+
+set -e
+
+strip_var() {
+ local var="$1"
+ local val="$(echo "${!var}" | sed 's#^\s*\|\s*$##g')"
+ eval "$var=$val"
+}
+
+set_ci_root() {
+ ci_root=`pwd`/"platform-ci"
+ CI_ROOT=$ci_root
+}
+
+strip_var CI_REFSPEC
+
+if [ ! -z $PROJECT ]; then
+ export REPO_UNDER_TEST=`basename $PROJECT`
+ echo "REPO_UNDER_TEST is blank, but PROJECT is set, setting REPO_UNDER_TEST based on PROJECT"
+ echo "REPO_UNDER_TEST=$REPO_UNDER_TEST"
+ echo "REPO_UNDER_TEST=$REPO_UNDER_TEST" >> env
+fi
+
+# For jobs triggered by Gerrit, obtain REPO_UNDER_TEST, TF_SRC_REPO_URL
+# and TFTF_SRC_REPO_URL (if not set explicitly) from Gerrit Environment
+# variables.
+
+if [ "$GERRIT_REFSPEC" ]; then
+
+ if [ -z $REPO_UNDER_TEST ]; then
+ if [ $GERRIT_PROJECT == "pdcs-platforms/ap/tf-topics" ] || [ $GERRIT_PROJECT == "TF-A/trusted-firmware-a" ]; then
+ export REPO_UNDER_TEST="trusted-firmware"
+ echo "REPO_UNDER_TEST is blank, setting REPO_UNDER_TEST based on GERRIT_PROJECT"
+
+ elif [ $GERRIT_PROJECT == "trusted-firmware/tf-a-tests" ] || [ $GERRIT_PROJECT == "TF-A/tf-a-tests" ]; then
+ export REPO_UNDER_TEST="trusted-firmware-tf"
+ echo "REPO_UNDER_TEST is blank, setting REPO_UNDER_TEST based on GERRIT_PROJECT"
+
+ elif [ $GERRIT_PROJECT == "pdswinf/ci/pdcs-platforms/platform-ci" ]; then
+ export REPO_UNDER_TEST="trusted-firmware-ci"
+ echo "REPO_UNDER_TEST is blank, setting REPO_UNDER_TEST based on GERRIT_PROJECT"
+ fi
+ fi
+
+ if [ -z $TF_SRC_REPO_URL ] && [ $REPO_UNDER_TEST == "trusted-firmware" ]; then
+ export TF_SRC_REPO_URL="https://$GERRIT_HOST/$GERRIT_PROJECT"
+ fi
+
+ if [ -z $TFTF_SRC_REPO_URL ] && [ $REPO_UNDER_TEST == "trusted-firmware-tf" ]; then
+ export TFTF_SRC_REPO_URL="https://$GERRIT_HOST/$GERRIT_PROJECT"
+ fi
+fi
+
+if [ "$CI_ENVIRONMENT" ]; then
+ tmpfile="$(mktemp --tmpdir="$WORKSPACE")"
+ echo "$CI_ENVIRONMENT" | tr ' ' '\n' > "$tmpfile"
+ set -a
+ source "$tmpfile"
+ set +a
+fi
+
+if [ "$CI_SCRATCH" ]; then
+ if [ ! -d "$CI_SCRATCH" ]; then
+ echo "\$CI_SCRATCH is stale; ignored."
+ else
+ # Copy environment and parameter file from scratch to this job's
+ # workspace
+ cp "$CI_SCRATCH/env" .
+ cp "$CI_SCRATCH/env.param" .
+ find "$CI_SCRATCH" -name "*.data" -exec cp -t . '{}' +
+
+ exit 0
+ fi
+fi
+
+# If no CI ref specs were explicitly specified, but was triggered from a CI
+# Gerrit trigger, move to the Gerrit refspec instead so that we use the expected
+# version of clone_repos.sh.
+if [ -z "$CI_REFSPEC" ] && [ "$REPO_UNDER_TEST" = "trusted-firmware-ci" ] && \
+ [ "$GERRIT_REFSPEC" ]; then
+ export CI_REFSPEC="$GERRIT_REFSPEC"
+fi
+
+# Clone CI repository and move to the refspec
+if [ ! -d "platform-ci" ]
+then
+git clone -q --depth 1 \
+ --reference /arm/projectscratch/ssg/trusted-fw/ref-repos/trusted-firmware-ci \
+ https://gerrit.oss.arm.com/pdswinf/ci/pdcs-platforms/platform-ci
+else
+ pushd platform-ci
+ git fetch
+ git checkout origin/master
+ popd
+fi
+
+set_ci_root
+# Set CI_ROOT as a fallback
+echo "CI_ROOT=$ci_root" >> env
+
+if [ "$CI_REFSPEC" ]; then
+ # Only recent Git versions support fetching refs via. commit IDs.
+ # However, platform slaves have been updated to a version that can do
+ # this (https://jira.arm.com/browse/SSGSWINF-1426). The module load
+ # commands have been commented out since.
+ #
+ # source /arm/tools/setup/init/bash
+ # module load swdev
+ # module load git/git/2.14.3
+
+ # Translate refspec if supported
+ if [ -x "$ci_root/script/translate_refspec.py" ]; then
+ CI_REFSPEC="$("$ci_root/script/translate_refspec.py" \
+ -p trusted-firmware-ci -s arm "$CI_REFSPEC")"
+ fi
+
+ pushd platform-ci &>/dev/null
+ git fetch -q --depth 1 origin "$CI_REFSPEC"
+ git checkout -q FETCH_HEAD
+ echo
+ echo "Initial CI repo checked out to '$CI_REFSPEC'."
+ popd &>/dev/null
+fi
+
+if [ "$ci_only" ]; then
+ exit 0
+fi
+
+if echo "$-" | grep -q "x"; then
+ minus_x="-x"
+fi
+
+if ! bash $minus_x "$ci_root/script/clone_repos.sh"; then
+ echo "clone_repos.sh failed!"
+ cat clone_repos.log
+ exit 1
+fi
+
+# vim:set tw=80 sw=8 sts=8 noet:
diff --git a/script/scratch_scripts/initial_clone_v2.sh b/script/scratch_scripts/initial_clone_v2.sh
index 0836fe1..29e996d 100755
--- a/script/scratch_scripts/initial_clone_v2.sh
+++ b/script/scratch_scripts/initial_clone_v2.sh
@@ -61,7 +61,7 @@
# Clone CI repository and move to the refspec
git clone -q --depth 1 \
--reference /arm/projectscratch/ssg/trusted-fw/ref-repos/trusted-firmware-ci \
- http://ssg-sw.cambridge.arm.com/gerrit/pdswinf/ci/pdcs-platforms/platform-ci
+ https://gerrit.oss.arm.com/pdswinf/ci/pdcs-platforms/platform-ci
# Set CI_ROOT as a fallback
ci_root="platform-ci/trusted-fw/new-ci"