Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No QA] GitHub actions CONST file #21260

Merged
merged 4 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 46 additions & 37 deletions .github/actions/javascript/authorChecklist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,29 @@ getNumberOfItemsFromAuthorChecklist()
});


/***/ }),

/***/ 4097:
/***/ ((module) => {

const CONST = {
GITHUB_OWNER: 'Expensify',
APP_REPO: 'App',
APPLAUSE_BOT: 'applausebot',
OS_BOTIFY: 'OSBotify',
LABELS: {
STAGING_DEPLOY: 'StagingDeployCash',
DEPLOY_BLOCKER: 'DeployBlockerCash',
INTERNAL_QA: 'InternalQA',
},
};

CONST.APP_REPO_URL = `https://github.com/${CONST.GITHUB_OWNER}/${CONST.APP_REPO}`;
CONST.APP_REPO_GIT_URL = `git@github.com:${CONST.GITHUB_OWNER}/${CONST.APP_REPO}.git`;

module.exports = CONST;


/***/ }),

/***/ 7999:
Expand All @@ -88,21 +111,13 @@ const core = __nccwpck_require__(2186);
const {GitHub, getOctokitOptions} = __nccwpck_require__(3030);
const {throttling} = __nccwpck_require__(9968);
const {paginateRest} = __nccwpck_require__(4193);

const GITHUB_OWNER = 'Expensify';
const APP_REPO = 'App';
const APP_REPO_URL = 'https://github.com/Expensify/App';
const CONST = __nccwpck_require__(4097);

const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)');
const PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/pull/([0-9]+).*`);
const ISSUE_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/issues/([0-9]+).*`);
const ISSUE_OR_PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/(?:pull|issues)/([0-9]+).*`);

const APPLAUSE_BOT = 'applausebot';
const STAGING_DEPLOY_CASH_LABEL = 'StagingDeployCash';
const DEPLOY_BLOCKER_CASH_LABEL = 'DeployBlockerCash';
const INTERNAL_QA_LABEL = 'InternalQA';

/**
* The standard rate in ms at which we'll poll the GitHub API to check for status changes.
* It's 10 seconds :)
Expand Down Expand Up @@ -180,20 +195,20 @@ class GithubUtils {
static getStagingDeployCash() {
return this.octokit.issues
.listForRepo({
owner: GITHUB_OWNER,
repo: APP_REPO,
labels: STAGING_DEPLOY_CASH_LABEL,
owner: CONST.GITHUB_OWNER,
repo: CONST.APP_REPO,
labels: CONST.LABELS.STAGING_DEPLOY,
state: 'open',
})
.then(({data}) => {
if (!data.length) {
const error = new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue.`);
const error = new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue.`);
error.code = 404;
throw error;
}

if (data.length > 1) {
const error = new Error(`Found more than one ${STAGING_DEPLOY_CASH_LABEL} issue.`);
const error = new Error(`Found more than one ${CONST.LABELS.STAGING_DEPLOY} issue.`);
error.code = 500;
throw error;
}
Expand Down Expand Up @@ -226,7 +241,7 @@ class GithubUtils {
tag,
};
} catch (exception) {
throw new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue with correct data.`);
throw new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue with correct data.`);
}
}

Expand Down Expand Up @@ -334,7 +349,7 @@ class GithubUtils {
// 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ]
// }
const internalQAPRMap = _.reduce(
_.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: INTERNAL_QA_LABEL}))),
_.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))),
(map, pr) => {
// eslint-disable-next-line no-param-reassign
map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login'));
Expand Down Expand Up @@ -422,8 +437,8 @@ class GithubUtils {
return this.paginate(
this.octokit.pulls.list,
{
owner: GITHUB_OWNER,
repo: APP_REPO,
owner: CONST.GITHUB_OWNER,
repo: CONST.APP_REPO,
state: 'all',
sort: 'created',
direction: 'desc',
Expand All @@ -447,8 +462,8 @@ class GithubUtils {
static getPullRequestBody(pullRequestNumber) {
return this.octokit.pulls
.get({
owner: GITHUB_OWNER,
repo: APP_REPO,
owner: CONST.GITHUB_OWNER,
repo: CONST.APP_REPO,
pull_number: pullRequestNumber,
})
.then(({data: pullRequestComment}) => pullRequestComment.body);
Expand All @@ -462,8 +477,8 @@ class GithubUtils {
return this.paginate(
this.octokit.pulls.listReviews,
{
owner: GITHUB_OWNER,
repo: APP_REPO,
owner: CONST.GITHUB_OWNER,
repo: CONST.APP_REPO,
pull_number: pullRequestNumber,
per_page: 100,
},
Expand All @@ -479,8 +494,8 @@ class GithubUtils {
return this.paginate(
this.octokit.issues.listComments,
{
owner: GITHUB_OWNER,
repo: APP_REPO,
owner: CONST.GITHUB_OWNER,
repo: CONST.APP_REPO,
issue_number: issueNumber,
per_page: 100,
},
Expand All @@ -499,7 +514,7 @@ class GithubUtils {
static createComment(repo, number, messageBody) {
console.log(`Writing comment on #${number}`);
return this.octokit.issues.createComment({
owner: GITHUB_OWNER,
owner: CONST.GITHUB_OWNER,
repo,
issue_number: number,
body: messageBody,
Expand All @@ -516,8 +531,8 @@ class GithubUtils {
console.log(`Fetching New Expensify workflow runs for ${workflow}...`);
return this.octokit.actions
.listWorkflowRuns({
owner: GITHUB_OWNER,
repo: APP_REPO,
owner: CONST.GITHUB_OWNER,
repo: CONST.APP_REPO,
workflow_id: workflow,
})
.then((response) => lodashGet(response, 'data.workflow_runs[0].id'));
Expand All @@ -540,7 +555,7 @@ class GithubUtils {
* @returns {String}
*/
static getPullRequestURLFromNumber(number) {
return `${APP_REPO_URL}/pull/${number}`;
return `${CONST.APP_REPO_URL}/pull/${number}`;
}

/**
Expand Down Expand Up @@ -595,7 +610,7 @@ class GithubUtils {
* @returns {Boolean}
*/
static isAutomatedPullRequest(pullRequest) {
return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify');
return _.isEqual(lodashGet(pullRequest, 'user.login', ''), CONST.OS_BOTIFY);
}

/**
Expand All @@ -606,8 +621,8 @@ class GithubUtils {
*/
static getActorWhoClosedIssue(issueNumber) {
return this.paginate(this.octokit.issues.listEvents, {
owner: GITHUB_OWNER,
repo: APP_REPO,
owner: CONST.GITHUB_OWNER,
repo: CONST.APP_REPO,
issue_number: issueNumber,
per_page: 100,
})
Expand All @@ -617,12 +632,6 @@ class GithubUtils {
}

module.exports = GithubUtils;
module.exports.GITHUB_OWNER = GITHUB_OWNER;
module.exports.APP_REPO = APP_REPO;
module.exports.APP_REPO_URL = APP_REPO_URL;
module.exports.STAGING_DEPLOY_CASH_LABEL = STAGING_DEPLOY_CASH_LABEL;
module.exports.DEPLOY_BLOCKER_CASH_LABEL = DEPLOY_BLOCKER_CASH_LABEL;
module.exports.APPLAUSE_BOT = APPLAUSE_BOT;
module.exports.ISSUE_OR_PULL_REQUEST_REGEX = ISSUE_OR_PULL_REQUEST_REGEX;
module.exports.POLL_RATE = POLL_RATE;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const _ = require('underscore');
const CONST = require('../../../libs/CONST');
const ActionUtils = require('../../../libs/ActionUtils');
const GitHubUtils = require('../../../libs/GithubUtils');
const {promiseDoWhile} = require('../../../libs/promiseWhile');
Expand All @@ -13,8 +14,8 @@ function run() {
Promise.all([
// These are active deploys
GitHubUtils.octokit.actions.listWorkflowRuns({
owner: GitHubUtils.GITHUB_OWNER,
repo: GitHubUtils.APP_REPO,
owner: CONST.GITHUB_OWNER,
repo: CONST.APP_REPO,
workflow_id: 'platformDeploy.yml',
event: 'push',
branch: tag,
Expand All @@ -24,8 +25,8 @@ function run() {
// 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,
owner: CONST.GITHUB_OWNER,
repo: CONST.APP_REPO,
workflow_id: 'preDeploy.yml',
}),
])
Expand Down
Loading