pull/684/merge
Paul Sauve 8 years ago committed by GitHub
commit 814966054a

1
.gitignore vendored

@ -12,5 +12,6 @@ coverage.lcov
test/sourcemaps/samples/*/output.js test/sourcemaps/samples/*/output.js
test/sourcemaps/samples/*/output.js.map test/sourcemaps/samples/*/output.js.map
_actual.* _actual.*
tmp
_actual-bundle.* _actual-bundle.*
src/generators/dom/shared.ts src/generators/dom/shared.ts

@ -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

@ -16,6 +16,7 @@
"codecov": "codecov", "codecov": "codecov",
"precodecov": "npm run coverage", "precodecov": "npm run coverage",
"lint": "eslint src test/*.js", "lint": "eslint src test/*.js",
"benchmark": "./scripts/benchmark.sh",
"build": "node src/shared/_build.js && rollup -c", "build": "node src/shared/_build.js && rollup -c",
"dev": "node src/shared/_build.js && rollup -c -w", "dev": "node src/shared/_build.js && rollup -c -w",
"pretest": "npm run build", "pretest": "npm run build",
@ -67,6 +68,7 @@
"locate-character": "^2.0.0", "locate-character": "^2.0.0",
"magic-string": "^0.22.3", "magic-string": "^0.22.3",
"mocha": "^3.2.0", "mocha": "^3.2.0",
"node-fetch": "^1.7.1",
"node-resolve": "^1.3.3", "node-resolve": "^1.3.3",
"nyc": "^10.0.0", "nyc": "^10.0.0",
"prettier": "^1.4.1", "prettier": "^1.4.1",

@ -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));
}
});

@ -1014,6 +1014,12 @@ electron-to-chromium@^1.2.7:
version "1.3.8" version "1.3.8"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.8.tgz#b2c8a2c79bb89fbbfd3724d9555e15095b5f5fb6" resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.8.tgz#b2c8a2c79bb89fbbfd3724d9555e15095b5f5fb6"
encoding@^0.1.11:
version "0.1.12"
resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb"
dependencies:
iconv-lite "~0.4.13"
entities@^1.1.1, entities@~1.1.1: entities@^1.1.1, entities@~1.1.1:
version "1.1.1" version "1.1.1"
resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0" resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0"
@ -1533,7 +1539,7 @@ http-signature@~1.1.0:
jsprim "^1.2.2" jsprim "^1.2.2"
sshpk "^1.7.0" sshpk "^1.7.0"
iconv-lite@0.4.13: iconv-lite@0.4.13, iconv-lite@~0.4.13:
version "0.4.13" version "0.4.13"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.13.tgz#1f88aba4ab0b1508e8312acc39345f36e992e2f2" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.13.tgz#1f88aba4ab0b1508e8312acc39345f36e992e2f2"
@ -1691,6 +1697,10 @@ is-resolvable@^1.0.0:
dependencies: dependencies:
tryit "^1.0.1" tryit "^1.0.1"
is-stream@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"
is-typedarray@~1.0.0: is-typedarray@~1.0.0:
version "1.0.0" version "1.0.0"
resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a"
@ -2082,6 +2092,13 @@ natural-compare@^1.4.0:
version "1.4.0" version "1.4.0"
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
node-fetch@^1.7.1:
version "1.7.1"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.1.tgz#899cb3d0a3c92f952c47f1b876f4c8aeabd400d5"
dependencies:
encoding "^0.1.11"
is-stream "^1.0.1"
node-resolve@^1.3.3: node-resolve@^1.3.3:
version "1.3.3" version "1.3.3"
resolved "https://registry.yarnpkg.com/node-resolve/-/node-resolve-1.3.3.tgz#74c7f5d3373e4bb2f60182e3a96dde0f8aacb0ce" resolved "https://registry.yarnpkg.com/node-resolve/-/node-resolve-1.3.3.tgz#74c7f5d3373e4bb2f60182e3a96dde0f8aacb0ce"

Loading…
Cancel
Save