Skip to content

Commit

Permalink
Merge pull request #41876 from JKobrynski/removeDebugLogs
Browse files Browse the repository at this point in the history
[No QA] remove debug logs from awaitStagingDeploys.ts and promiseWhile.ts
  • Loading branch information
mountiny authored May 14, 2024
2 parents 8c31166 + 07e3629 commit 1bc9343
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,10 @@ import {promiseDoWhile} from '@github/libs/promiseWhile';
type CurrentStagingDeploys = Awaited<ReturnType<typeof GitHubUtils.octokit.actions.listWorkflowRuns>>['data']['workflow_runs'];

function run() {
console.info('[awaitStagingDeploys] POLL RATE', CONST.POLL_RATE);
console.info('[awaitStagingDeploys] run()');
console.info('[awaitStagingDeploys] getStringInput', getStringInput);
console.info('[awaitStagingDeploys] GitHubUtils', GitHubUtils);
console.info('[awaitStagingDeploys] promiseDoWhile', promiseDoWhile);

const tag = getStringInput('TAG', {required: false});
console.info('[awaitStagingDeploys] run() tag', tag);

let currentStagingDeploys: CurrentStagingDeploys = [];

console.info('[awaitStagingDeploys] run() _.throttle', lodashThrottle);

const throttleFunc = () =>
Promise.all([
// These are active deploys
Expand All @@ -42,24 +33,20 @@ function run() {
}),
])
.then((responses) => {
console.info('[awaitStagingDeploys] listWorkflowRuns responses', responses);
const workflowRuns = responses[0].data.workflow_runs;
if (!tag && typeof responses[1] === 'object') {
workflowRuns.push(...responses[1].data.workflow_runs);
}
console.info('[awaitStagingDeploys] workflowRuns', workflowRuns);
return workflowRuns;
})
.then((workflowRuns) => (currentStagingDeploys = workflowRuns.filter((workflowRun) => workflowRun.status !== 'completed')))
.then(() => {
console.info('[awaitStagingDeploys] currentStagingDeploys', currentStagingDeploys);
console.log(
!currentStagingDeploys.length
? 'No current staging deploys found'
: `Found ${currentStagingDeploys.length} staging deploy${currentStagingDeploys.length > 1 ? 's' : ''} still running...`,
);
});
console.info('[awaitStagingDeploys] run() throttleFunc', throttleFunc);

return promiseDoWhile(
() => !!currentStagingDeploys.length,
Expand Down
16 changes: 0 additions & 16 deletions .github/actions/javascript/awaitStagingDeploys/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12131,15 +12131,8 @@ const CONST_1 = __importDefault(__nccwpck_require__(9873));
const GithubUtils_1 = __importDefault(__nccwpck_require__(9296));
const promiseWhile_1 = __nccwpck_require__(9438);
function run() {
console.info('[awaitStagingDeploys] POLL RATE', CONST_1.default.POLL_RATE);
console.info('[awaitStagingDeploys] run()');
console.info('[awaitStagingDeploys] getStringInput', ActionUtils_1.getStringInput);
console.info('[awaitStagingDeploys] GitHubUtils', GithubUtils_1.default);
console.info('[awaitStagingDeploys] promiseDoWhile', promiseWhile_1.promiseDoWhile);
const tag = (0, ActionUtils_1.getStringInput)('TAG', { required: false });
console.info('[awaitStagingDeploys] run() tag', tag);
let currentStagingDeploys = [];
console.info('[awaitStagingDeploys] run() _.throttle', throttle_1.default);
const throttleFunc = () => Promise.all([
// These are active deploys
GithubUtils_1.default.octokit.actions.listWorkflowRuns({
Expand All @@ -12159,22 +12152,18 @@ function run() {
}),
])
.then((responses) => {
console.info('[awaitStagingDeploys] listWorkflowRuns responses', responses);
const workflowRuns = responses[0].data.workflow_runs;
if (!tag && typeof responses[1] === 'object') {
workflowRuns.push(...responses[1].data.workflow_runs);
}
console.info('[awaitStagingDeploys] workflowRuns', workflowRuns);
return workflowRuns;
})
.then((workflowRuns) => (currentStagingDeploys = workflowRuns.filter((workflowRun) => workflowRun.status !== 'completed')))
.then(() => {
console.info('[awaitStagingDeploys] currentStagingDeploys', currentStagingDeploys);
console.log(!currentStagingDeploys.length
? 'No current staging deploys found'
: `Found ${currentStagingDeploys.length} staging deploy${currentStagingDeploys.length > 1 ? 's' : ''} still running...`);
});
console.info('[awaitStagingDeploys] run() throttleFunc', throttleFunc);
return (0, promiseWhile_1.promiseDoWhile)(() => !!currentStagingDeploys.length, (0, throttle_1.default)(throttleFunc,
// Poll every 60 seconds instead of every 10 seconds
CONST_1.default.POLL_RATE * 6));
Expand Down Expand Up @@ -12730,15 +12719,13 @@ exports.promiseDoWhile = exports.promiseWhile = void 0;
* Simulates a while loop where the condition is determined by the result of a Promise.
*/
function promiseWhile(condition, action) {
console.info('[promiseWhile] promiseWhile()');
return new Promise((resolve, reject) => {
const loop = function () {
if (!condition()) {
resolve();
}
else {
const actionResult = action?.();
console.info('[promiseWhile] promiseWhile() actionResult', actionResult);
if (!actionResult) {
resolve();
return;
Expand All @@ -12759,11 +12746,8 @@ exports.promiseWhile = promiseWhile;
* Simulates a do-while loop where the condition is determined by the result of a Promise.
*/
function promiseDoWhile(condition, action) {
console.info('[promiseWhile] promiseDoWhile()');
return new Promise((resolve, reject) => {
console.info('[promiseWhile] promiseDoWhile() condition', condition);
const actionResult = action?.();
console.info('[promiseWhile] promiseDoWhile() actionResult', actionResult);
if (!actionResult) {
resolve();
return;
Expand Down
8 changes: 1 addition & 7 deletions .github/libs/promiseWhile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@ import type {DebouncedFunc} from 'lodash';
* Simulates a while loop where the condition is determined by the result of a Promise.
*/
function promiseWhile(condition: () => boolean, action: (() => Promise<void>) | DebouncedFunc<() => Promise<void>> | undefined): Promise<void> {
console.info('[promiseWhile] promiseWhile()');

return new Promise((resolve, reject) => {
const loop = function () {
if (!condition()) {
resolve();
} else {
const actionResult = action?.();
console.info('[promiseWhile] promiseWhile() actionResult', actionResult);

if (!actionResult) {
resolve();
Expand All @@ -35,12 +32,9 @@ function promiseWhile(condition: () => boolean, action: (() => Promise<void>) |
* Simulates a do-while loop where the condition is determined by the result of a Promise.
*/
function promiseDoWhile(condition: () => boolean, action: (() => Promise<void>) | DebouncedFunc<() => Promise<void>> | undefined): Promise<void> {
console.info('[promiseWhile] promiseDoWhile()');

return new Promise((resolve, reject) => {
console.info('[promiseWhile] promiseDoWhile() condition', condition);
const actionResult = action?.();
console.info('[promiseWhile] promiseDoWhile() actionResult', actionResult);

if (!actionResult) {
resolve();
return;
Expand Down

0 comments on commit 1bc9343

Please sign in to comment.