-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui-scripts): post gerrit reviews from publish script
...to log the published version for the commit. refs INSTUI-1947 Change-Id: Ie7379438ec47f635542a3272efa058ba3ec35298 Reviewed-on: https://gerrit.instructure.com/187475 Tested-by: Jenkins Reviewed-by: Steve Jensen <sejensen@instructure.com> QA-Review: Jennifer Stern <jstern@instructure.com> Product-Review: Jennifer Stern <jstern@instructure.com>
- Loading branch information
Showing
8 changed files
with
274 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2015 - present Instructure, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
const GerritBot = require('gerritbot') | ||
const { error } = require('@instructure/command-utils') | ||
|
||
const { | ||
SSH_USERNAME, | ||
GERRIT_HOST, | ||
GERRIT_PORT, | ||
SSH_KEY_PATH | ||
} = process.env | ||
|
||
let gerrit | ||
|
||
function gerritClient () { | ||
if (!gerrit) { | ||
gerrit = new GerritBot.Client({ | ||
user: SSH_USERNAME, | ||
host: GERRIT_HOST, | ||
keyFile: SSH_KEY_PATH, | ||
sshPort: parseInt(GERRIT_PORT) | ||
}) | ||
} | ||
return gerrit | ||
} | ||
|
||
exports.postGerritReview = async function postGerritReview (target, message, labels = {}) { | ||
return new Promise((resolve, reject) => { | ||
gerritClient().review(target, { message, labels }, (err) => { | ||
if (err) { | ||
error(`An error occured posting a gerrit review for ${target}.`) | ||
error(err) | ||
reject(err) | ||
} else { | ||
resolve() | ||
} | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.