Skip to content

Commit e42e3a0

Browse files
committed
add report on github comment
1 parent 4d2292d commit e42e3a0

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ before_script:
2929
script:
3030
- ./cmp.sh
3131
- .travis/test-part.sh
32+
33+
after_success:
3234
- .travis/report.sh
3335

3436
deploy:

.travis/remove-all-bot-comment.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
let github = require('octonode');
2+
3+
var client = github.client(process.env.GITHUB_TOKEN);
4+
5+
async function getBotInfo() {
6+
let ghme = client.me();
7+
const result = await ghme.infoAsync();
8+
return result[0];
9+
}
10+
11+
var ghpr = client.issue(process.env.TRAVIS_REPO_SLUG, process.env.TRAVIS_PULL_REQUEST);
12+
13+
async function removeBotComments(bot) {
14+
let result = await ghpr.commentsAsync();
15+
let comments = result[0];
16+
for (let i = 0; i < comments.length; i++) {
17+
comment = comments[i];
18+
if (bot == comment.user.login) {
19+
await ghpr.deleteCommentAsync(comment.id);
20+
}
21+
}
22+
}
23+
24+
async function main() {
25+
let botInfo = await getBotInfo();
26+
await removeBotComments(botInfo.login);
27+
}
28+
29+
main();

.travis/report.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
#!/bin/bash
22

3-
node contractSizeReport.js $TRAVIS_PULL_REQUEST_BRANCH
4-
node gasUsedReport.js $TRAVIS_PULL_REQUEST_BRANCH
3+
sizeReport = `node contractSizeReport.js $TRAVIS_PULL_REQUEST_BRANCH`
4+
gasReport = `node gasUsedReport.js $TRAVIS_PULL_REQUEST_BRANCH`
5+
6+
if [[ $TRAVIS_PULL_REQUEST ]]; then
7+
node travis/remove-all-bot-comment.js
8+
curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST \
9+
-d "{\"body\": \"$sizeReport\"}" \
10+
"https://api.github.com/repos/${TRAVIS_REPO_SLUG}/issues/${TRAVIS_PULL_REQUEST}/comments"
11+
12+
curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST \
13+
-d "{\"body\": \"$gasReport\"}" \
14+
"https://api.github.com/repos/${TRAVIS_REPO_SLUG}/issues/${TRAVIS_PULL_REQUEST}/comments"

0 commit comments

Comments
 (0)