Skip to content

Commit

Permalink
build(travis): run travis comment command to comment benchmarking res…
Browse files Browse the repository at this point in the history
…ults
  • Loading branch information
tusharmath committed Nov 13, 2016
1 parent eae7028 commit d5859f3
Show file tree
Hide file tree
Showing 4 changed files with 883 additions and 808 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Expand Up @@ -8,14 +8,13 @@ notifications:
node_js:
- 'stable'
before_install:
- pip install travis_bot
- npm i -g typings
- typings install
- npm i -g npm@^2.0.0
before_script:
- npm prune
- npm run lint
- npm run benchmark | travis_bot
- npm run benchmark | node .dist/travis-comment
- npm run coverage
after_success:
- npm run semantic-release
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -34,6 +34,7 @@
"cz-conventional-changelog": "^1.2.0",
"ghooks": "^1.3.2",
"nyc": "^8.3.1",
"request-promise": "^4.1.1",
"rollup": "^0.36.3",
"rollup-plugin-commonjs": "^5.0.5",
"semantic-release": "^4.3.5",
Expand Down
39 changes: 39 additions & 0 deletions travis-comment.ts
@@ -0,0 +1,39 @@
/**
* Created by tushar.mathur on 13/11/16.
*/

const rp = require('request-promise')


let body = ''
process.stdin.resume()
process.stdin.setEncoding('utf8')
process.stdin.on('data', (chunk: string) => body += chunk)
process.stdin.on('end', () => main().then(
x => console.log('Success'),
function (err) {
console.error(err.message)
}
))

function getParams () {
const [owner, repo] = process.env.TRAVIS_REPO_SLUG.split('/')
return {
owner, repo,
number: process.env.TRAVIS_PULL_REQUEST
}
}

async function main () {
if (!process.env.TRAVIS_PULL_REQUEST) return
const p = getParams()
const uri = `https://api.github.com/repos/${p.owner}/${p.repo}/issues/${p.number}/comments`
return rp({
uri,
method: 'POST',
body: {body},
json: true,
headers: {'User-Agent': p.repo},
qs: {access_token: process.env.GH_TOKEN}
})
}

0 comments on commit d5859f3

Please sign in to comment.