Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 57 additions & 19 deletions .github/workflows/common_failure_alerts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,31 +50,69 @@ jobs:
id: failed_jobs
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const runId = context.payload.workflow_run.id;
const attemptNumber = context.payload.workflow_run.run_attempt ?? 1;
const { owner, repo } = context.repo;
const failingConclusions = new Set(['failure', 'timed_out', 'action_required']);
const failedJobs = await github.paginate(
github.rest.actions.listJobsForWorkflowRun,
{
owner,
repo,
run_id: runId,
per_page: 100,
},
response => {
const ignoredJobs = new Set(['Integration Test']);
const relevantJobs = new Set();

async function collectJobs(fetchPage) {
let page = 1;
while (true) {
const response = await fetchPage(page);

const jobs = Array.isArray(response?.data?.jobs) ? response.data.jobs : [];
return jobs.filter(
job => job.conclusion && failingConclusions.has(job.conclusion)
);
for (const job of jobs) {
if (
job?.conclusion &&
failingConclusions.has(job.conclusion) &&
job?.name &&
!ignoredJobs.has(job.name)
) {
relevantJobs.add(job.name);
}
}

if (jobs.length < 100) {
break;
}
page += 1;
}
);
const ignoredJobs = new Set(['Integration Test']);
const relevantJobs = failedJobs
.map(job => job.name)
.filter(name => !ignoredJobs.has(name));
const names = relevantJobs.length > 0 ? relevantJobs.join('\n- ') : 'Unknown job';
core.setOutput('names', relevantJobs.length > 0 ? `- ${names}` : names);
}

try {
await collectJobs(page =>
github.rest.actions.listJobsForWorkflowRunAttempt({
owner,
repo,
run_id: runId,
attempt_number: attemptNumber,
per_page: 100,
page,
})
);
} catch (error) {
if (error?.status !== 404) {
throw error;
}
core.info('Falling back to run-wide job listing');
await collectJobs(page =>
github.rest.actions.listJobsForWorkflowRun({
owner,
repo,
run_id: runId,
per_page: 100,
page,
})
);
}

const jobList = Array.from(relevantJobs);
const names = jobList.length > 0 ? jobList.join('\n- ') : 'Unknown job';
core.setOutput('names', jobList.length > 0 ? `- ${names}` : names);

- name: Post failure to Slack
env:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/daily_snapsync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
name: Sync ${{ matrix.network }}
runs-on: ethrex-sync
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.prepare.outputs.matrix) }}
steps:
Expand Down
Loading