Skip to content

fix: crash on Android 12L / 13 #97

fix: crash on Android 12L / 13

fix: crash on Android 12L / 13 #97

Workflow file for this run

name: Ready to Merge
on:
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.ref }}-ready-to-merge
cancel-in-progress: true
jobs:
check_commit_status:
runs-on: ubuntu-latest
steps:
- name: Check if PR is mergeable
uses: actions/github-script@v7
with:
script: |
// Define a list of workflows that need to finish successfully if run before merging
workflows_to_check = [
"all_packages.yml",
"check-uncommitted-changes.yml",
"mega-linter.yml",
"e2e_tests.yml",
"supabase-test.yml",
];
console.log("Initializing with workflows to check: " + workflows_to_check);
console.log("Sleeping 10s to give other runs a chance to start");
await sleep(10000);
const { owner, repo } = context.repo;
const commit_sha = context.payload.pull_request.head.sha; // Get the SHA of the head commit of the PR
const branch_name = context.payload.pull_request.head.ref;
const excludedCheckRunName = 'check_commit_status' // important you don't define name key for the job
const maxRetries = 15; // Maximum number of retries
async function fetchLatestWorkflowRun(workflowId) {
console.log("Fetching workflow runs for: " + workflowId);
try {
const response = await github.rest.actions.listWorkflowRuns({
owner,
repo,
workflow_id: workflowId,
branch: branch_name,
per_page: 1,
});
return response.data.workflow_runs[0];
} catch (error) {
if (error.status === 404) {
console.warn("Workflow not found: " + workflowId + ". It will be ignored.");
return;
}
core.setFailed("Error fetching workflow runs for: " + workflowId + ". Error: " + error.message);
process.exit();
}
}
async function fetchCheckRuns() {
const response = await github.rest.checks.listForRef({
owner,
repo,
ref: commit_sha,
per_page: 100,
});
console.log("Found " + response.data.check_runs.length + " check runs.");
return response.data.check_runs;
}
async function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
for (const workflowId of workflows_to_check) {
let retryCount = 0;
let inProgressFound = false;
let workflowRun = await fetchLatestWorkflowRun(workflowId);
if (!workflowRun) {
console.log("No workflow runs found for: " + workflowId);
continue;
}
do {
inProgressFound = false;
console.log("Checking workflow run: " + workflowRun.name + " with status: " + workflowRun.status + " and conclusion: " + workflowRun.conclusion);
if (workflowRun.status === "in_progress") {
console.log("Workflow run in progress: " + workflowRun.name);
if (retryCount >= maxRetries) {
core.setFailed(
"Maximum retries reached with check runs still in progress."
);
break;
}
console.log("Waiting for 1 minute before rechecking...");
await sleep(60000);
workflowRun = await fetchLatestWorkflowRun(workflowId);
retryCount++;
inProgressFound = true;
}
if (workflowRun.conclusion === "failure") {
console.log("Workflow run failed: " + workflowRun.name);
const checkSuiteId = workflowRun.check_suite_id;
const urlOfFailedCheckSuite = workflowRun.html_url;
const checkRuns = await github.rest.checks.listForSuite({
owner,
repo,
check_suite_id: checkSuiteId,
});
const failedCheckNames = checkRuns.data.check_runs
.filter((checkRun) => checkRun.conclusion === "failure")
.map((checkRun) => checkRun.name);
core.setFailed("The workflow run '" +
workflowRun.name + "' has failed. Please fix the failed checks: '" +
failedCheckNames.join(", ") + "'. Check suite URL: " +
urlOfFailedCheckSuite
);
}
} while (inProgressFound);
}
console.log("All given workflow runs completed.");
// Do not check the check runs for now, since this currently checks for all running workflows
// Todo: find another way to check for checks that are not part of this repository
// e.g. GitGuardian
/*
console.log("Checking check runs...");
let checkRuns = await fetchCheckRuns();
let inProgressFound = false;
for (const checkRun of checkRuns) {
let retryCount = 0;
do {
inProgressFound = false;
console.log("Checking check run: " + checkRun.name + " with status: " + checkRun.status + " and conclusion: " + checkRun.conclusion);
if (checkRun.name === excludedCheckRunName) {
console.log("Skipping excluded check run: " + checkRun.name);
break;
}
if (checkRun.status === "in_progress") {
console.log("Check run in progress: " + checkRun.name);
if (retryCount >= maxRetries) {
core.setFailed(
"Maximum retries reached with check runs still in progress."
);
break;
}
console.log("Waiting for 1 minute before rechecking...");
await sleep(60000);
checkRuns = await fetchCheckRuns();
retryCount++;
inProgressFound = true;
}
if (checkRun.conclusion === "failure") {
core.setFailed("The check run '" +
checkRun.name + "' has failed. Please fix the failed checks. Check run URL: " +
checkRun.html_url
);
}
} while (inProgressFound);
}
console.log("All check runs completed successfully.");
*/