mirror of https://github.com/sveltejs/svelte
Merge 9cb013fe3c
into d3da45ddb1
commit
814966054a
@ -1,10 +1,26 @@
|
|||||||
language: node_js
|
language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
- "4"
|
- '4'
|
||||||
- "6"
|
- '6'
|
||||||
- "node"
|
- node
|
||||||
|
dist: trusty
|
||||||
|
sudo: required
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
- BUILD_TIMEOUT=10000
|
- BUILD_TIMEOUT=10000
|
||||||
install: npm install
|
- BROWSER_USERNAME=paulsauve1
|
||||||
after_success: npm run codecov
|
cache:
|
||||||
|
directories:
|
||||||
|
- "$HOME/.yarn-cache"
|
||||||
|
install: yarn
|
||||||
|
after_success:
|
||||||
|
- npm run codecov
|
||||||
|
jobs:
|
||||||
|
include:
|
||||||
|
- stage: benchmark
|
||||||
|
script: node scripts/travis-bench.js
|
||||||
|
node_js: '6'
|
||||||
|
addons:
|
||||||
|
jwt:
|
||||||
|
- secure: cOK1+CViuy516Y5UokCDod1ZfdAGJophzGZuKetGuOvUVbLohJJsZkkjPGn7iCD85g3NK7cOVUmqc3+uM+xCOSPf3Hy5wEEQLY+C1hgP4c5rykg8n+MjmOHET6NSa8D9fpeWTc48Al+5l7w3PPs0SISPI/dp9voIYJl61nPuvLmbLH1YESJtrlQ10cem550Ty7alKRLuHcobtFmcdVLKHCoDmUJO7AdqgEh6n8EQRd5csBaB4VGmw7QTOqdgK5cRhWW2w5wL2eOtMNR614VRR96k3p7QW/Nzd1uIQ9PAXU+Y8OgGIyUWDvL3JjRrH74R6RNazLKoqEjR8NaVvg1zIcNYaGrmhtviwJXFpEnqf4jRNtGMqOD/XULgbmi6X8G9qG0WcR/RW2vCyRFa7bg6xb9UhAahmnxDlOOkDJkJzmyWGW9XGF/9w+UR+e8g/wKbiV+xLg+WxTj1SQioKflXWwQnP7lzBbWA/ICBpq8k/lrzQ4Js3Y8fu3K4HPRIzYQxBvoeQ9rWuR6rxD0MyrCAXYIJ/vWC/6Q1/BGVEfeOnXhweVgjy7YOVG2IL0w8cCBoYZvsE4jnV857Y6+3ZxIaVU3v/DwFRry4lwTmgVGMEMYnU5jM1ic5F0MrjuRvJnIjteWRvmIDv1fO6vPo0ypYLdDquUwlajRIns5yJU/uuD0= # browser key
|
||||||
|
- secure: BkFLjOmOLU9euAZT9H/9ezDu8s3HdvWr4fEyl0Ddgjjjna/onv1c1GQ9Xu7BG/xEa8o+oM2hXrNs+pdz2euA/pJh6fiYsc3b2XMAEytM/kg8fAUzc6YKK0wRe9HzOW0UnmULyWgqfU1mPaFN+N2TrBXDNq5cCGt+Dze+Oc6fxj/h93OWjcYgHQCTFdIPXKCfKARWqhKgIxhufge1mbdkgT8sQohMdF7sE9hBj2soimRWN1+EWpYBDSGC1rhvm07udFBwFLb2zHPLesOdOsPjNgv8Zm1A8srwNljmKbL7Z0cpJPmB/H/ZaR0tuBTPLZM1yd5f5TR6Y8yNeE7a04t/UtCoLRXw6yd4bYQxGWPjSywAB/ZX3Af0CoMrWGxe7CEJAzhvUcyUXhhQsPNo5ec/vwswDVmF+iDSEpo5IfOMw3tFAOPr7wqBHSNZx6NmHIX58h2yE3AOBozBo+Z9QbCI5fikQ91Okk0YKq9FkYABZNnZpbhxCmVPjzZuuIDZfuCulrIaKAz0WX03TJHKTTrUPc2hHAnjvk6pHXcUMc9qDFUrd5UaSsqskDBhSn/mViAt15wR3p5G2ZkDipIxGuGjvEE7MlEsWCH+OdNQtCcEX5USu3csXzUF8/OZ8B7P4ZZbL5heljNQ9sil4qQoB6IIvpGOIURcQssq+w3dF3BV3aU= # github_access_token
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DIR=./tmp/svelte-bench
|
||||||
|
REPO=https://github.com/sveltejs/svelte-bench.git
|
||||||
|
|
||||||
|
if [ ! -d $DIR ]; then
|
||||||
|
git clone $REPO $DIR
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd $DIR
|
||||||
|
git pull origin master
|
||||||
|
|
||||||
|
yarn
|
||||||
|
yarn run build:benchmarks
|
||||||
|
|
||||||
|
node ./selenium/run.js "$@"
|
@ -0,0 +1,115 @@
|
|||||||
|
const path = require('path');
|
||||||
|
const fs = require('fs');
|
||||||
|
const childProcess = require('child_process');
|
||||||
|
const fetch = require('node-fetch');
|
||||||
|
|
||||||
|
const username = process.env.BROWSER_USERNAME;
|
||||||
|
const accessKey = process.env.BROWSER_KEY;
|
||||||
|
const build = process.env.TRAVIS_BUILD_NUMBER;
|
||||||
|
const pullRequest = process.env.TRAVIS_PULL_REQUEST;
|
||||||
|
|
||||||
|
console.log(username.length, accessKey ? accessKey.length : typeof accessKey);
|
||||||
|
|
||||||
|
if (pullRequest === 'false') {
|
||||||
|
console.log('Benchmark skipped.');
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const outputFile = path.join(process.cwd(), 'tmp', 'output.txt');
|
||||||
|
|
||||||
|
const defaultCap = {
|
||||||
|
'browserstack.user': username,
|
||||||
|
'browserstack.key': accessKey,
|
||||||
|
'browserstack.debug': 'true',
|
||||||
|
build
|
||||||
|
};
|
||||||
|
|
||||||
|
const args = [
|
||||||
|
`--capabilities=${JSON.stringify([
|
||||||
|
/* {
|
||||||
|
browserName: 'safari',
|
||||||
|
version: '10.0',
|
||||||
|
platform: 'macOS 10.12',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
browserName: 'internet explorer',
|
||||||
|
version: '11.103',
|
||||||
|
platform: 'Windows 10',
|
||||||
|
},
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
browserName: 'Firefox',
|
||||||
|
os: 'Windows',
|
||||||
|
os_version: '10',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
browserName: 'chrome',
|
||||||
|
os: 'Windows',
|
||||||
|
os_version: '10',
|
||||||
|
},
|
||||||
|
].map(cap => Object.assign(cap, defaultCap)))}`,
|
||||||
|
`--server=http://hub-cloud.browserstack.com/wd/hub`,
|
||||||
|
`--custom=${process.cwd()}`,
|
||||||
|
`--output=${outputFile}`,
|
||||||
|
`--iterations=15`,
|
||||||
|
];
|
||||||
|
|
||||||
|
try {
|
||||||
|
childProcess.execFileSync(path.join(__dirname, 'benchmark.sh'), args, {
|
||||||
|
cwd: process.cwd(),
|
||||||
|
stdio: 'inherit'
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.error('An error occurred running the benchmark!');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fs.existsSync(outputFile)) {
|
||||||
|
throw new Error('Benchmark failed.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const githubUsername = 'Svelte-Bot';
|
||||||
|
const id = 29757693;
|
||||||
|
const githubToken = process.env.GITHUB_ACCESS_TOKEN;
|
||||||
|
console.log('GitHub token is of type', typeof githubToken);
|
||||||
|
const headers = {
|
||||||
|
'Authorization': `token ${githubToken}`
|
||||||
|
};
|
||||||
|
|
||||||
|
fetch(`https://api.github.com/repos/sveltejs/svelte/issues/${pullRequest}/comments`)
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(res => {
|
||||||
|
let addComment = false;
|
||||||
|
let editId = null;
|
||||||
|
console.log('[DEBUG]', res);
|
||||||
|
if (res.length === 0) {
|
||||||
|
addComment = true;
|
||||||
|
} else if (res[res.length - 1].user.id === id) {
|
||||||
|
addComment = true;
|
||||||
|
editId = res[res.length - 1].id;
|
||||||
|
} else {
|
||||||
|
addComment = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addComment) {
|
||||||
|
const contents = '<details><summary>Benchmark Results</summary>```' + fs.readFileSync(outputFile).replace(/[\r\n]+/g, '\n') + '```</details>';
|
||||||
|
let action;
|
||||||
|
if (editId === null) {
|
||||||
|
action = fetch(`https://api.github.com/repos/sveltejs/svelte/issues/${pullRequest}/comments`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers,
|
||||||
|
body: JSON.stringify({
|
||||||
|
body: contents
|
||||||
|
})
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
action = fetch(`https://api.github.com/repos/sveltejs/svelte/issues/comments/${editId}`, {
|
||||||
|
method: 'PATCH',
|
||||||
|
headers,
|
||||||
|
body: JSON.stringify({
|
||||||
|
body: contents
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return action.then(res => res.json()).then(res => console.log('[DEBUG]', res));
|
||||||
|
}
|
||||||
|
});
|
Loading…
Reference in new issue