Skip to content

[pull] develop from tronprotocol:develop #1

[pull] develop from tronprotocol:develop

[pull] develop from tronprotocol:develop #1

name: Waiting Coverage project
on:
pull_request:
branches: [ 'develop', 'release_**' ]
types: [ opened, synchronize, reopened ]
permissions:
contents: read
checks: read
statuses: read
pull-requests: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
waiting-coverage-project:
name: waiting-coverage-report
runs-on: ubuntu-latest
timeout-minutes: 70
steps:
- name: Wait for codecov/project status
uses: actions/github-script@v8
with:
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const ref = context.payload.pull_request.head.sha;
const targetContext = 'codecov/project';
const maxAttempts = 120; // 120 * 30s = 60 minutes
const intervalMs = 30 * 1000;
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
core.info(`Polling attempt ${attempt}/${maxAttempts} for ${targetContext} on ${ref}`);
try {
// Check legacy commit statuses
const combined = await github.rest.repos.getCombinedStatusForRef({
owner,
repo,
ref,
per_page: 100
});
const statuses = combined.data.statuses || [];
const matchedStatus = statuses.find(s => s.context === targetContext);
if (matchedStatus) {
core.info(`Found commit status: ${matchedStatus.context} = ${matchedStatus.state}`);
if (matchedStatus.state === 'success') {
core.info(`${targetContext} succeeded.`);
return;
}
if (matchedStatus.state === 'failure' || matchedStatus.state === 'error') {
core.setFailed(`${targetContext} is ${matchedStatus.state}.`);
return;
}
// pending
await sleep(intervalMs);
continue;
}
// Check check-runs as a fallback
const checks = await github.rest.checks.listForRef({
owner,
repo,
ref,
per_page: 100
});
const checkRuns = checks.data.check_runs || [];
const matchedCheck = checkRuns.find(c => c.name === targetContext);
if (matchedCheck) {
core.info(
`Found check run: ${matchedCheck.name}, status=${matchedCheck.status}, conclusion=${matchedCheck.conclusion}`
);
if (matchedCheck.status === 'completed') {
if (matchedCheck.conclusion === 'success') {
core.info(`${targetContext} succeeded.`);
return;
}
core.setFailed(
`${targetContext} completed with conclusion=${matchedCheck.conclusion}.`
);
return;
}
// queued / in_progress
await sleep(intervalMs);
continue;
}
core.info(`${targetContext} not reported yet. Waiting...`);
} catch (error) {
core.warning(
`Attempt ${attempt}/${maxAttempts} failed with transient error: ${error.message}. Retrying in ${intervalMs / 1000}s...`
);
}
await sleep(intervalMs);
}
core.setFailed(
`Timed out waiting for ${targetContext} to report success on commit ${ref}.`
);