Skip to content

Commit

Permalink
Add verification probot for release PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinGrandon authored and fusion-bot[bot] committed Feb 23, 2018
1 parent 347d1e1 commit fe86236
Show file tree
Hide file tree
Showing 3 changed files with 172 additions and 5 deletions.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@
"probot-app-release",
"probot-app-release-notes",
"probot-app-release-pr-compare",
"probot-app-todos"
"probot-app-todos",
"./src/release-verification.js"
]
},
"engines": {
"node": "^8.9.0"
},
"devDependencies": {
"smee-client": "^1.0.1"
}
}
73 changes: 73 additions & 0 deletions src/release-verification.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/** Copyright (c) 2017 Uber Technologies, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

const exec = require('child_process').exec;

module.exports = robot => {
robot.on('pull_request.labeled', check);

async function check(context) {
const {github} = context;
const pr = context.payload.pull_request;

// set status to pending while checks happen
setStatus(context, {
state: 'pending',
description: 'Checking whether to start a verification build.',
});

const isRelease = context.payload.label.name === 'release';
if (!isRelease) {
return setStatus(context, {
state: 'success',
description: 'Verification run is not necessary.',
});
}

const curlCommand = `curl \
-H "Authorization: Bearer ${process.env.BUILDKITE_TOKEN}" \
-X POST "https://api.buildkite.com/v2/organizations/uberopensource/pipelines/fusion-release-verification/builds" \
-d '{
"commit": "HEAD",
"branch": "master",
"message": "${pr.base.repo.name}, ${pr.title} - release verification",
"author": {
"name": "${pr.user.login}"
}
}'`;

exec(curlCommand, (error, stdout) => {
if (error !== null) {
// eslint-disable-next-line no-console
console.warn('exec error: ' + error);
}
const output = JSON.parse(stdout);
github.issues.createComment(
context.issue({
body: `Triggered Fusion.js build verification: ${output.web_url}`,
}),
);
});

// set status to success
setStatus(context, {
state: 'success',
description: 'Verification run has been started.',
});
}
};

async function setStatus(context, {state, description}) {
const {github} = context;
return github.repos.createStatus(
context.issue({
state,
description,
sha: context.payload.pull_request.head.sha,
context: 'probot/label-release-pr',
}),
);
}
98 changes: 94 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,12 @@ [email protected], base64url@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/base64url/-/base64url-2.0.0.tgz#eac16e03ea1438eff9423d69baa36262ed1f70bb"

basic-auth@~2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/basic-auth/-/basic-auth-2.0.0.tgz#015db3f353e02e56377755f962742e8981e7bbba"
dependencies:
safe-buffer "5.1.1"

bcrypt-pbkdf@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz#63bc5dcb61331b92bc05fd528953c33462a06f8d"
Expand Down Expand Up @@ -603,6 +609,12 @@ color-name@^1.1.1:
version "1.1.3"
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25"

[email protected]:
version "1.0.6"
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.6.tgz#723e7df6e801ac5613113a7e445a9b69cb632818"
dependencies:
delayed-stream "~1.0.0"

combined-stream@^1.0.5, combined-stream@~1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.5.tgz#938370a57b4a51dea2c77c15d5c5fdf895164009"
Expand All @@ -613,6 +625,14 @@ commander@^2.11.0:
version "2.13.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c"

commander@^2.12.2:
version "2.14.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.14.1.tgz#2235123e37af8ca3c65df45b026dbd357b01b9aa"

component-emitter@^1.2.0:
version "1.2.1"
resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6"

compromise@^11.1.0:
version "11.2.3"
resolved "https://registry.yarnpkg.com/compromise/-/compromise-11.2.3.tgz#5f2b33fdd4188e47f3a9a551e732a14a865d85d0"
Expand Down Expand Up @@ -651,6 +671,10 @@ [email protected]:
version "0.3.1"
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb"

cookiejar@^2.1.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.1.1.tgz#41ad57b1b555951ec171412a81942b1e8200d34a"

core-js@^2.4.0, core-js@^2.5.0:
version "2.5.3"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.3.tgz#8acc38345824f16d8365b7c9b4259168e8ed603e"
Expand Down Expand Up @@ -1001,7 +1025,7 @@ express@^4.15.4, express@^4.16.2:
utils-merge "1.0.1"
vary "~1.1.2"

extend@3, extend@~3.0.0, extend@~3.0.1:
extend@3, extend@^3.0.0, extend@~3.0.0, extend@~3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444"

Expand Down Expand Up @@ -1118,6 +1142,14 @@ forever-agent@~0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91"

form-data@^2.3.1:
version "2.3.2"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.2.tgz#4970498be604c20c005d4f5c23aecd21d6b49099"
dependencies:
asynckit "^0.4.0"
combined-stream "1.0.6"
mime-types "^2.1.12"

form-data@~2.1.1:
version "2.1.4"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.1.4.tgz#33c183acf193276ecaa98143a69e94bfee1750d1"
Expand All @@ -1134,6 +1166,10 @@ form-data@~2.3.1:
combined-stream "^1.0.5"
mime-types "^2.1.12"

formidable@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/formidable/-/formidable-1.1.1.tgz#96b8886f7c3c3508b932d6bd70c4d3a88f35f1a9"

forwarded@~0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84"
Expand Down Expand Up @@ -2468,7 +2504,7 @@ merge@^1.1.3:
version "1.2.0"
resolved "https://registry.yarnpkg.com/merge/-/merge-1.2.0.tgz#7531e39d4949c281a66b8c5a6e0265e8b05894da"

methods@~1.1.2:
methods@^1.1.1, methods@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee"

Expand Down Expand Up @@ -2504,7 +2540,7 @@ [email protected]:
version "1.4.1"
resolved "https://registry.yarnpkg.com/mime/-/mime-1.4.1.tgz#121f9ebc49e3766f311a76e1fa1c8003c4b03aa6"

mime@^1.2.11:
mime@^1.2.11, mime@^1.4.1:
version "1.6.0"
resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1"

Expand Down Expand Up @@ -2544,6 +2580,16 @@ moment@^2.10.6:
version "2.20.1"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.20.1.tgz#d6eb1a46cbcc14a2b2f9434112c1ff8907f313fd"

morgan@^1.9.0:
version "1.9.0"
resolved "https://registry.yarnpkg.com/morgan/-/morgan-1.9.0.tgz#d01fa6c65859b76fcf31b3cb53a3821a311d8051"
dependencies:
basic-auth "~2.0.0"
debug "2.6.9"
depd "~1.1.1"
on-finished "~2.3.0"
on-headers "~1.0.1"

[email protected]:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
Expand Down Expand Up @@ -2697,6 +2743,10 @@ on-finished@~2.3.0:
dependencies:
ee-first "1.1.1"

on-headers@~1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/on-headers/-/on-headers-1.0.1.tgz#928f5d0f470d49342651ea6794b0857c100693f7"

once@^1.3.0, once@^1.3.3, once@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
Expand Down Expand Up @@ -3098,6 +3148,10 @@ process-nextick-args@~1.0.6:
version "1.0.7"
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3"

process-nextick-args@~2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa"

promise-events@^0.1.3:
version "0.1.4"
resolved "https://registry.yarnpkg.com/promise-events/-/promise-events-0.1.4.tgz#3c88fae97e448da68f7fcf19d4ee308d6e432d5b"
Expand Down Expand Up @@ -3125,7 +3179,7 @@ punycode@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.0.tgz#5f863edc89b96db09074bad7947bf09056ca4e7d"

[email protected], qs@~6.5.1:
[email protected], qs@^6.5.1, qs@~6.5.1:
version "6.5.1"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8"

Expand Down Expand Up @@ -3218,6 +3272,18 @@ readable-stream@^2.0.1, readable-stream@^2.0.6, readable-stream@^2.1.4:
string_decoder "~1.0.3"
util-deprecate "~1.0.1"

readable-stream@^2.0.5:
version "2.3.4"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.4.tgz#c946c3f47fa7d8eabc0b6150f4a12f69a4574071"
dependencies:
core-util-is "~1.0.0"
inherits "~2.0.3"
isarray "~1.0.0"
process-nextick-args "~2.0.0"
safe-buffer "~5.1.1"
string_decoder "~1.0.3"
util-deprecate "~1.0.1"

readable-stream@~2.0.5:
version "2.0.6"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.0.6.tgz#8f90341e68a53ccc928788dacfcd11b36eb9b78e"
Expand Down Expand Up @@ -3476,6 +3542,15 @@ slash@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55"

smee-client@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/smee-client/-/smee-client-1.0.1.tgz#b4add6fc3208c82032ba1a5e704330234eb0c402"
dependencies:
commander "^2.12.2"
eventsource "^1.0.5"
morgan "^1.9.0"
superagent "^3.8.1"

[email protected]:
version "1.0.9"
resolved "https://registry.yarnpkg.com/sntp/-/sntp-1.0.9.tgz#6541184cc90aeea6c6e7b35e2659082443c66198"
Expand Down Expand Up @@ -3636,6 +3711,21 @@ strip-json-comments@~2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"

superagent@^3.8.1:
version "3.8.2"
resolved "https://registry.yarnpkg.com/superagent/-/superagent-3.8.2.tgz#e4a11b9d047f7d3efeb3bbe536d9ec0021d16403"
dependencies:
component-emitter "^1.2.0"
cookiejar "^2.1.0"
debug "^3.1.0"
extend "^3.0.0"
form-data "^2.3.1"
formidable "^1.1.1"
methods "^1.1.1"
mime "^1.4.1"
qs "^6.5.1"
readable-stream "^2.0.5"

supports-color@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
Expand Down

0 comments on commit fe86236

Please sign in to comment.