Skip to content

Commit

Permalink
Use source repo for live validation (#2238)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlad Barosan authored Jan 10, 2018
1 parent e7a671f commit 7efa3c5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
4 changes: 2 additions & 2 deletions scripts/liveValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const utils = require('../test/util/utils'),
request = require('request-promise-native'),
zlib = require('zlib');

const repoUrl = utils.getRepoUrl(),
const repoUrl = utils.getSourceRepoUrl(),
validationService = "https://app.azure-devex-tools.com/api/validations",
branch = utils.getSourceBranch(),
processingDelay = 20,
Expand Down Expand Up @@ -75,7 +75,7 @@ async function runScript() {
let validationId = JSON.parse(response).validationId;

let validationResultUrl = `${validationService}/${validationId}`;
console.log(`Request done, results will in ${durationInSeconds} seconds...`);
console.log(`Request done, results will be available in ${durationInSeconds} seconds...`);

await timeout((durationInSeconds + processingDelay) * 1000);
let validationResult = JSON.parse(await request(validationResultUrl));
Expand Down
27 changes: 25 additions & 2 deletions test/util/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,20 @@ exports.getPullRequestNumber = function getPullRequestNumber() {
*/
exports.getRepoName = function getRepoName() {
let result = process.env['TRAVIS_REPO_SLUG'];
console.log(`@@@@@ process.env['TRAVIS_REPO_SLUG'] - ${process.env['TRAVIS_REPO_SLUG']}`);
console.log(`@@@@@ process.env['TRAVIS_REPO_SLUG'] - ${result}`);

return result;
};

/**
* Gets the source repo name for PR's. We are using the environment
* variable provided by travis-ci. It is called TRAVIS_PULL_REQUEST_SLUG. More info can be found here:
* https://docs.travis-ci.com/user/environment-variables/#Convenience-Variables
* @returns {string} repo name or 'undefined'.
*/
exports.getSourceRepoName = function getSourceRepoName() {
let result = process.env['TRAVIS_PULL_REQUEST_SLUG'];
console.log(`@@@@@ process.env['TRAVIS_PULL_REQUEST_SLUG'] - ${result}`);

return result;
};
Expand All @@ -151,7 +164,17 @@ exports.getRepoName = function getRepoName() {
exports.getRepoUrl = function getRepoUrl() {
let repoName = exports.getRepoName();
return `https://github.com/${repoName}`;
}
};

// Retrieves the source Git Repository Url
/**
* Gets the repo URL from where the PR originated
* @returns {string} repo URL or 'undefined'
*/
exports.getSourceRepoUrl = function getSourceRepoUrl() {
let repoName = exports.getSourceRepoName();
return `https://github.com/${repoName}`;
};

exports.getTimeStamp = function getTimeStamp() {
// We pad each value so that sorted directory listings show the files in chronological order
Expand Down

0 comments on commit 7efa3c5

Please sign in to comment.