Skip to content

Commit

Permalink
add prettier for easier resolving conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
staszekscp committed May 15, 2023
1 parent 5175d8b commit 99214de
Show file tree
Hide file tree
Showing 745 changed files with 14,510 additions and 25,588 deletions.
12 changes: 2 additions & 10 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
extends: ['expensify', 'plugin:storybook/recommended', 'plugin:react-hooks/recommended'],
extends: ['expensify', 'plugin:storybook/recommended', 'plugin:react-hooks/recommended', 'prettier'],
plugins: ['react-hooks'],
parser: 'babel-eslint',
ignorePatterns: ['!.*', 'src/vendor', '.github/actions/**/index.js', 'desktop/dist/*.js', 'dist/*.js', 'node_modules/.bin/**', '.git/**'],
Expand All @@ -9,15 +9,7 @@ module.exports = {
settings: {
'import/resolver': {
node: {
extensions: [
'.js',
'.website.js',
'.desktop.js',
'.native.js',
'.ios.js',
'.android.js',
'.config.js',
],
extensions: ['.js', '.website.js', '.desktop.js', '.native.js', '.ios.js', '.android.js', '.config.js'],
},
},
},
Expand Down
62 changes: 30 additions & 32 deletions .github/actions/javascript/authorChecklist/authorChecklist.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,22 @@ const issue = github.context.payload.issue ? github.context.payload.issue.number
*/
function getNumberOfItemsFromAuthorChecklist() {
return new Promise((resolve, reject) => {
https.get(pathToAuthorChecklist, (res) => {
let fileContents = '';
res.on('data', (chunk) => {
fileContents += chunk;
});
res.on('end', () => {
// Currently, both the author and reviewer checklists are in the PR template file, so we need to do a little bit of parsing the PR description to get just the author
// checklist.
const contentAfterStartOfAuthorChecklist = fileContents.split(authorChecklistStartsWith).pop();
const contentBeforeStartOfReviewerChecklist = contentAfterStartOfAuthorChecklist.split(reviewerChecklistStartsWith).shift();
https
.get(pathToAuthorChecklist, (res) => {
let fileContents = '';
res.on('data', (chunk) => {
fileContents += chunk;
});
res.on('end', () => {
// Currently, both the author and reviewer checklists are in the PR template file, so we need to do a little bit of parsing the PR description to get just the author
// checklist.
const contentAfterStartOfAuthorChecklist = fileContents.split(authorChecklistStartsWith).pop();
const contentBeforeStartOfReviewerChecklist = contentAfterStartOfAuthorChecklist.split(reviewerChecklistStartsWith).shift();

const numberOfChecklistItems = (contentBeforeStartOfReviewerChecklist.match(/\[ \]/g) || []).length;
resolve(numberOfChecklistItems);
});
})
const numberOfChecklistItems = (contentBeforeStartOfReviewerChecklist.match(/\[ \]/g) || []).length;
resolve(numberOfChecklistItems);
});
})
.on('error', reject);
});
}
Expand All @@ -36,29 +37,26 @@ function getNumberOfItemsFromAuthorChecklist() {
* @param {Number} numberOfChecklistItems
*/
function checkIssueForCompletedChecklist(numberOfChecklistItems) {
GitHubUtils.getPullRequestBody(issue)
.then((pullRequestBody) => {
const contentAfterStartOfAuthorChecklist = pullRequestBody.split(authorChecklistStartsWith).pop();
const contentOfAuthorChecklist = contentAfterStartOfAuthorChecklist.split(reviewerChecklistStartsWith).shift();
GitHubUtils.getPullRequestBody(issue).then((pullRequestBody) => {
const contentAfterStartOfAuthorChecklist = pullRequestBody.split(authorChecklistStartsWith).pop();
const contentOfAuthorChecklist = contentAfterStartOfAuthorChecklist.split(reviewerChecklistStartsWith).shift();

const numberOfFinishedChecklistItems = (contentOfAuthorChecklist.match(/- \[x\]/gi) || []).length;
const numberOfUnfinishedChecklistItems = (contentOfAuthorChecklist.match(/- \[ \]/g) || []).length;
const numberOfFinishedChecklistItems = (contentOfAuthorChecklist.match(/- \[x\]/gi) || []).length;
const numberOfUnfinishedChecklistItems = (contentOfAuthorChecklist.match(/- \[ \]/g) || []).length;

const maxCompletedItems = numberOfChecklistItems + 2;
const minCompletedItems = numberOfChecklistItems - 2;
const maxCompletedItems = numberOfChecklistItems + 2;
const minCompletedItems = numberOfChecklistItems - 2;

console.log(`You completed ${numberOfFinishedChecklistItems} out of ${numberOfChecklistItems} checklist items with ${numberOfUnfinishedChecklistItems} unfinished items`);
console.log(`You completed ${numberOfFinishedChecklistItems} out of ${numberOfChecklistItems} checklist items with ${numberOfUnfinishedChecklistItems} unfinished items`);

if (numberOfFinishedChecklistItems >= minCompletedItems
&& numberOfFinishedChecklistItems <= maxCompletedItems
&& numberOfUnfinishedChecklistItems === 0) {
console.log('PR Author checklist is complete 🎉');
return;
}
if (numberOfFinishedChecklistItems >= minCompletedItems && numberOfFinishedChecklistItems <= maxCompletedItems && numberOfUnfinishedChecklistItems === 0) {
console.log('PR Author checklist is complete 🎉');
return;
}

console.log(`Make sure you are using the most up to date checklist found here: ${pathToAuthorChecklist}`);
core.setFailed('PR Author Checklist is not completely filled out. Please check every box to verify you\'ve thought about the item.');
});
console.log(`Make sure you are using the most up to date checklist found here: ${pathToAuthorChecklist}`);
core.setFailed("PR Author Checklist is not completely filled out. Please check every box to verify you've thought about the item.");
});
}

getNumberOfItemsFromAuthorChecklist()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,41 @@ function run() {
return promiseDoWhile(
() => !_.isEmpty(currentStagingDeploys),
_.throttle(
() => Promise.all([
// These are active deploys
GitHubUtils.octokit.actions.listWorkflowRuns({
owner: GitHubUtils.GITHUB_OWNER,
repo: GitHubUtils.APP_REPO,
workflow_id: 'platformDeploy.yml',
event: 'push',
branch: tag,
}),
() =>
Promise.all([
// These are active deploys
GitHubUtils.octokit.actions.listWorkflowRuns({
owner: GitHubUtils.GITHUB_OWNER,
repo: GitHubUtils.APP_REPO,
workflow_id: 'platformDeploy.yml',
event: 'push',
branch: tag,
}),

// These have the potential to become active deploys, so we need to wait for them to finish as well (unless we're looking for a specific tag)
// In this context, we'll refer to unresolved preDeploy workflow runs as staging deploys as well
!tag && GitHubUtils.octokit.actions.listWorkflowRuns({
owner: GitHubUtils.GITHUB_OWNER,
repo: GitHubUtils.APP_REPO,
workflow_id: 'preDeploy.yml',
}),
])
.then((responses) => {
const workflowRuns = responses[0].data.workflow_runs;
if (!tag) {
workflowRuns.push(...responses[1].data.workflow_runs);
}
return workflowRuns;
})
.then(workflowRuns => currentStagingDeploys = _.filter(workflowRuns, workflowRun => workflowRun.status !== 'completed'))
.then(() => console.log(
_.isEmpty(currentStagingDeploys)
? 'No current staging deploys found'
: `Found ${currentStagingDeploys.length} staging deploy${currentStagingDeploys.length > 1 ? 's' : ''} still running...`,
)),
// These have the potential to become active deploys, so we need to wait for them to finish as well (unless we're looking for a specific tag)
// In this context, we'll refer to unresolved preDeploy workflow runs as staging deploys as well
!tag &&
GitHubUtils.octokit.actions.listWorkflowRuns({
owner: GitHubUtils.GITHUB_OWNER,
repo: GitHubUtils.APP_REPO,
workflow_id: 'preDeploy.yml',
}),
])
.then((responses) => {
const workflowRuns = responses[0].data.workflow_runs;
if (!tag) {
workflowRuns.push(...responses[1].data.workflow_runs);
}
return workflowRuns;
})
.then((workflowRuns) => (currentStagingDeploys = _.filter(workflowRuns, (workflowRun) => workflowRun.status !== 'completed')))
.then(() =>
console.log(
_.isEmpty(currentStagingDeploys)
? 'No current staging deploys found'
: `Found ${currentStagingDeploys.length} staging deploy${currentStagingDeploys.length > 1 ? 's' : ''} still running...`,
),
),

// Poll every 60 seconds instead of every 10 seconds
GitHubUtils.POLL_RATE * 6,
Expand Down
5 changes: 1 addition & 4 deletions .github/actions/javascript/bumpVersion/bumpVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ function updateNativeVersions(version) {

let semanticVersionLevel = core.getInput('SEMVER_LEVEL', {require: true});
if (!semanticVersionLevel || !_.contains(versionUpdater.SEMANTIC_VERSION_LEVELS, semanticVersionLevel)) {
console.log(
`Invalid input for 'SEMVER_LEVEL': ${semanticVersionLevel}`,
`Defaulting to: ${versionUpdater.SEMANTIC_VERSION_LEVELS.BUILD}`,
);
console.log(`Invalid input for 'SEMVER_LEVEL': ${semanticVersionLevel}`, `Defaulting to: ${versionUpdater.SEMANTIC_VERSION_LEVELS.BUILD}`);
semanticVersionLevel = versionUpdater.SEMANTIC_VERSION_LEVELS.BUILD;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ const run = function () {

console.log(`Fetching issue number ${issueNumber}`);

return GithubUtils.octokit.issues.get({
owner: GithubUtils.GITHUB_OWNER,
repo: GithubUtils.APP_REPO,
issue_number: issueNumber,
})
return GithubUtils.octokit.issues
.get({
owner: GithubUtils.GITHUB_OWNER,
repo: GithubUtils.APP_REPO,
issue_number: issueNumber,
})
.then(({data}) => {
console.log('Checking for unverified PRs or unresolved deploy blockers', data);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ const run = function () {
} else {
console.log(
'Latest StagingDeployCash is open, updating it instead of creating a new one.',
'Current:', stagingDeployResponse.data[0],
'Previous:', stagingDeployResponse.data[1],
'Current:',
stagingDeployResponse.data[0],
'Previous:',
stagingDeployResponse.data[1],
);
}

Expand Down Expand Up @@ -84,48 +86,41 @@ const run = function () {
console.log(`The following PRs have been merged between the previous StagingDeployCash (${previousStagingDeployCashData.tag}) and new version (${newVersion}):`, mergedPRs);

if (shouldCreateNewStagingDeployCash) {
return GithubUtils.generateStagingDeployCashBody(
newTag,
_.map(mergedPRs, GithubUtils.getPullRequestURLFromNumber),
);
return GithubUtils.generateStagingDeployCashBody(newTag, _.map(mergedPRs, GithubUtils.getPullRequestURLFromNumber));
}

const didVersionChange = newVersion ? newVersion !== currentStagingDeployCashData.tag : false;

// Generate the PR list, preserving the previous state of `isVerified` for existing PRs
const PRList = _.sortBy(
_.unique(
_.union(currentStagingDeployCashData.PRList, _.map(mergedPRs, number => ({
number: Number.parseInt(number, 10),
url: GithubUtils.getPullRequestURLFromNumber(number),

// Since this is the second argument to _.union,
// it will appear later in the array than any duplicate.
// Since it is later in the array, it will be truncated by _.unique,
// and the original value of isVerified will be preserved.
isVerified: false,
}))),
_.union(
currentStagingDeployCashData.PRList,
_.map(mergedPRs, (number) => ({
number: Number.parseInt(number, 10),
url: GithubUtils.getPullRequestURLFromNumber(number),

// Since this is the second argument to _.union,
// it will appear later in the array than any duplicate.
// Since it is later in the array, it will be truncated by _.unique,
// and the original value of isVerified will be preserved.
isVerified: false,
})),
),
false,
item => item.number,
(item) => item.number,
),
'number',
);

// Generate the deploy blocker list, preserving the previous state of `isResolved`
const deployBlockers = _.sortBy(
_.unique(
_.union(currentStagingDeployCashData.deployBlockers, newDeployBlockers),
false,
item => item.number,
),
_.unique(_.union(currentStagingDeployCashData.deployBlockers, newDeployBlockers), false, (item) => item.number),
'number',
);

// Get the internalQA PR list, preserving the previous state of `isResolved`
const internalQAPRList = _.sortBy(
currentStagingDeployCashData.internalQAPRList,
'number',
);
const internalQAPRList = _.sortBy(currentStagingDeployCashData.internalQAPRList, 'number');

return GithubUtils.generateStagingDeployCashBody(
newTag,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,18 @@ function getTagsOrReleases(fetchReleases) {

console.log(`Fetching ${itemToFetch} list from github...`);
getTagsOrReleases(isProductionDeploy)
.catch(githubError => core.setFailed(githubError))
.catch((githubError) => core.setFailed(githubError))
.then(({data}) => {
const keyToPluck = isProductionDeploy ? 'tag_name' : 'name';
const tags = _.pluck(data, keyToPluck);
const priorTagIndex = _.indexOf(tags, inputTag) + 1;

if (priorTagIndex === 0) {
console.log(`No ${itemToFetch} was found for input tag ${inputTag}.`
+ `Comparing it to latest ${itemToFetch} ${tags[0]}`);
console.log(`No ${itemToFetch} was found for input tag ${inputTag}.` + `Comparing it to latest ${itemToFetch} ${tags[0]}`);
}

if (priorTagIndex === tags.length) {
const err = new Error('Somehow, the input tag was at the end of the paginated result, '
+ 'so we don\'t have the prior tag');
const err = new Error('Somehow, the input tag was at the end of the paginated result, ' + "so we don't have the prior tag");
console.error(err.message);
core.setFailed(err);
return;
Expand All @@ -61,4 +59,4 @@ getTagsOrReleases(isProductionDeploy)
console.log(`Found the pull request list: ${pullRequestList}`);
return core.setOutput('PR_LIST', pullRequestList);
})
.catch(error => core.setFailed(error));
.catch((error) => core.setFailed(error));
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,29 @@ function handleUnknownError(err) {
}

if (pullRequestNumber) {
GithubUtils.octokit.pulls.get({
...DEFAULT_PAYLOAD,
pull_number: pullRequestNumber,
})
GithubUtils.octokit.pulls
.get({
...DEFAULT_PAYLOAD,
pull_number: pullRequestNumber,
})
.then(({data}) => {
outputMergeCommitHash(data);
outputMergeActor(data);
})
.catch(handleUnknownError);
} else {
GithubUtils.octokit.pulls.list({
...DEFAULT_PAYLOAD,
state: 'all',
})
.then(({data}) => _.find(data, PR => PR.user.login === user && titleRegex.test(PR.title)).number)
.then(matchingPRNum => GithubUtils.octokit.pulls.get({
GithubUtils.octokit.pulls
.list({
...DEFAULT_PAYLOAD,
pull_number: matchingPRNum,
}))
state: 'all',
})
.then(({data}) => _.find(data, (PR) => PR.user.login === user && titleRegex.test(PR.title)).number)
.then((matchingPRNum) =>
GithubUtils.octokit.pulls.get({
...DEFAULT_PAYLOAD,
pull_number: matchingPRNum,
}),
)
.then(({data}) => {
outputMergeCommitHash(data);
outputMergeActor(data);
Expand Down
Loading

0 comments on commit 99214de

Please sign in to comment.