Skip to content

Commit

Permalink
Merge b20defa into 97f84ae
Browse files Browse the repository at this point in the history
  • Loading branch information
thatkookooguy committed Dec 19, 2019
2 parents 97f84ae + b20defa commit 86b3fc2
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 8 deletions.
52 changes: 52 additions & 0 deletions deploy-test-results.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env node

const {
exec
} = require('child_process');

const travisPullRequest = process.env.TRAVIS_PULL_REQUEST;
const nowToken = process.env.NOW_TOKEN;
const isTravis = process.env.TRAVIS;

if (!isTravis || !travisPullRequest) {
console.info('not running on a travis pull request job. silently quitting...');
process.exit(0);
}

if (!nowToken) {
console.error('required environment variable NOW_TOKEN is not set');
throw new Error('required environment variable NOW_TOKEN is not set');
}

exec(`now alias --token=${nowToken} $(now ./test-results --no-clipboard --token=${nowToken} --public) achievibit-pr-${ travisPullRequest }`,
async (err, stdout, stderr) => {
if (err) {
console.error(err);
// node couldn't execute the command
return;
}

const Octokit = require("@octokit/rest");
const auth = process.env.GH_TOKEN;
const octokit = new Octokit({ auth });

const prSlug = process.env.TRAVIS_PULL_REQUEST_SLUG;

const splitted = prSlug.split('\/');

const testReportUrl = `https://achievibit-pr-${ travisPullRequest }.now.sh`

const comment = {
repo: splitted[1],
owner: splitted[0],
issue_number: travisPullRequest,
body: 'Test report is available on ' + testReportUrl
};

const response = await octokit.issues.createComment(comment);

// the *entire* stdout and stderr (buffered)
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
console.log(response);
});
7 changes: 0 additions & 7 deletions deploy-test-results.sh

This file was deleted.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"generate-barrels": "barrelsby --delete -d ./src -l below -q",
"coveralls": "cat ./test-results/coverage/lcov.info | coveralls",
"commit": "npx git-cz",
"deploy-tests-report": "./deploy-test-results.sh"
"deploy-tests-report": "./deploy-test-results.js"
},
"dependencies": {
"@hapi/joi": "^16.1.8",
Expand Down Expand Up @@ -64,6 +64,7 @@
"@nestjs/schematics": "^6.7.0",
"@nestjs/testing": "^6.7.1",
"@nestjs/typeorm": "^6.2.0",
"@octokit/rest": "^16.35.2",
"@types/chance": "^1.0.7",
"@types/depcheck": "^0.9.1",
"@types/dotenv": "^8.2.0",
Expand Down

0 comments on commit 86b3fc2

Please sign in to comment.