From fac8906102be707b1a0b3bdec8f5e6788e5fe4d3 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 17 May 2017 16:11:34 +0100 Subject: [PATCH 1/8] Add script to fetch correct dep branches Fetch branches of js-sdk and react-sdk that match the current branch name, if they exist. This will mostly be used in the automated tests. --- scripts/fetch-develop.deps.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 scripts/fetch-develop.deps.sh diff --git a/scripts/fetch-develop.deps.sh b/scripts/fetch-develop.deps.sh new file mode 100755 index 0000000000..c5756a86ac --- /dev/null +++ b/scripts/fetch-develop.deps.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +# 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. + +curbranch=`git rev-parse --abbrev-ref HEAD` + +cd node_modules + +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 From 94ac4bf490a02f026c5f47d6e8174360c215ade4 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 17 May 2017 16:17:08 +0100 Subject: [PATCH 2/8] Use fetch dep script in jenkins script --- scripts/fetch-develop.deps.sh | 1 + scripts/jenkins.sh | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/scripts/fetch-develop.deps.sh b/scripts/fetch-develop.deps.sh index c5756a86ac..4053666fff 100755 --- a/scripts/fetch-develop.deps.sh +++ b/scripts/fetch-develop.deps.sh @@ -17,6 +17,7 @@ function dodep() { git clone https://github.com/$org/$repo.git $repo pushd $repo git checkout $curbranch || git checkout develop + npm install echo "$repo set to branch "`git rev-parse --abbrev-ref HEAD` popd } diff --git a/scripts/jenkins.sh b/scripts/jenkins.sh index 312eea4543..17f86fe126 100755 --- a/scripts/jenkins.sh +++ b/scripts/jenkins.sh @@ -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 From 60d33f50a7e30de6f16e610025f40586acbed8be Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 17 May 2017 16:19:19 +0100 Subject: [PATCH 3/8] Create node_modules if it doesn't exist --- scripts/fetch-develop.deps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/fetch-develop.deps.sh b/scripts/fetch-develop.deps.sh index 4053666fff..1a3c09969b 100755 --- a/scripts/fetch-develop.deps.sh +++ b/scripts/fetch-develop.deps.sh @@ -8,6 +8,7 @@ curbranch=`git rev-parse --abbrev-ref HEAD` +mkdir -p node_modules cd node_modules function dodep() { From 18afbc5becae4c65906d98e2b48ff511524b34aa Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 17 May 2017 18:14:28 +0100 Subject: [PATCH 4/8] Make dep install script work --- scripts/fetch-develop.deps.sh | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/scripts/fetch-develop.deps.sh b/scripts/fetch-develop.deps.sh index 1a3c09969b..a8abcef150 100755 --- a/scripts/fetch-develop.deps.sh +++ b/scripts/fetch-develop.deps.sh @@ -8,9 +8,6 @@ curbranch=`git rev-parse --abbrev-ref HEAD` -mkdir -p node_modules -cd node_modules - function dodep() { org=$1 repo=$2 @@ -18,10 +15,32 @@ function dodep() { git clone https://github.com/$org/$repo.git $repo pushd $repo git checkout $curbranch || git checkout develop - npm install 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 From b3b44dd99e31ebccf3f4f4472f256eb73235bdb5 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 17 May 2017 18:20:25 +0100 Subject: [PATCH 5/8] Use fetch dep script for travis --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9720d8872f..ff58bf374c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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) From c929cb1337f565e44da48da298f4b07c77c3703b Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 17 May 2017 18:21:58 +0100 Subject: [PATCH 6/8] Do I mean bash? Probably --- scripts/fetch-develop.deps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/fetch-develop.deps.sh b/scripts/fetch-develop.deps.sh index a8abcef150..50c3af1a57 100755 --- a/scripts/fetch-develop.deps.sh +++ b/scripts/fetch-develop.deps.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Fetches the js-sdk and matrix-react-sdk dependencies for development # or testing purposes From a9a4b1c44e6a9cebceeb5a039c45a01f2f8c0d9e Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 18 May 2017 11:05:19 +0100 Subject: [PATCH 7/8] Get branch from various CI env vars So we hopefully get the right branch for PRs from the same repo (but not forks). From @t3chguy's comment (tweaked a bit) --- scripts/fetch-develop.deps.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/scripts/fetch-develop.deps.sh b/scripts/fetch-develop.deps.sh index 50c3af1a57..8048d4bc58 100755 --- a/scripts/fetch-develop.deps.sh +++ b/scripts/fetch-develop.deps.sh @@ -6,7 +6,22 @@ # the branch the current checkout is on, use that branch. Otherwise, # use develop. -curbranch=`git rev-parse --abbrev-ref HEAD` +# 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 From 68a39b27835ac1c9b5cbdc5838c3b0bab1c92e34 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 19 May 2017 11:59:27 +0100 Subject: [PATCH 8/8] Update process to not set deps to #develop Update README instructions and add checks to release script to prevent us forgetting to bump the versions of dependencies (because the check in the main release script will only catch references to #develop left in, which will no longer be the failure mode). --- README.md | 30 +++++++++++++++++++----------- release.sh | 16 ++++++++++++++++ 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 55463a376e..3410787361 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/release.sh b/release.sh index c245456051..8ae307f7e2 100755 --- a/release.sh +++ b/release.sh @@ -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}"