Skip to content
Open
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 .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ before_script:
script:
- ./cmp.sh
- .travis/test-part.sh

after_success:
- .travis/report.sh

deploy:
Expand All @@ -43,7 +45,7 @@ deploy:
skip_cleanup: true
on:
all_branches: true
condition: $TEST_PART = Sol6
condition: $TEST_PART = All
- provider: s3
access_key_id: $AWS_ACCESS_KEY_ID
secret_access_key: $AWS_SECRET_ACCESS_KEY
Expand Down
29 changes: 29 additions & 0 deletions .travis/remove-all-bot-comment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
let github = require('octonode');

var client = github.client(process.env.GITHUB_TOKEN);

async function getBotInfo() {
let ghme = client.me();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the name.
what is ghme?

const result = await ghme.infoAsync();
return result[0];
}

var ghpr = client.issue(process.env.TRAVIS_REPO_SLUG, process.env.TRAVIS_PULL_REQUEST);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use let.

and I don'lt understand the name again.
what gh stands for?
what is ghpr?
Pr is for pull request?


async function removeBotComments(bot) {
let result = await ghpr.commentsAsync();
let comments = result[0];
for (let i = 0; i < comments.length; i++) {
comment = comments[i];
if (bot == comment.user.login) {
await ghpr.deleteCommentAsync(comment.id);
}
}
}

async function main() {
let botInfo = await getBotInfo();
await removeBotComments(botInfo.login);
}

main();
19 changes: 17 additions & 2 deletions .travis/report.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
#!/bin/bash

node contractSizeReport.js $TRAVIS_PULL_REQUEST_BRANCH
node gasUsedReport.js $TRAVIS_PULL_REQUEST_BRANCH
readonly test_part=${TEST_PART:-}
case "$test_part" in
All)
if [[ $TRAVIS_PULL_REQUEST ]]; then
export sizeReport=$(node contractSizeReport.js $TRAVIS_PULL_REQUEST_BRANCH)
export gasReport=$(node gasUsedReport.js $TRAVIS_PULL_REQUEST_BRANCH)
node travis/remove-all-bot-comment.js
curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST \
-d "{\"body\": \"$sizeReport\"}" \
"https://api.github.com/repos/${TRAVIS_REPO_SLUG}/issues/${TRAVIS_PULL_REQUEST}/comments"

curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST \
-d "{\"body\": \"$gasReport\"}" \
"https://api.github.com/repos/${TRAVIS_REPO_SLUG}/issues/${TRAVIS_PULL_REQUEST}/comments"
fi
;;
esac
4 changes: 2 additions & 2 deletions contractSizeReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async function writeReport(report) {
}
fs.writeFile(reportFile, jsonContent, 'utf8', function (err) {
if (err) {
console.log('An error occured while writing JSON Object to File.');
console.log('An error occurred while writing JSON Object to File.');
return console.log(err);
}
});
Expand All @@ -59,7 +59,7 @@ async function compareContractSize() {
let remoteReport = await getRemoteReport();
if (!remoteReport) {
console.log(`Could not get report for ${argv.branch}`);
console.log("Current contract size report");
console.log('Current contract size report');
console.table(contractSizeReport);
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions gasUsedReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ async function getLocalReport() {
reportFile = `report/${process.env.TRAVIS_BRANCH}/gasUsed.json`;
}
let report = JSON.parse(fs.readFileSync(reportFile, 'utf8'));
return report
return report;
}

async function compareGasConsumtion() {
async function compareGasConsumption() {
let localReport = await getLocalReport();
let remoteReport = await getRemoteReport();
if (!remoteReport) {
Expand Down Expand Up @@ -71,4 +71,4 @@ async function compareGasConsumtion() {
}
}

compareGasConsumtion();
compareGasConsumption();
29 changes: 29 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"ethers": "5.0.4",
"ganache-cli": "6.8.2",
"mathjs": "4.4.2",
"octonode": "^0.9.5",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove ˆ

"rlp": "2.2.4",
"secp256k1": "3.8.0",
"sha3": "2.1.1",
Expand Down