Skip to content

Commit

Permalink
use real start time
Browse files Browse the repository at this point in the history
  • Loading branch information
maximtop committed Apr 22, 2024
1 parent 5cdb23b commit 58eb6c6
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/lib/github/GithubApiManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,18 +270,12 @@ export class GithubApiManager {

/**
* Logs how much time has passed since the workflow run started.
* @param workflowRun The workflow run info to log the time for.
* @param workflowRun The workflow run to log the status of.
* @param startTime The time when the workflow run started.
*/
private static logHowMuchTimePassed(workflowRun: WorkflowRun): void {
if (!workflowRun.run_started_at) {
// impossible here, since we log after workflow run has started
logger.error(`Workflow run has not started yet, status: ${workflowRun.status}}`);
return;
}

const startedAt = workflowRun.run_started_at;
private static logHowMuchTimePassed(workflowRun: WorkflowRun, startTime: number): void {
const currentTime = new Date();
const workflowStartTime = new Date(startedAt);
const workflowStartTime = new Date(startTime);
const durationSeconds = Math.floor((currentTime.getTime() - workflowStartTime.getTime()) / 1000);

// Log the time the build has been running and its current status
Expand Down Expand Up @@ -334,7 +328,7 @@ export class GithubApiManager {
const checkIfWorkflowRunCompleted = async (): Promise<WorkflowRun | null> => {
const workflowRun = await this.getWorkflowRun(branch, customWorkflowRunId);
if (workflowRun) {
GithubApiManager.logHowMuchTimePassed(workflowRun);
GithubApiManager.logHowMuchTimePassed(workflowRun, startTime);

if (workflowRun.status) {
if (!IN_PROGRESS_STATUSES[workflowRun.status as keyof Statuses]) {
Expand Down

0 comments on commit 58eb6c6

Please sign in to comment.