Skip to content

Commit 976726c

Browse files
author
Fernando Arozarena
committed
add logging to debug failing executions
1 parent 31865e4 commit 976726c

2 files changed

Lines changed: 81 additions & 23 deletions

File tree

src/github.ts

Lines changed: 61 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,34 @@ export class OctokitGitHub {
2727
});
2828
}
2929

30-
workflows = async (owner: string, repo: string) =>
31-
this.octokit.paginate(this.octokit.actions.listRepoWorkflows, {
30+
workflows = async (owner: string, repo: string) => {
31+
debug(`🔍 API Call: GET /repos/${owner}/${repo}/actions/workflows`);
32+
const workflows = await this.octokit.paginate(this.octokit.actions.listRepoWorkflows, {
3233
owner,
3334
repo,
3435
per_page: 100,
3536
});
37+
debug(`📋 API Response: Found ${workflows.length} workflows`);
38+
debug(`📋 Workflows details: ${JSON.stringify(workflows.map(w => ({ id: w.id, name: w.name, state: w.state })), null, 2)}`);
39+
return workflows;
40+
};
3641

3742
runs = async (owner: string, repo: string, branch: string | undefined, workflow_id: number) => {
3843
const options: Endpoints['GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs']['parameters'] =
39-
{
40-
owner,
41-
repo,
42-
workflow_id,
43-
per_page: 100,
44-
};
44+
{
45+
owner,
46+
repo,
47+
workflow_id,
48+
per_page: 100,
49+
};
4550

4651
if (branch) {
4752
options.branch = branch;
4853
}
4954

55+
debug(`🔍 API Call: GET /repos/${owner}/${repo}/actions/workflows/${workflow_id}/runs`);
56+
debug(`🔍 Request options: ${JSON.stringify({ ...options, branch: branch || 'all branches' }, null, 2)}`);
57+
5058
const in_progress_options = {
5159
...options,
5260
status: 'in_progress' as const,
@@ -60,6 +68,8 @@ export class OctokitGitHub {
6068
status: 'waiting' as const,
6169
};
6270

71+
debug(`🔍 Making 3 parallel API calls for statuses: in_progress, queued, waiting`);
72+
6373
const in_progress_runs = this.octokit.paginate(
6474
this.octokit.actions.listWorkflowRuns,
6575
in_progress_options,
@@ -75,21 +85,42 @@ export class OctokitGitHub {
7585
waiting_options,
7686
);
7787

78-
return Promise.all([in_progress_runs, queued_runs, waiting_runs]).then((values) =>
79-
values.flat(),
80-
);
88+
const [inProgressResults, queuedResults, waitingResults] = await Promise.all([in_progress_runs, queued_runs, waiting_runs]);
89+
90+
debug(`📋 API Response - in_progress runs: ${inProgressResults.length}`);
91+
debug(`📋 API Response - queued runs: ${queuedResults.length}`);
92+
debug(`📋 API Response - waiting runs: ${waitingResults.length}`);
93+
94+
const allRuns = [inProgressResults, queuedResults, waitingResults].flat();
95+
debug(`📋 Total runs found: ${allRuns.length}`);
96+
97+
// Log detailed info about each run
98+
allRuns.forEach((run, index) => {
99+
debug(`📋 Run ${index + 1}: ID=${run.id}, status="${run.status}", conclusion="${run.conclusion}", created_at="${run.created_at}", branch="${run.head_branch}"`);
100+
});
101+
102+
return allRuns;
81103
};
82104

83105
jobs = async (owner: string, repo: string, run_id: number) => {
84106
const options: Endpoints['GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs']['parameters'] =
85-
{
86-
owner,
87-
repo,
88-
run_id,
89-
per_page: 100,
90-
};
91-
92-
return this.octokit.paginate(this.octokit.actions.listJobsForWorkflowRun, options);
107+
{
108+
owner,
109+
repo,
110+
run_id,
111+
per_page: 100,
112+
};
113+
114+
debug(`🔍 API Call: GET /repos/${owner}/${repo}/actions/runs/${run_id}/jobs`);
115+
const jobs = await this.octokit.paginate(this.octokit.actions.listJobsForWorkflowRun, options);
116+
debug(`📋 API Response: Found ${jobs.length} jobs for run ${run_id}`);
117+
118+
// Log detailed info about each job
119+
jobs.forEach((job, index) => {
120+
debug(`📋 Job ${index + 1}: ID=${job.id}, name="${job.name}", status="${job.status}", conclusion="${job.conclusion}", started_at="${job.started_at}"`);
121+
});
122+
123+
return jobs;
93124
};
94125

95126
steps = async (owner: string, repo: string, job_id: number) => {
@@ -98,7 +129,17 @@ export class OctokitGitHub {
98129
repo,
99130
job_id,
100131
};
132+
133+
debug(`🔍 API Call: GET /repos/${owner}/${repo}/actions/jobs/${job_id}`);
101134
const { data: job } = await this.octokit.actions.getJobForWorkflowRun(options);
102-
return job.steps || [];
135+
const steps = job.steps || [];
136+
debug(`📋 API Response: Found ${steps.length} steps for job ${job_id}`);
137+
138+
// Log detailed info about each step
139+
steps.forEach((step, index) => {
140+
debug(`📋 Step ${index + 1}: name="${step.name}", status="${step.status}", conclusion="${step.conclusion}", started_at="${step.started_at}"`);
141+
});
142+
143+
return steps;
103144
};
104145
}

src/wait.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ export class Waiter implements Wait {
5353
);
5454

5555
this.debug(`Found ${runs.length} ${this.workflowId} runs`);
56+
this.debug(`🔍 Current run ID: ${this.input.runId}`);
57+
this.debug(`🔍 Branch filter: ${this.input.sameBranchOnly ? this.input.branch : 'all branches'}`);
5658

5759
const queueName = this.input.queueName;
5860
let filteredRuns = runs;
@@ -65,6 +67,8 @@ export class Waiter implements Wait {
6567

6668
if (matchesQueue) {
6769
this.debug(`Run ${run.id} matches queue name: ${queueName}`);
70+
} else {
71+
this.debug(`Run ${run.id} does NOT match queue name: ${queueName} (display_title: "${run.display_title}", name: "${run.name}")`);
6872
}
6973

7074
return matchesQueue;
@@ -73,20 +77,33 @@ export class Waiter implements Wait {
7377
this.debug(`After queue filtering: ${filteredRuns.length} runs match queue "${queueName}"`);
7478
}
7579

76-
const previousRuns = filteredRuns
77-
.filter((run) => run.id < this.input.runId)
80+
// Filter runs that started before current run
81+
const runsBeforeCurrent = filteredRuns.filter((run) => run.id < this.input.runId);
82+
this.debug(`🔍 Runs before current (ID < ${this.input.runId}): ${runsBeforeCurrent.length}`);
83+
84+
runsBeforeCurrent.forEach((run) => {
85+
this.debug(`🔍 Run ${run.id}: status="${run.status}", conclusion="${run.conclusion}", created_at="${run.created_at}"`);
86+
});
87+
88+
const previousRuns = runsBeforeCurrent
7889
.filter((run) => {
7990
const isSuccessful: boolean = run.conclusion === 'success';
8091

8192
if (isSuccessful) {
8293
this.debug(
83-
`Skipping run ${run.id}, status: ${run.status}, conclusion: ${run.conclusion}`,
94+
`✅ Skipping successful run ${run.id}, status: ${run.status}, conclusion: ${run.conclusion}`,
95+
);
96+
} else {
97+
this.debug(
98+
`⏳ Will wait for run ${run.id}, status: ${run.status}, conclusion: ${run.conclusion}`,
8499
);
85100
}
86101

87102
return !isSuccessful;
88103
})
89104
.sort((a, b) => b.id - a.id);
105+
106+
this.debug(`🔍 Final previousRuns to wait for: ${previousRuns.length}`);
90107
if (!previousRuns || !previousRuns.length) {
91108
setOutput('force_continued', '');
92109
if (

0 commit comments

Comments
 (0)