Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"start:test": "lerna run start:test --scope app --stream",
"start:vscode": "cross-env VSCODE=1 yarn start:fast & cd standalone-packages/monaco-editor && yarn simpleserver & cd standalone-packages/vscode && yarn watch",
"test": "lerna run test --ignore codesandbox-browserfs",
"test:pr": "node testpr-script",
"test:ci": "lerna run test --ignore codesandbox-browserfs -- --ci --testResultsProcessor=\"jest-junit\" ",
"test:integrations": "lerna exec --scope app --stream -- yarn test:integrations",
"test:jest-lite": "lerna exec --scope app --stream -- yarn run test jest-lite --watch --coverage",
Expand Down Expand Up @@ -86,7 +87,8 @@
"lint-staged": "^9.2.5",
"prettier": "1.17.0",
"pretty-quick": "^1.10.0",
"typescript": "3.6.3"
"typescript": "3.6.3",
"username": "^5.1.0"
},
"husky": {
"hooks": {
Expand Down
57 changes: 57 additions & 0 deletions testpr-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
const { spawn } = require('child_process');
const { argv } = require('yargs');
const username = require('username');

const id = argv._[0];

function spawnPromise(command, args) {
return new Promise((resolve, reject) => {
const p = spawn(command, args);

p.stdout.on('data', data => {
// eslint-disable-next-line
console.log(data.toString());
});

p.stderr.on('data', data => {
console.error(data.toString());
});

p.on('exit', code => {
if (code === 0) {
resolve();
} else {
reject();
}
});
});
}

async function test(prId) {
const branchName = `pr-${username.sync()}-${prId}`;

Promise.resolve()
.then(() => spawnPromise('git', ['checkout', 'master']))
.then(() => spawnPromise('git', ['pull']))
.then(() =>
spawnPromise('git', [
'fetch',
'origin',
`pull/${prId}/head:${branchName}`,
])
)
.then(() => spawnPromise('git', ['checkout', branchName]))
.then(() => spawnPromise('git', ['merge', 'master']))
.then(() => spawnPromise('yarn', ['build:deps']))
.catch(() => {
console.error(
'Something wrong happened building the deps, maybe missing a new package added. Please install and run build:deps manually before continuing'
);
});
}

if (id && Number(id)) {
test(Number(id));
} else {
throw new Error('You have to pass the ID of a PR, ex: yarn test:pr 1234');
}
10 changes: 9 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17042,7 +17042,7 @@ mem@^1.1.0:
dependencies:
mimic-fn "^1.0.0"

mem@^4.0.0:
mem@^4.0.0, mem@^4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/mem/-/mem-4.3.0.tgz#461af497bc4ae09608cdb2e60eefb69bff744178"
integrity sha512-qX2bG48pTqYRVmDB37rn/6PT7LcR8T7oAX3bf99u1Tt1nzxYfxkgqDwUwolPlXweM0XzBOBFzSx4kfp7KP1s/w==
Expand Down Expand Up @@ -25865,6 +25865,14 @@ user-home@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190"

username@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/username/-/username-5.1.0.tgz#a7f9325adce2d0166448cdd55d4985b1360f2508"
integrity sha512-PCKbdWw85JsYMvmCv5GH3kXmM66rCd9m1hBEDutPNv94b/pqCMT4NtcKyeWYvLFiE8b+ha1Jdl8XAaUdPn5QTg==
dependencies:
execa "^1.0.0"
mem "^4.3.0"

utif@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/utif/-/utif-2.0.1.tgz#9e1582d9bbd20011a6588548ed3266298e711759"
Expand Down