Skip to content

Commit

Permalink
Merge pull request Expensify#32367 from Expensify/Rory-BetterAdHocLogs
Browse files Browse the repository at this point in the history
[No QA] Improve AdHoc build comment
  • Loading branch information
roryabraham authored Dec 23, 2023
2 parents 723befd + de167c7 commit 85a5206
Show file tree
Hide file tree
Showing 25 changed files with 368 additions and 122 deletions.
25 changes: 0 additions & 25 deletions .github/actions/composite/configureAwsCredentials/action.yml

This file was deleted.

14 changes: 14 additions & 0 deletions .github/actions/javascript/authorChecklist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,20 @@ class GithubUtils {
return this.internalOctokit.rest;
}

/**
* Get the graphql instance from internal octokit.
* @readonly
* @static
* @memberof GithubUtils
*/
static get graphql() {
if (this.internalOctokit) {
return this.internalOctokit.graphql;
}
this.initOctokit();
return this.internalOctokit.graphql;
}

/**
* Either give an existing instance of Octokit paginate or create a new one
*
Expand Down
14 changes: 14 additions & 0 deletions .github/actions/javascript/awaitStagingDeploys/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,20 @@ class GithubUtils {
return this.internalOctokit.rest;
}

/**
* Get the graphql instance from internal octokit.
* @readonly
* @static
* @memberof GithubUtils
*/
static get graphql() {
if (this.internalOctokit) {
return this.internalOctokit.graphql;
}
this.initOctokit();
return this.internalOctokit.graphql;
}

/**
* Either give an existing instance of Octokit paginate or create a new one
*
Expand Down
14 changes: 14 additions & 0 deletions .github/actions/javascript/checkDeployBlockers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,20 @@ class GithubUtils {
return this.internalOctokit.rest;
}

/**
* Get the graphql instance from internal octokit.
* @readonly
* @static
* @memberof GithubUtils
*/
static get graphql() {
if (this.internalOctokit) {
return this.internalOctokit.graphql;
}
this.initOctokit();
return this.internalOctokit.graphql;
}

/**
* Either give an existing instance of Octokit paginate or create a new one
*
Expand Down
14 changes: 14 additions & 0 deletions .github/actions/javascript/createOrUpdateStagingDeploy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,20 @@ class GithubUtils {
return this.internalOctokit.rest;
}

/**
* Get the graphql instance from internal octokit.
* @readonly
* @static
* @memberof GithubUtils
*/
static get graphql() {
if (this.internalOctokit) {
return this.internalOctokit.graphql;
}
this.initOctokit();
return this.internalOctokit.graphql;
}

/**
* Either give an existing instance of Octokit paginate or create a new one
*
Expand Down
14 changes: 14 additions & 0 deletions .github/actions/javascript/getDeployPullRequestList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,20 @@ class GithubUtils {
return this.internalOctokit.rest;
}

/**
* Get the graphql instance from internal octokit.
* @readonly
* @static
* @memberof GithubUtils
*/
static get graphql() {
if (this.internalOctokit) {
return this.internalOctokit.graphql;
}
this.initOctokit();
return this.internalOctokit.graphql;
}

/**
* Either give an existing instance of Octokit paginate or create a new one
*
Expand Down
14 changes: 14 additions & 0 deletions .github/actions/javascript/getPullRequestDetails/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,20 @@ class GithubUtils {
return this.internalOctokit.rest;
}

/**
* Get the graphql instance from internal octokit.
* @readonly
* @static
* @memberof GithubUtils
*/
static get graphql() {
if (this.internalOctokit) {
return this.internalOctokit.graphql;
}
this.initOctokit();
return this.internalOctokit.graphql;
}

/**
* Either give an existing instance of Octokit paginate or create a new one
*
Expand Down
14 changes: 14 additions & 0 deletions .github/actions/javascript/getReleaseBody/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,20 @@ class GithubUtils {
return this.internalOctokit.rest;
}

/**
* Get the graphql instance from internal octokit.
* @readonly
* @static
* @memberof GithubUtils
*/
static get graphql() {
if (this.internalOctokit) {
return this.internalOctokit.graphql;
}
this.initOctokit();
return this.internalOctokit.graphql;
}

/**
* Either give an existing instance of Octokit paginate or create a new one
*
Expand Down
14 changes: 14 additions & 0 deletions .github/actions/javascript/isStagingDeployLocked/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,20 @@ class GithubUtils {
return this.internalOctokit.rest;
}

/**
* Get the graphql instance from internal octokit.
* @readonly
* @static
* @memberof GithubUtils
*/
static get graphql() {
if (this.internalOctokit) {
return this.internalOctokit.graphql;
}
this.initOctokit();
return this.internalOctokit.graphql;
}

/**
* Either give an existing instance of Octokit paginate or create a new one
*
Expand Down
14 changes: 14 additions & 0 deletions .github/actions/javascript/markPullRequestsAsDeployed/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,20 @@ class GithubUtils {
return this.internalOctokit.rest;
}

/**
* Get the graphql instance from internal octokit.
* @readonly
* @static
* @memberof GithubUtils
*/
static get graphql() {
if (this.internalOctokit) {
return this.internalOctokit.graphql;
}
this.initOctokit();
return this.internalOctokit.graphql;
}

/**
* Either give an existing instance of Octokit paginate or create a new one
*
Expand Down
67 changes: 56 additions & 11 deletions .github/actions/javascript/postTestBuildComment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
/***/ 2052:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {

const _ = __nccwpck_require__(5067);
const core = __nccwpck_require__(2186);
const {context} = __nccwpck_require__(5438);
const CONST = __nccwpck_require__(4097);
const GithubUtils = __nccwpck_require__(7999);

/**
Expand Down Expand Up @@ -42,7 +44,12 @@ function getTestBuildMessage() {
| ${androidQRCode} | ${iOSQRCode} |
| Desktop :computer: | Web :spider_web: |
| ${desktopLink} | ${webLink} |
| ${desktopQRCode} | ${webQRCode} |`;
| ${desktopQRCode} | ${webQRCode} |

---

:eyes: [View the workflow run that generated this build](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}) :eyes:
`;

return message;
}
Expand All @@ -54,20 +61,44 @@ function getTestBuildMessage() {
* @param {String} message
* @returns {Promise<void>}
*/
function commentPR(PR, message) {
async function commentPR(PR, message) {
console.log(`Posting test build comment on #${PR}`);
return GithubUtils.createComment(context.repo.repo, PR, message)
.then(() => console.log(`Comment created on #${PR} successfully 🎉`))
.catch((err) => {
console.log(`Unable to write comment on #${PR} 😞`);
core.setFailed(err.message);
});
try {
await GithubUtils.createComment(context.repo.repo, PR, message);
console.log(`Comment created on #${PR} successfully 🎉`);
} catch (err) {
console.log(`Unable to write comment on #${PR} 😞`);
core.setFailed(err.message);
}
}

const run = function () {
async function run() {
const PR_NUMBER = core.getInput('PR_NUMBER', {required: true});
return commentPR(PR_NUMBER, getTestBuildMessage()).then(() => Promise.resolve());
};
const comments = await GithubUtils.paginate(
GithubUtils.octokit.issues.listComments,
{
owner: CONST.GITHUB_OWNER,
repo: CONST.APP_REPO,
issue_number: PR_NUMBER,
per_page: 100,
},
(response) => response.data,
);
const testBuildComment = _.find(comments, (comment) => comment.body.startsWith(':test_tube::test_tube: Use the links below to test this adhoc build'));
if (testBuildComment) {
console.log('Found previous build comment, hiding it', testBuildComment);
await GithubUtils.graphql(`
mutation {
minimizeComment(input: {classifier: OUTDATED, subjectId: "${testBuildComment.node_id}"}) {
minimizedComment {
minimizedReason
}
}
}
`);
}
await commentPR(PR_NUMBER, getTestBuildMessage());
}

if (require.main === require.cache[eval('__filename')]) {
run();
Expand Down Expand Up @@ -173,6 +204,20 @@ class GithubUtils {
return this.internalOctokit.rest;
}

/**
* Get the graphql instance from internal octokit.
* @readonly
* @static
* @memberof GithubUtils
*/
static get graphql() {
if (this.internalOctokit) {
return this.internalOctokit.graphql;
}
this.initOctokit();
return this.internalOctokit.graphql;
}

/**
* Either give an existing instance of Octokit paginate or create a new one
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const _ = require('underscore');
const core = require('@actions/core');
const {context} = require('@actions/github');
const CONST = require('../../../libs/CONST');
const GithubUtils = require('../../../libs/GithubUtils');

/**
Expand Down Expand Up @@ -33,7 +35,12 @@ function getTestBuildMessage() {
| ${androidQRCode} | ${iOSQRCode} |
| Desktop :computer: | Web :spider_web: |
| ${desktopLink} | ${webLink} |
| ${desktopQRCode} | ${webQRCode} |`;
| ${desktopQRCode} | ${webQRCode} |

---

:eyes: [View the workflow run that generated this build](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}) :eyes:
`;

return message;
}
Expand All @@ -45,20 +52,44 @@ function getTestBuildMessage() {
* @param {String} message
* @returns {Promise<void>}
*/
function commentPR(PR, message) {
async function commentPR(PR, message) {
console.log(`Posting test build comment on #${PR}`);
return GithubUtils.createComment(context.repo.repo, PR, message)
.then(() => console.log(`Comment created on #${PR} successfully 🎉`))
.catch((err) => {
console.log(`Unable to write comment on #${PR} 😞`);
core.setFailed(err.message);
});
try {
await GithubUtils.createComment(context.repo.repo, PR, message);
console.log(`Comment created on #${PR} successfully 🎉`);
} catch (err) {
console.log(`Unable to write comment on #${PR} 😞`);
core.setFailed(err.message);
}
}

const run = function () {
async function run() {
const PR_NUMBER = core.getInput('PR_NUMBER', {required: true});
return commentPR(PR_NUMBER, getTestBuildMessage()).then(() => Promise.resolve());
};
const comments = await GithubUtils.paginate(
GithubUtils.octokit.issues.listComments,
{
owner: CONST.GITHUB_OWNER,
repo: CONST.APP_REPO,
issue_number: PR_NUMBER,
per_page: 100,
},
(response) => response.data,
);
const testBuildComment = _.find(comments, (comment) => comment.body.startsWith(':test_tube::test_tube: Use the links below to test this adhoc build'));
if (testBuildComment) {
console.log('Found previous build comment, hiding it', testBuildComment);
await GithubUtils.graphql(`
mutation {
minimizeComment(input: {classifier: OUTDATED, subjectId: "${testBuildComment.node_id}"}) {
minimizedComment {
minimizedReason
}
}
}
`);
}
await commentPR(PR_NUMBER, getTestBuildMessage());
}

if (require.main === module) {
run();
Expand Down
Loading

0 comments on commit 85a5206

Please sign in to comment.