2017-05-17 13:21:58 -04:00
|
|
|
#!/bin/bash
|
2017-05-17 11:11:34 -04:00
|
|
|
|
|
|
|
# Fetches the js-sdk and matrix-react-sdk dependencies for development
|
|
|
|
# or testing purposes
|
|
|
|
# If there exists a branch of that dependency with the same name as
|
|
|
|
# the branch the current checkout is on, use that branch. Otherwise,
|
|
|
|
# use develop.
|
|
|
|
|
2019-03-19 12:41:28 -04:00
|
|
|
set -ex
|
2017-05-31 10:37:30 -04:00
|
|
|
|
2017-06-01 13:02:51 -04:00
|
|
|
GIT_CLONE_ARGS=("$@")
|
2019-01-22 22:28:09 -05:00
|
|
|
[ -z "$defbranch" ] && defbranch="develop"
|
2017-05-17 11:11:34 -04:00
|
|
|
|
2017-06-01 13:02:51 -04:00
|
|
|
# clone a specific branch of a github repo
|
|
|
|
function clone() {
|
|
|
|
org=$1
|
|
|
|
repo=$2
|
|
|
|
branch=$3
|
2019-01-22 22:28:09 -05:00
|
|
|
|
|
|
|
# Chop 'origin' off the start as jenkins ends up using
|
|
|
|
# branches on the origin, but this doesn't work if we
|
|
|
|
# specify the branch when cloning.
|
|
|
|
branch=${branch#origin/}
|
|
|
|
|
|
|
|
if [ -n "$branch" ]
|
|
|
|
then
|
|
|
|
echo "Trying to use $org/$repo#$branch"
|
2019-03-20 14:05:02 -04:00
|
|
|
git clone git://github.com/$org/$repo.git $repo --branch $branch \
|
2019-01-22 22:28:09 -05:00
|
|
|
"${GIT_CLONE_ARGS[@]}"
|
2019-01-23 06:40:21 -05:00
|
|
|
return $?
|
2019-01-22 22:28:09 -05:00
|
|
|
fi
|
2019-01-23 06:40:21 -05:00
|
|
|
return 1
|
2017-06-01 13:02:51 -04:00
|
|
|
}
|
|
|
|
|
2017-05-17 11:11:34 -04:00
|
|
|
function dodep() {
|
2019-03-19 12:41:28 -04:00
|
|
|
deforg=$1
|
|
|
|
defrepo=$2
|
|
|
|
rm -rf $defrepo
|
2019-01-22 22:28:09 -05:00
|
|
|
|
|
|
|
# Try the PR author's branch in case it exists on the deps as well.
|
|
|
|
# Try the target branch of the push or PR.
|
|
|
|
# Use the default branch as the last resort.
|
2019-03-14 00:23:28 -04:00
|
|
|
if [[ "$BUILDKITE" == true ]]; then
|
2019-03-19 12:41:28 -04:00
|
|
|
# If BUILDKITE_BRANCH is set, it will contain either:
|
|
|
|
# * "branch" when the author's branch and target branch are in the same repo
|
|
|
|
# * "author:branch" when the author's branch is in their fork
|
|
|
|
# We can split on `:` into an array to check.
|
|
|
|
BUILDKITE_BRANCH_ARRAY=(${BUILDKITE_BRANCH//:/ })
|
|
|
|
if [[ "${#BUILDKITE_BRANCH_ARRAY[@]}" == "2" ]]; then
|
|
|
|
prAuthor=${BUILDKITE_BRANCH_ARRAY[0]}
|
|
|
|
prBranch=${BUILDKITE_BRANCH_ARRAY[1]}
|
|
|
|
else
|
|
|
|
prAuthor=$deforg
|
|
|
|
prBranch=$BUILDKITE_BRANCH
|
|
|
|
fi
|
|
|
|
clone $prAuthor $defrepo $prBranch ||
|
|
|
|
clone $deforg $defrepo $BUILDKITE_PULL_REQUEST_BASE_BRANCH ||
|
|
|
|
clone $deforg $defrepo $defbranch ||
|
2019-01-22 22:28:09 -05:00
|
|
|
return $?
|
|
|
|
else
|
2019-03-19 12:41:28 -04:00
|
|
|
clone $deforg $defrepo $ghprbSourceBranch ||
|
|
|
|
clone $deforg $defrepo $GIT_BRANCH ||
|
|
|
|
clone $deforg $defrepo `git rev-parse --abbrev-ref HEAD` ||
|
|
|
|
clone $deforg $defrepo $defbranch ||
|
2019-01-22 22:28:09 -05:00
|
|
|
return $?
|
|
|
|
fi
|
2017-06-01 13:02:51 -04:00
|
|
|
|
2019-03-19 12:41:28 -04:00
|
|
|
echo "$defrepo set to branch "`git -C "$defrepo" rev-parse --abbrev-ref HEAD`
|
2017-05-17 11:11:34 -04:00
|
|
|
}
|
|
|
|
|
2017-08-08 04:43:40 -04:00
|
|
|
##############################
|
|
|
|
|
2017-06-01 13:02:51 -04:00
|
|
|
echo 'Setting up matrix-js-sdk'
|
|
|
|
|
2017-05-17 11:11:34 -04:00
|
|
|
dodep matrix-org matrix-js-sdk
|
2017-06-01 13:02:51 -04:00
|
|
|
|
2019-03-12 07:06:57 -04:00
|
|
|
pushd matrix-js-sdk
|
|
|
|
yarn link
|
2021-07-07 10:10:40 -04:00
|
|
|
yarn install --pure-lockfile
|
2019-03-12 07:06:57 -04:00
|
|
|
popd
|
|
|
|
|
|
|
|
yarn link matrix-js-sdk
|
|
|
|
|
2017-08-08 04:43:40 -04:00
|
|
|
##############################
|
|
|
|
|
2017-06-01 13:02:51 -04:00
|
|
|
echo 'Setting up matrix-react-sdk'
|
|
|
|
|
2017-05-17 11:11:34 -04:00
|
|
|
dodep matrix-org matrix-react-sdk
|
2017-05-17 13:14:28 -04:00
|
|
|
|
2019-03-12 07:06:57 -04:00
|
|
|
pushd matrix-react-sdk
|
|
|
|
yarn link
|
|
|
|
yarn link matrix-js-sdk
|
2021-07-07 10:10:40 -04:00
|
|
|
yarn install --pure-lockfile
|
2020-12-18 10:32:53 -05:00
|
|
|
yarn reskindex
|
2019-03-12 07:06:57 -04:00
|
|
|
popd
|
|
|
|
|
|
|
|
yarn link matrix-react-sdk
|
2017-06-01 13:02:51 -04:00
|
|
|
|
2017-08-08 04:43:40 -04:00
|
|
|
##############################
|
|
|
|
|
2019-03-12 07:06:57 -04:00
|
|
|
# Link the reskindex binary in place: if we used `yarn link`,
|
|
|
|
# Yarn would do this for us, but we don't because we'd have
|
|
|
|
# to define the Yarn binary prefix somewhere so it could put the
|
2017-05-17 13:14:28 -04:00
|
|
|
# intermediate symlinks there. Instead, we do it ourselves.
|
2017-06-01 13:02:51 -04:00
|
|
|
mkdir -p node_modules/.bin
|
|
|
|
ln -sfv ../matrix-react-sdk/scripts/reskindex.js node_modules/.bin/reskindex
|