Skip to content

Commit

Permalink
fix: typecheck
Browse files Browse the repository at this point in the history
  • Loading branch information
kubabutkiewicz committed Apr 3, 2024
1 parent 41f0d72 commit ef5f493
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/naming-convention */
import lodashThrottle from 'lodash/throttle';
import ActionUtils from '@github/libs/ActionUtils';
import {getStringInput} from '@github/libs/ActionUtils';
import CONST from '@github/libs/CONST';
import GitHubUtils, {POLL_RATE} from '@github/libs/GithubUtils';
import {promiseDoWhile} from '@github/libs/promiseWhile';
Expand All @@ -9,11 +9,11 @@ type CurrentStagingDeploys = Awaited<ReturnType<typeof GitHubUtils.octokit.actio

function run() {
console.info('[awaitStagingDeploys] run()');
console.info('[awaitStagingDeploys] ActionUtils', ActionUtils);
console.info('[awaitStagingDeploys] getStringInput', getStringInput);
console.info('[awaitStagingDeploys] GitHubUtils', GitHubUtils);
console.info('[awaitStagingDeploys] promiseDoWhile', promiseDoWhile);

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

let currentStagingDeploys: CurrentStagingDeploys = [];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import core from '@actions/core';
import github from '@actions/github';
import ActionUtils from '@github/libs/ActionUtils';
import {getJSONInput} from '@github/libs/ActionUtils';
import GithubUtils from '@github/libs/GithubUtils';
import GitUtils from '@github/libs/GitUtils';

async function run() {
try {
const inputTag = core.getInput('TAG', {required: true});
const isProductionDeploy = ActionUtils.getJSONInput('IS_PRODUCTION_DEPLOY', {required: false}, false);
const isProductionDeploy = getJSONInput('IS_PRODUCTION_DEPLOY', {required: false}, false);
const deployEnv = isProductionDeploy ? 'production' : 'staging';

console.log(`Looking for PRs deployed to ${deployEnv} in ${inputTag}...`);
Expand Down
12 changes: 7 additions & 5 deletions .github/libs/promiseWhile.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
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>): Promise<void> {
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();
const actionResult = action?.();
console.info('[promiseWhile] promiseWhile() actionResult', actionResult);
Promise.resolve(actionResult).then(loop).catch(reject);
}
Expand All @@ -21,15 +23,15 @@ function promiseWhile(condition: () => boolean, action: () => Promise<void>): Pr
/**
* Simulates a do-while loop where the condition is determined by the result of a Promise.
*/
function promiseDoWhile(condition: () => boolean, action: () => Promise<void>): Promise<void> {
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();
const actionResult = action?.();
console.info('[promiseWhile] promiseDoWhile() actionResult', actionResult);
actionResult
.then(() => promiseWhile(condition, action))
?.then(() => promiseWhile(condition, action))
.then(() => resolve())
.catch(reject);
});
Expand Down

0 comments on commit ef5f493

Please sign in to comment.