Skip to content

Commit

Permalink
Merge branch 'main' into chirag-nonChat-headers
Browse files Browse the repository at this point in the history
  • Loading branch information
chiragsalian committed Jun 30, 2023
2 parents 950f7d1 + 50c16ac commit 1b958b8
Show file tree
Hide file tree
Showing 175 changed files with 10,089 additions and 2,284 deletions.
17 changes: 2 additions & 15 deletions .github/actions/javascript/authorChecklist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,6 @@ class GithubUtils {
) {
return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL))
.then((data) => {
const automatedPRs = _.pluck(_.filter(data, GithubUtils.isAutomatedPullRequest), 'html_url');
console.log('Filtering out the following automated pull requests:', automatedPRs);

// The format of this map is following:
// {
// 'https://github.com/Expensify/App/pull/9641': [ 'PauloGasparSv', 'kidroca' ],
Expand All @@ -366,7 +363,7 @@ class GithubUtils {
console.log('Found the following NO QA PRs:', noQAPRs);
const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs);

const sortedPRList = _.chain(PRList).difference(automatedPRs).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value();
const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value();
const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL);

// Tag version and comparison URL
Expand Down Expand Up @@ -423,7 +420,7 @@ class GithubUtils {
issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n';
return issueBody;
})
.catch((err) => console.warn('Error generating StagingDeployCash issue body!', 'Automated PRs may not be properly filtered out. Continuing...', err));
.catch((err) => console.warn('Error generating StagingDeployCash issue body! Continuing...', err));
}

/**
Expand Down Expand Up @@ -603,16 +600,6 @@ class GithubUtils {
return Number.parseInt(matches[1], 10);
}

/**
* Determine if a given pull request is an automated PR.
*
* @param {Object} pullRequest
* @returns {Boolean}
*/
static isAutomatedPullRequest(pullRequest) {
return _.isEqual(lodashGet(pullRequest, 'user.login', ''), CONST.OS_BOTIFY);
}

/**
* Return the login of the actor who closed an issue or PR. If the issue is not closed, return an empty string.
*
Expand Down
17 changes: 2 additions & 15 deletions .github/actions/javascript/awaitStagingDeploys/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,6 @@ class GithubUtils {
) {
return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL))
.then((data) => {
const automatedPRs = _.pluck(_.filter(data, GithubUtils.isAutomatedPullRequest), 'html_url');
console.log('Filtering out the following automated pull requests:', automatedPRs);

// The format of this map is following:
// {
// 'https://github.com/Expensify/App/pull/9641': [ 'PauloGasparSv', 'kidroca' ],
Expand All @@ -404,7 +401,7 @@ class GithubUtils {
console.log('Found the following NO QA PRs:', noQAPRs);
const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs);

const sortedPRList = _.chain(PRList).difference(automatedPRs).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value();
const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value();
const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL);

// Tag version and comparison URL
Expand Down Expand Up @@ -461,7 +458,7 @@ class GithubUtils {
issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n';
return issueBody;
})
.catch((err) => console.warn('Error generating StagingDeployCash issue body!', 'Automated PRs may not be properly filtered out. Continuing...', err));
.catch((err) => console.warn('Error generating StagingDeployCash issue body! Continuing...', err));
}

/**
Expand Down Expand Up @@ -641,16 +638,6 @@ class GithubUtils {
return Number.parseInt(matches[1], 10);
}

/**
* Determine if a given pull request is an automated PR.
*
* @param {Object} pullRequest
* @returns {Boolean}
*/
static isAutomatedPullRequest(pullRequest) {
return _.isEqual(lodashGet(pullRequest, 'user.login', ''), CONST.OS_BOTIFY);
}

/**
* Return the login of the actor who closed an issue or PR. If the issue is not closed, return an empty string.
*
Expand Down
17 changes: 2 additions & 15 deletions .github/actions/javascript/checkDeployBlockers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,6 @@ class GithubUtils {
) {
return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL))
.then((data) => {
const automatedPRs = _.pluck(_.filter(data, GithubUtils.isAutomatedPullRequest), 'html_url');
console.log('Filtering out the following automated pull requests:', automatedPRs);

// The format of this map is following:
// {
// 'https://github.com/Expensify/App/pull/9641': [ 'PauloGasparSv', 'kidroca' ],
Expand All @@ -371,7 +368,7 @@ class GithubUtils {
console.log('Found the following NO QA PRs:', noQAPRs);
const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs);

const sortedPRList = _.chain(PRList).difference(automatedPRs).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value();
const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value();
const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL);

// Tag version and comparison URL
Expand Down Expand Up @@ -428,7 +425,7 @@ class GithubUtils {
issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n';
return issueBody;
})
.catch((err) => console.warn('Error generating StagingDeployCash issue body!', 'Automated PRs may not be properly filtered out. Continuing...', err));
.catch((err) => console.warn('Error generating StagingDeployCash issue body! Continuing...', err));
}

/**
Expand Down Expand Up @@ -608,16 +605,6 @@ class GithubUtils {
return Number.parseInt(matches[1], 10);
}

/**
* Determine if a given pull request is an automated PR.
*
* @param {Object} pullRequest
* @returns {Boolean}
*/
static isAutomatedPullRequest(pullRequest) {
return _.isEqual(lodashGet(pullRequest, 'user.login', ''), CONST.OS_BOTIFY);
}

/**
* Return the login of the actor who closed an issue or PR. If the issue is not closed, return an empty string.
*
Expand Down
73 changes: 35 additions & 38 deletions .github/actions/javascript/createOrUpdateStagingDeploy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,38 +218,48 @@ const CONST = __nccwpck_require__(4097);
const sanitizeStringForJSONParse = __nccwpck_require__(9338);

/**
* @param {String} ref
* @param {String} tag
*/
function fetchRefIfNeeded(ref) {
// eslint-disable-next-line no-unused-vars
function fetchTagIfNeeded(tag) {
try {
console.log(`Checking if ref ${ref} exists locally`);
const command = `git rev-parse --verify ${ref}`;
console.log(`Checking if tag ${tag} exists locally`);
const command = `git rev-parse --verify ${tag}`;
console.log(`Running command: ${command}`);
execSync(command);
const result = execSync(command).toString();
console.log(result);
} catch (e) {
console.log(`Ref ${ref} not found locally, attempting to fetch it.`);
const command = `git fetch origin ${ref}`;
console.log(`Tag ${tag} not found locally, attempting to fetch it.`);
let command = `git fetch origin tag ${tag} --no-tags`;
console.log(`Running command: ${command}`);
execSync(command);
let result = execSync(command).toString();
console.log(result);
console.log('Verifying that the tag is now available...');
command = `git rev-parse --verify ${tag}`;
console.log(`Running command: ${command}`);
result = execSync(command).toString();
console.log(result);
}
}

/**
* Get merge logs between two refs (inclusive) as a JavaScript object.
* Get merge logs between two tags (inclusive) as a JavaScript object.
*
* @param {String} fromRef
* @param {String} toRef
* @param {String} fromTag
* @param {String} toTag
* @returns {Promise<Array<Object<{commit: String, subject: String, authorName: String}>>>}
*/
function getCommitHistoryAsJSON(fromRef, toRef) {
fetchRefIfNeeded(fromRef);
fetchRefIfNeeded(toRef);
function getCommitHistoryAsJSON(fromTag, toTag) {
// fetchTagIfNeeded(fromTag);
// fetchTagIfNeeded(toTag);
// Note: this is a temporary measure until we can figure out a faster way to fetch only what's needed
execSync('git fetch --all --tags');

console.log('Getting pull requests merged between the following refs:', fromRef, toRef);
console.log('Getting pull requests merged between the following tags:', fromTag, toTag);
return new Promise((resolve, reject) => {
let stdout = '';
let stderr = '';
const args = ['log', '--format={"commit": "%H", "authorName": "%an", "subject": "%s"},', `${fromRef}...${toRef}`];
const args = ['log', '--format={"commit": "%H", "authorName": "%an", "subject": "%s"},', `${fromTag}...${toTag}`];
console.log(`Running command: git ${args.join(' ')}`);
const spawnedProcess = spawn('git', args);
spawnedProcess.on('message', console.log);
Expand Down Expand Up @@ -314,19 +324,19 @@ function getValidMergedPRs(commits) {
}

/**
* Takes in two git refs and returns a list of PR numbers of all PRs merged between those two refs
* Takes in two git tags and returns a list of PR numbers of all PRs merged between those two tags
*
* @param {String} fromRef
* @param {String} toRef
* @param {String} fromTag
* @param {String} toTag
* @returns {Promise<Array<String>>} – Pull request numbers
*/
function getPullRequestsMergedBetween(fromRef, toRef) {
return getCommitHistoryAsJSON(fromRef, toRef).then((commitList) => {
console.log(`Commits made between ${fromRef} and ${toRef}:`, commitList);
function getPullRequestsMergedBetween(fromTag, toTag) {
return getCommitHistoryAsJSON(fromTag, toTag).then((commitList) => {
console.log(`Commits made between ${fromTag} and ${toTag}:`, commitList);

// Find which commit messages correspond to merged PR's
const pullRequestNumbers = getValidMergedPRs(commitList);
console.log(`List of pull requests merged between ${fromRef} and ${toRef}`, pullRequestNumbers);
console.log(`List of pull requests merged between ${fromTag} and ${toTag}`, pullRequestNumbers);
return pullRequestNumbers;
});
}
Expand Down Expand Up @@ -577,9 +587,6 @@ class GithubUtils {
) {
return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL))
.then((data) => {
const automatedPRs = _.pluck(_.filter(data, GithubUtils.isAutomatedPullRequest), 'html_url');
console.log('Filtering out the following automated pull requests:', automatedPRs);

// The format of this map is following:
// {
// 'https://github.com/Expensify/App/pull/9641': [ 'PauloGasparSv', 'kidroca' ],
Expand All @@ -603,7 +610,7 @@ class GithubUtils {
console.log('Found the following NO QA PRs:', noQAPRs);
const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs);

const sortedPRList = _.chain(PRList).difference(automatedPRs).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value();
const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value();
const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL);

// Tag version and comparison URL
Expand Down Expand Up @@ -660,7 +667,7 @@ class GithubUtils {
issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n';
return issueBody;
})
.catch((err) => console.warn('Error generating StagingDeployCash issue body!', 'Automated PRs may not be properly filtered out. Continuing...', err));
.catch((err) => console.warn('Error generating StagingDeployCash issue body! Continuing...', err));
}

/**
Expand Down Expand Up @@ -840,16 +847,6 @@ class GithubUtils {
return Number.parseInt(matches[1], 10);
}

/**
* Determine if a given pull request is an automated PR.
*
* @param {Object} pullRequest
* @returns {Boolean}
*/
static isAutomatedPullRequest(pullRequest) {
return _.isEqual(lodashGet(pullRequest, 'user.login', ''), CONST.OS_BOTIFY);
}

/**
* Return the login of the actor who closed an issue or PR. If the issue is not closed, return an empty string.
*
Expand Down
Loading

0 comments on commit 1b958b8

Please sign in to comment.