Merge pull request #3945 from vector-im/dbkr/fetch_deps_script

Script to fetch corresponding branches of dependent projects
This commit is contained in:
David Baker 2017-05-19 13:14:07 +01:00 committed by GitHub
commit 50b46af943
5 changed files with 101 additions and 19 deletions

View file

@ -2,6 +2,5 @@ language: node_js
node_js:
- 6 # node v6, to match jenkins
install:
- scripts/fetch-develop.deps.sh
- npm install
- (cd node_modules/matrix-js-sdk && npm install)
- (cd node_modules/matrix-react-sdk && npm install)

View file

@ -58,27 +58,35 @@ to build.
1. Install or update `node.js` so that your `npm` is at least at version `2.0.0`
1. Clone the repo: `git clone https://github.com/vector-im/riot-web.git`
1. Switch to the riot-web directory: `cd riot-web`
1. Install the prerequisites: `npm install`
1. If you are using the `develop` branch of vector-web, you will probably need
to rebuild some of the dependencies, due to
https://github.com/npm/npm/issues/3055:
1. If you're using the `develop` branch, install the develop versions of the
dependencies, as the released ones will be too old:
```
(cd node_modules/matrix-js-sdk && npm install)
(cd node_modules/matrix-react-sdk && npm install)
scripts/fetch-develop-deps.sh
```
Whenever you git pull on riot-web you will also probably need to force an update
to these dependencies - the easiest way is probably:
to these dependencies - the simplest way is to re-run the script, but you can also
manually update and reuild them:
```
rm -rf node_modules/matrjx-{js,react}-sdk && npm i
(cd node_modules/matrix-js-sdk && npm install)
(cd node_modules/matrix-react-sdk && npm install)
cd matrix-js-sdk
git pull
npm install # re-run to pull in any new dependencies
# Depending on your version of npm, npm run build may happen as part of
# the npm install above (https://docs.npmjs.com/misc/scripts#prepublish-and-prepare)
# If in doubt, run it anyway:
npm run build
cd ../matrix-react-sdk
git pull
npm install
npm run build
```
However, we recommend setting up a proper development environment (see "Setting
up a development environment" below) if you want to run your own copy of the
`develop` branch, as it makes it much easier to keep these dependencies
up-to-date. Or just use https://riot.im/develop - the continuous integration
release of the develop branch.
(Note that we don't reference the develop versions in git directly due to
https://github.com/npm/npm/issues/3055)
1. Install the prerequisites: `npm install`
1. Configure the app by copying `config.sample.json` to `config.json` and
modifying it (see below for details)
1. `npm run dist` to build a tarball to deploy. Untaring this file will give

View file

@ -9,6 +9,22 @@ set -e
cd `dirname $0`
for i in matrix-js-sdk matrix-react-sdk
do
depver=`cat package.json | jq -r .dependencies.\"$i\"`
latestver=`npm show $i version`
if [ "$depver" != "$latestver" ]
then
echo "The latest version of $i is $latestver but package.json depends on $depver"
echo -n "Type 'Yes' to continue anyway: "
read resp
if [ "$resp" != "Yes" ]
then
echo "OK, never mind."
exit 1
fi
fi
done
# bump Electron's package.json first
release="${1#v}"

61
scripts/fetch-develop.deps.sh Executable file
View file

@ -0,0 +1,61 @@
#!/bin/bash
# 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.
# Look in the many different CI env vars for which branch we're
# building
if [[ "$TRAVIS" == true ]]; then
curbranch="${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"
else
# ghprbSourceBranch for jenkins github pull request builder
# GIT_BRANCH for other jenkins builds
curbranch="${ghprbSourceBranch:-$GIT_BRANCH}"
# Otherwise look at the actual branch we're on
if [ -z "$curbranch" ]
then
curbranch=`git rev-parse --abbrev-ref HEAD`
fi
fi
echo "Determined branch to be $curbranch"
function dodep() {
org=$1
repo=$2
rm -rf $repo || true
git clone https://github.com/$org/$repo.git $repo
pushd $repo
git checkout $curbranch || git checkout develop
echo "$repo set to branch "`git rev-parse --abbrev-ref HEAD`
popd
}
dodep matrix-org matrix-js-sdk
dodep matrix-org matrix-react-sdk
mkdir -p node_modules
cd node_modules
ln -s ../matrix-js-sdk ./
pushd matrix-js-sdk
npm install
popd
ln -s ../matrix-react-sdk ./
pushd matrix-react-sdk
mkdir -p node_modules
cd node_modules
ln -s ../../matrix-js-sdk matrix-js-sdk
cd ..
npm install
popd
# Link the reskindex binary in place: if we used npm link,
# npm would do this for us, but we don't because we'd have
# to define the npm prefix somewhere so it could put the
# intermediate symlinks there. Instead, we do it ourselves.
mkdir -p .bin
ln -s ../matrix-react-sdk/scripts/reskindex.js .bin/reskindex

View file

@ -8,10 +8,13 @@ nvm use 6
set -x
# check out corresponding branches of dependencies
`dirname $0`/fetch-develop.deps.sh
npm install
# apparently npm 3.10.3 on node 6.4.0 doesn't upgrade #develop target with npm install unless explicitly asked.
npm install matrix-react-sdk matrix-js-sdk olm
npm install olm
# install olm. A naive 'npm i ./olm/olm-*.tgz' fails because it uses the url
# from our package.json (or even matrix-js-sdk's) in preference.
@ -23,11 +26,6 @@ npm install matrix-react-sdk matrix-js-sdk olm
#rm -r node_modules/olm
#cp -r olm/package node_modules/olm
# we may be using dev branches of js-sdk and react-sdk, in which case we need to build them
(cd node_modules/matrix-js-sdk && npm install)
(cd node_modules/matrix-react-sdk && npm install)
# run the mocha tests
npm run test