Rebrand various CI scripts and modules

This replaces Riot with Element in various CI scripts, modules, parameters, etc.
This _should_ be the last major rebranding pass (hopefully).

Fixes https://github.com/vector-im/element-web/issues/14894
This commit is contained in:
J. Ryan Stinnett 2020-12-03 13:56:27 +00:00
parent 675a4b0816
commit 1fda735222
22 changed files with 78 additions and 79 deletions

View file

@ -1,4 +1,4 @@
src/component-index.js src/component-index.js
test/end-to-end-tests/node_modules/ test/end-to-end-tests/node_modules/
test/end-to-end-tests/riot/ test/end-to-end-tests/element/
test/end-to-end-tests/synapse/ test/end-to-end-tests/synapse/

View file

@ -12,5 +12,5 @@ test/components/views/dialogs/InteractiveAuthDialog-test.js
test/mock-clock.js test/mock-clock.js
src/component-index.js src/component-index.js
test/end-to-end-tests/node_modules/ test/end-to-end-tests/node_modules/
test/end-to-end-tests/riot/ test/end-to-end-tests/element/
test/end-to-end-tests/synapse/ test/end-to-end-tests/synapse/

View file

@ -50,7 +50,7 @@
"lint:types": "tsc --noEmit --jsx react", "lint:types": "tsc --noEmit --jsx react",
"lint:style": "stylelint 'res/css/**/*.scss'", "lint:style": "stylelint 'res/css/**/*.scss'",
"test": "jest", "test": "jest",
"test:e2e": "./test/end-to-end-tests/run.sh --riot-url http://localhost:8080" "test:e2e": "./test/end-to-end-tests/run.sh --app-url http://localhost:8080"
}, },
"dependencies": { "dependencies": {
"@babel/runtime": "^7.10.5", "@babel/runtime": "^7.10.5",

View file

@ -2,11 +2,11 @@
# #
# script which is run by the CI build (after `yarn test`). # script which is run by the CI build (after `yarn test`).
# #
# clones riot-web develop and runs the tests against our version of react-sdk. # clones element-web develop and runs the tests against our version of react-sdk.
set -ev set -ev
scripts/ci/layered-riot-web.sh scripts/ci/layered.sh
cd ../riot-web cd ../element-web
yarn build:genfiles # so the tests can run. Faster version of `build` yarn build:genfiles # so the tests can run. Faster version of `build`
yarn test yarn test

View file

@ -2,7 +2,7 @@
# #
# script which is run by the CI build (after `yarn test`). # script which is run by the CI build (after `yarn test`).
# #
# clones riot-web develop and runs the tests against our version of react-sdk. # clones element-web develop and runs the tests against our version of react-sdk.
set -ev set -ev
@ -14,20 +14,20 @@ handle_error() {
trap 'handle_error' ERR trap 'handle_error' ERR
echo "--- Building Element" echo "--- Building Element"
scripts/ci/layered-riot-web.sh scripts/ci/layered.sh
cd ../riot-web cd ../element-web
riot_web_dir=`pwd` element_web_dir=`pwd`
CI_PACKAGE=true yarn build CI_PACKAGE=true yarn build
cd ../matrix-react-sdk cd ../matrix-react-sdk
# run end to end tests # run end to end tests
pushd test/end-to-end-tests pushd test/end-to-end-tests
ln -s $riot_web_dir riot/riot-web ln -s $element_web_dir element/element-web
# PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true ./install.sh # PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true ./install.sh
# CHROME_PATH=$(which google-chrome-stable) ./run.sh # CHROME_PATH=$(which google-chrome-stable) ./run.sh
echo "--- Install synapse & other dependencies" echo "--- Install synapse & other dependencies"
./install.sh ./install.sh
# install static webserver to server symlinked local copy of riot # install static webserver to server symlinked local copy of element
./riot/install-webserver.sh ./element/install-webserver.sh
rm -r logs || true rm -r logs || true
mkdir logs mkdir logs
echo "+++ Running end-to-end tests" echo "+++ Running end-to-end tests"

View file

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
# Creates an environment similar to one that riot-web would expect for # Creates an environment similar to one that element-web would expect for
# development. This means going one directory up (and assuming we're in # development. This means going one directory up (and assuming we're in
# a directory like /workdir/matrix-react-sdk) and putting riot-web and # a directory like /workdir/matrix-react-sdk) and putting element-web and
# the js-sdk there. # the js-sdk there.
cd ../ # Assume we're at something like /workdir/matrix-react-sdk cd ../ # Assume we're at something like /workdir/matrix-react-sdk
@ -21,9 +21,9 @@ yarn link
yarn install yarn install
popd popd
# Finally, set up riot-web # Finally, set up element-web
matrix-react-sdk/scripts/fetchdep.sh vector-im riot-web matrix-react-sdk/scripts/fetchdep.sh vector-im element-web
pushd riot-web pushd element-web
yarn link matrix-js-sdk yarn link matrix-js-sdk
yarn link matrix-react-sdk yarn link matrix-react-sdk
yarn install yarn install

View file

@ -1,3 +1,3 @@
node_modules node_modules
*.png *.png
riot/env element/env

View file

@ -5,9 +5,9 @@ This directory contains tests for matrix-react-sdk. The tests fire up a headless
## Setup ## Setup
Run `./install.sh`. This will: Run `./install.sh`. This will:
- install Synapse, fetches the master branch at the moment. If anything fails here, please refer to the Synapse README to see if you're missing one of the prerequisites. - install Synapse, fetches the develop branch at the moment. If anything fails here, please refer to the Synapse README to see if you're missing one of the prerequisites.
- install Riot, this fetches the master branch at the moment. - install Element Web, this fetches the develop branch at the moment.
- install dependencies (will download copy of chrome) - install dependencies (will download copy of Chrome)
## Running the tests ## Running the tests
@ -15,7 +15,7 @@ Run tests with `./run.sh`.
### Debug tests locally. ### Debug tests locally.
`./run.sh` will run the tests against the Riot copy present in `riot/riot-web` served by a static Python HTTP server. You can symlink your `riot-web` develop copy here but that doesn't work well with Webpack recompiling. You can run the test runner directly and specify parameters to get more insight into a failure or run the tests against your local Webpack server. `./run.sh` will run the tests against the Element copy present in `element/element-web` served by a static Python HTTP server. You can symlink your `element-web` develop copy here but that doesn't work well with Webpack recompiling. You can run the test runner directly and specify parameters to get more insight into a failure or run the tests against your local Webpack server.
``` ```
./synapse/stop.sh && \ ./synapse/stop.sh && \
@ -26,8 +26,7 @@ It's important to always stop and start Synapse before each run of the tests to
start.js accepts these parameters (and more, see `node start.js --help`) that can help running the tests locally: start.js accepts these parameters (and more, see `node start.js --help`) that can help running the tests locally:
- `--riot-url <url>` don't use the Riot copy and static server provided by the tests, but use a running server like the Webpack watch server to run the tests against. Make sure to have the following local config: - `--app-url <url>` don't use the Element Web copy and static server provided by the tests, but use a running server like the Webpack watch server to run the tests against.
- `welcomeUserId` disabled as the tests assume there is no riot-bot currently.
- `--slow-mo` type at a human speed, useful with `--windowed`. - `--slow-mo` type at a human speed, useful with `--windowed`.
- `--throttle-cpu <factor>` throttle cpu in the browser by the given factor. Useful to reproduce failures because of insufficient timeouts happening on the slower CI server. - `--throttle-cpu <factor>` throttle cpu in the browser by the given factor. Useful to reproduce failures because of insufficient timeouts happening on the slower CI server.
- `--windowed` run the tests in an actual browser window Try to limit interacting with the windows while the tests are running. Hovering over the window tends to fail the tests, dragging the title bar should be fine though. - `--windowed` run the tests in an actual browser window Try to limit interacting with the windows while the tests are running. Hovering over the window tends to fail the tests, dragging the title bar should be fine though.

View file

@ -5,14 +5,14 @@ and start following these steps to get going:
1. Navigate to your working directory (`cd /mnt/c/users/travisr/whatever/matrix-react-sdk` for example). 1. Navigate to your working directory (`cd /mnt/c/users/travisr/whatever/matrix-react-sdk` for example).
2. Run `sudo apt-get install unzip python3 virtualenv dos2unix` 2. Run `sudo apt-get install unzip python3 virtualenv dos2unix`
3. Run `dos2unix ./test/end-to-end-tests/*.sh ./test/end-to-end-tests/synapse/*.sh ./test/end-to-end-tests/riot/*.sh` 3. Run `dos2unix ./test/end-to-end-tests/*.sh ./test/end-to-end-tests/synapse/*.sh ./test/end-to-end-tests/element/*.sh`
4. Install NodeJS for ubuntu: 4. Install NodeJS for ubuntu:
```bash ```bash
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get update sudo apt-get update
sudo apt-get install nodejs sudo apt-get install nodejs
``` ```
5. Start Riot on Windows through `yarn start` 5. Start Element on Windows through `yarn start`
6. While that builds... Run: 6. While that builds... Run:
```bash ```bash
sudo apt-get install x11-apps sudo apt-get install x11-apps
@ -25,11 +25,11 @@ and start following these steps to get going:
cd ./test/end-to-end-tests cd ./test/end-to-end-tests
./synapse/install.sh ./synapse/install.sh
./install.sh ./install.sh
./run.sh --riot-url http://localhost:8080 --no-sandbox ./run.sh --app-url http://localhost:8080 --no-sandbox
``` ```
Note that using `yarn test:e2e` probably won't work for you. You might also have to use the config.json from the Note that using `yarn test:e2e` probably won't work for you. You might also have to use the config.json from the
`riot/config-template` directory in order to actually succeed at the tests. `element/config-template` directory in order to actually succeed at the tests.
Also note that you'll have to use `--no-sandbox` otherwise Chrome will complain that there's no sandbox available. You Also note that you'll have to use `--no-sandbox` otherwise Chrome will complain that there's no sandbox available. You
could probably fix this with enough effort, or you could run a headless Chrome in the WSL container without a sandbox. could probably fix this with enough effort, or you could run a headless Chrome in the WSL container without a sandbox.

View file

@ -0,0 +1,2 @@
element-web
element.pid

View file

@ -8,7 +8,7 @@
"brand": "Element", "brand": "Element",
"integrations_ui_url": "https://scalar.vector.im/", "integrations_ui_url": "https://scalar.vector.im/",
"integrations_rest_url": "https://scalar.vector.im/api", "integrations_rest_url": "https://scalar.vector.im/api",
"bug_report_endpoint_url": "https://riot.im/bugreports/submit", "bug_report_endpoint_url": "https://element.io/bugreports/submit",
"showLabsSettings": true, "showLabsSettings": true,
"default_federate": true, "default_federate": true,
"welcomePageUrl": "home.html", "welcomePageUrl": "home.html",

View file

@ -0,0 +1,16 @@
#!/bin/bash
set -e
ELEMENT_BRANCH=develop
if [ -d $BASE_DIR/element-web ]; then
echo "Element is already installed"
exit
fi
curl -L https://github.com/vector-im/element-web/archive/${ELEMENT_BRANCH}.zip --output element.zip
unzip -q element.zip
rm element.zip
mv element-web-${ELEMENT_BRANCH} element-web
cd element-web
yarn install
yarn run build

View file

@ -3,7 +3,7 @@ set -e
PORT=5000 PORT=5000
BASE_DIR=$(cd $(dirname $0) && pwd) BASE_DIR=$(cd $(dirname $0) && pwd)
PIDFILE=$BASE_DIR/riot.pid PIDFILE=$BASE_DIR/element.pid
CONFIG_BACKUP=config.e2etests_backup.json CONFIG_BACKUP=config.e2etests_backup.json
if [ -f $PIDFILE ]; then if [ -f $PIDFILE ]; then
@ -11,8 +11,8 @@ if [ -f $PIDFILE ]; then
fi fi
cd $BASE_DIR/ cd $BASE_DIR/
echo -n "starting riot on http://localhost:$PORT ... " echo -n "Starting Element on http://localhost:$PORT ... "
pushd riot-web/webapp/ > /dev/null pushd element-web/webapp/ > /dev/null
# backup config file before we copy template # backup config file before we copy template
if [ -f config.json ]; then if [ -f config.json ]; then
@ -34,7 +34,7 @@ LOGFILE=$(mktemp)
# NOT expected SIGTERM (128 + 15) # NOT expected SIGTERM (128 + 15)
# from stop.sh? # from stop.sh?
if [ $RESULT -ne 143 ]; then if [ $RESULT -ne 143 ]; then
echo "failed" echo "Failed"
cat $LOGFILE cat $LOGFILE
rm $PIDFILE 2> /dev/null rm $PIDFILE 2> /dev/null
fi fi
@ -49,6 +49,6 @@ sleep 0.5 &
wait -n; RESULT=$? wait -n; RESULT=$?
# return exit code of first child to exit # return exit code of first child to exit
if [ $RESULT -eq 0 ]; then if [ $RESULT -eq 0 ]; then
echo "running" echo "Running"
fi fi
exit $RESULT exit $RESULT

View file

@ -2,19 +2,19 @@
set -e set -e
BASE_DIR=$(cd $(dirname $0) && pwd) BASE_DIR=$(cd $(dirname $0) && pwd)
PIDFILE=riot.pid PIDFILE=element.pid
CONFIG_BACKUP=config.e2etests_backup.json CONFIG_BACKUP=config.e2etests_backup.json
cd $BASE_DIR cd $BASE_DIR
if [ -f $PIDFILE ]; then if [ -f $PIDFILE ]; then
echo "stopping riot server ..." echo "Stopping Element server ..."
PID=$(cat $PIDFILE) PID=$(cat $PIDFILE)
rm $PIDFILE rm $PIDFILE
kill $PID kill $PID
# revert config file # revert config file
cd riot-web/webapp cd element-web/webapp
rm config.json rm config.json
if [ -f $CONFIG_BACKUP ]; then if [ -f $CONFIG_BACKUP ]; then
mv $CONFIG_BACKUP config.json mv $CONFIG_BACKUP config.json

View file

@ -15,10 +15,10 @@ limitations under the License.
*/ */
// used from run.sh as getopts doesn't support long parameters // used from run.sh as getopts doesn't support long parameters
const idx = process.argv.indexOf("--riot-url"); const idx = process.argv.indexOf("--app-url");
let hasRiotUrl = false; let hasAppUrl = false;
if (idx !== -1) { if (idx !== -1) {
const value = process.argv[idx + 1]; const value = process.argv[idx + 1];
hasRiotUrl = !!value; hasAppUrl = !!value;
} }
process.stdout.write(hasRiotUrl ? "1" : "0" ); process.stdout.write(hasAppUrl ? "1" : "0" );

View file

@ -1,2 +0,0 @@
riot-web
riot.pid

View file

@ -1,16 +0,0 @@
#!/bin/bash
set -e
RIOT_BRANCH=develop
if [ -d $BASE_DIR/riot-web ]; then
echo "riot is already installed"
exit
fi
curl -L https://github.com/vector-im/riot-web/archive/${RIOT_BRANCH}.zip --output riot.zip
unzip -q riot.zip
rm riot.zip
mv riot-web-${RIOT_BRANCH} riot-web
cd riot-web
yarn install
yarn run build

View file

@ -9,16 +9,16 @@ echo "Please first run $BASE_DIR/install.sh"
exit 1 exit 1
fi fi
has_custom_riot=$(node has_custom_riot.js $@) has_custom_app=$(node has-custom-app.js $@)
if [ ! -d "riot/riot-web" ] && [ $has_custom_riot -ne "1" ]; then if [ ! -d "element/element-web" ] && [ $has_custom_app -ne "1" ]; then
echo "Please provide an instance of riot to test against by passing --riot-url <url> or running $BASE_DIR/riot/install.sh" echo "Please provide an instance of Element to test against by passing --element-url <url> or running $BASE_DIR/element/install.sh"
exit 1 exit 1
fi fi
stop_servers() { stop_servers() {
if [ $has_custom_riot -ne "1" ]; then if [ $has_custom_app -ne "1" ]; then
./riot/stop.sh ./element/stop.sh
fi fi
./synapse/stop.sh ./synapse/stop.sh
} }
@ -32,8 +32,8 @@ handle_error() {
trap 'handle_error' ERR trap 'handle_error' ERR
./synapse/start.sh ./synapse/start.sh
if [ $has_custom_riot -ne "1" ]; then if [ $has_custom_app -ne "1" ]; then
./riot/start.sh ./element/start.sh
fi fi
node start.js $@ node start.js $@
stop_servers stop_servers

View file

@ -22,12 +22,12 @@ const {delay} = require('./util');
const DEFAULT_TIMEOUT = 20000; const DEFAULT_TIMEOUT = 20000;
module.exports = class RiotSession { module.exports = class ElementSession {
constructor(browser, page, username, riotserver, hsUrl) { constructor(browser, page, username, elementServer, hsUrl) {
this.browser = browser; this.browser = browser;
this.page = page; this.page = page;
this.hsUrl = hsUrl; this.hsUrl = hsUrl;
this.riotserver = riotserver; this.elementServer = elementServer;
this.username = username; this.username = username;
this.consoleLog = new LogBuffer(page, "console", (msg) => `${msg.text()}\n`); this.consoleLog = new LogBuffer(page, "console", (msg) => `${msg.text()}\n`);
this.networkLog = new LogBuffer(page, "requestfinished", async (req) => { this.networkLog = new LogBuffer(page, "requestfinished", async (req) => {
@ -38,7 +38,7 @@ module.exports = class RiotSession {
this.log = new Logger(this.username); this.log = new Logger(this.username);
} }
static async create(username, puppeteerOptions, riotserver, hsUrl, throttleCpuFactor = 1) { static async create(username, puppeteerOptions, elementServer, hsUrl, throttleCpuFactor = 1) {
const browser = await puppeteer.launch(puppeteerOptions); const browser = await puppeteer.launch(puppeteerOptions);
const page = await browser.newPage(); const page = await browser.newPage();
await page.setViewport({ await page.setViewport({
@ -50,7 +50,7 @@ module.exports = class RiotSession {
console.log("throttling cpu by a factor of", throttleCpuFactor); console.log("throttling cpu by a factor of", throttleCpuFactor);
await client.send('Emulation.setCPUThrottlingRate', { rate: throttleCpuFactor }); await client.send('Emulation.setCPUThrottlingRate', { rate: throttleCpuFactor });
} }
return new RiotSession(browser, page, username, riotserver, hsUrl); return new ElementSession(browser, page, username, elementServer, hsUrl);
} }
async tryGetInnertext(selector) { async tryGetInnertext(selector) {
@ -194,7 +194,7 @@ module.exports = class RiotSession {
} }
url(path) { url(path) {
return this.riotserver + path; return this.elementServer + path;
} }
delay(ms) { delay(ms) {

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
const RiotSession = require('./src/session'); const ElementSession = require('./src/session');
const scenario = require('./src/scenario'); const scenario = require('./src/scenario');
const RestSessionCreator = require('./src/rest/creator'); const RestSessionCreator = require('./src/rest/creator');
const fs = require("fs"); const fs = require("fs");
@ -22,7 +22,7 @@ const fs = require("fs");
const program = require('commander'); const program = require('commander');
program program
.option('--no-logs', "don't output logs, document html on error", false) .option('--no-logs', "don't output logs, document html on error", false)
.option('--riot-url [url]', "riot url to test", "http://localhost:5000") .option('--app-url [url]', "url to test", "http://localhost:5000")
.option('--windowed', "dont run tests headless", false) .option('--windowed', "dont run tests headless", false)
.option('--slow-mo', "type at a human speed", false) .option('--slow-mo', "type at a human speed", false)
.option('--dev-tools', "open chrome devtools in browser window", false) .option('--dev-tools', "open chrome devtools in browser window", false)
@ -57,7 +57,7 @@ async function runTests() {
); );
async function createSession(username) { async function createSession(username) {
const session = await RiotSession.create(username, options, program.riotUrl, hsUrl, program.throttleCpu); const session = await ElementSession.create(username, options, program.appUrl, hsUrl, program.throttleCpu);
sessions.push(session); sessions.push(session);
return session; return session;
} }

View file

@ -875,8 +875,8 @@ password_config:
# Enable sending emails for notification events # Enable sending emails for notification events
# Defining a custom URL for Riot is only needed if email notifications # Defining a custom URL for Element is only needed if email notifications
# should contain links to a self-hosted installation of Riot; when set # should contain links to a self-hosted installation of Element; when set
# the "app_name" setting is ignored. # the "app_name" setting is ignored.
# #
# If your SMTP server requires authentication, the optional smtp_user & # If your SMTP server requires authentication, the optional smtp_user &
@ -897,7 +897,7 @@ email:
notif_template_html: notif_mail.html notif_template_html: notif_mail.html
notif_template_text: notif_mail.txt notif_template_text: notif_mail.txt
notif_for_new_users: True notif_for_new_users: True
riot_base_url: "http://localhost/riot" client_base_url: "http://localhost/element"
#password_providers: #password_providers: