Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ jobs:
CLANG_PATH: /usr/bin/clang-23
LIBCLANG_PATH: /usr/lib/llvm-23/lib
PROFILER_COVERAGE_TOOLCHAIN: nightly-2026-11-11
# Diagnostic artifacts: no job downloads them, so a transient upload error (seen as
# ECONNRESET) must not fail a run whose checks passed. Every upload below does the same.
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
continue-on-error: true
if: always()
with:
name: coverage
Expand Down Expand Up @@ -183,6 +186,7 @@ jobs:
extensions: pdo_sqlite, curl, pcntl, ffi, posix
- run: scripts/php-tool.sh scripts/rust-mutation.php --timeout 240 --jobs 2 --shard '${{ strategy.job-index }}/${{ strategy.job-total }}'
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
continue-on-error: true
if: always()
with:
name: mutants-${{ matrix.shard }}
Expand Down Expand Up @@ -241,11 +245,13 @@ jobs:
if test -d "$directory"; then sudo chown -R "$(id -u):$(id -g)" "$directory"; fi
done
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
continue-on-error: true
if: always()
with:
name: compatibility-${{ matrix.php }}-${{ matrix.sapi }}
path: target/compatibility
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
continue-on-error: true
if: always() && matrix.sapi != 'apache' && !startsWith(matrix.sapi, 'frankenphp')
with:
name: performance-${{ matrix.php }}-${{ matrix.sapi }}
Expand Down Expand Up @@ -312,6 +318,7 @@ jobs:
scripts/c-mutation.sh
'
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
continue-on-error: true
if: always()
with:
name: c-mutation-${{ matrix.zts }}
Expand Down Expand Up @@ -342,6 +349,7 @@ jobs:
if test -d "$directory"; then sudo chown -R "$(id -u):$(id -g)" "$directory"; fi
done
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
continue-on-error: true
if: always()
with:
name: clang-c-coverage-${{ matrix.sapi }}
Expand Down Expand Up @@ -408,6 +416,7 @@ jobs:
toolchain: '1.99.1'
- run: scripts/php-tool.sh scripts/vendor-patch-mutation.php
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
continue-on-error: true
if: always()
with:
name: vendored-ownership-mutation-${{ matrix.php }}
Expand All @@ -433,6 +442,7 @@ jobs:
if test -d "$directory"; then sudo chown -R "$(id -u):$(id -g)" "$directory"; fi
done
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
continue-on-error: true
if: always()
with:
name: zts-sampling-isolation
Expand Down
2 changes: 1 addition & 1 deletion docs/releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Privileged orchestration checks out trusted main, never candidate scripts. Candi

Bot-dispatched quality runs explicitly dispatch the trusted-main release workflow from a small continuation job after `quality-gate` passes. They do not rely on a recursively triggered `workflow_run` event. The release entry point receives only the quality run ID, waits a bounded interval for that upstream run to become terminal, and independently checks its successful result, repository, source, branch, actor, and candidate transition. This wait handles the continuation job briefly keeping its own workflow in progress. Ordinary successful main push runs also retain the `workflow_run` entry point; serialized, idempotent orchestration makes retries safe.

GitHub sometimes never assigns a hosted runner to a job, most often on macOS. Such a job is cancelled before its first step, and `quality-gate` fails without anything having been tested. The `runner-retry` workflow then reruns the run's failed jobs, at most twice, but only when every failed job other than `quality-gate` and `release-continuation` was cancelled with no runner and no step, and only while the run's commit is still its branch head: a rerun of a push or pull request run joins its branch's concurrency group and would cancel a newer run. A dispatched release run has its own group, so pushes never cancel it. The rerun includes the dependent `quality-gate` and `release-continuation` jobs, so a dispatched run continues as usual. A rerun's completion is caused by the default token and may start no workflow, so the retry job waits for each rerun itself, retries again if needed, and dispatches the release when a main push run passes on a rerun; serialized, idempotent orchestration makes a second trigger harmless. If the wait runs out, `gh workflow run release.yml --ref main -f quality_run_id=<run id>` continues from the successful run.
GitHub sometimes never assigns a hosted runner to a job, most often on macOS. Such a job is cancelled before its first step, and `quality-gate` fails without anything having been tested. The `runner-retry` workflow then reruns the run's failed jobs, at most twice, but only when every failed job other than `quality-gate` and `release-continuation` was cancelled with no runner and no step, and only while the run's commit is still its branch head: a rerun of a push or pull request run joins its branch's concurrency group and would cancel a newer run. A dispatched release run has its own group, so pushes never cancel it. The rerun includes the dependent `quality-gate` and `release-continuation` jobs, so a dispatched run continues as usual. A rerun's completion is caused by the default token and may start no workflow, so the retry job waits for each rerun itself, retries again if needed, and dispatches the release when a main push run passes on a rerun; serialized, idempotent orchestration makes a second trigger harmless. When someone reruns the run between the inspection and the retry job's request, GitHub refuses the second rerun; the job then ends successfully and leaves that attempt to the other rerun, whose completion starts this workflow again. If the wait runs out, `gh workflow run release.yml --ref main -f quality_run_id=<run id>` continues from the successful run.

These distinctions follow [GitHub's token event policy](https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/trigger-a-workflow), [required-check event restrictions](https://docs.github.com/en/pull-requests/how-tos/merge-and-close-pull-requests/troubleshooting-required-status-checks), and [commit-status API](https://docs.github.com/en/rest/commits/statuses). The exact-source full dispatched run supplies the measured QA result. The held pull-request run never starts and would later show as a failure, so after projecting the status, orchestration deletes the candidate's held `quality` runs from the bot on that exact SHA. A failed lookup or deletion only leaves that run in place; it never stops the release.

Expand Down
10 changes: 8 additions & 2 deletions scripts/lib/RunnerRetry.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public static function shouldRerun(array $run, array $jobs, string $repository,
*
* @param Closure(string): mixed $get GETs a repository API path
* @param Closure(string): ?string $branchHead the branch's current head, null when gone
* @param Closure(): void $rerun reruns the run's failed jobs
* @param Closure(): bool $rerun reruns the run's failed jobs; false when the run is already
* running again, rerun by someone else between the inspection and the request
* @param Closure(): void $continueRelease dispatches the release for this run
* @param Closure(int): void $sleep waits that many seconds
*/
Expand Down Expand Up @@ -102,7 +103,12 @@ public static function retry(
)) {
break;
}
$rerun();
if (!$rerun()) {
// Whoever reran it owns that attempt. A rerun by a person starts this workflow
// again when it completes; one by the default token cannot exist here, since
// this workflow's concurrency group holds one job per run.
return "quality run {$runId} attempt {$attempt}: already rerun elsewhere";
}
$reran = true;
for ($poll = 0;; $poll++) {
if ($poll === $polls) {
Expand Down
20 changes: 13 additions & 7 deletions scripts/runner-retry.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use PhpProfiler\Tooling\Arguments;
use PhpProfiler\Tooling\Process;
use PhpProfiler\Tooling\ProcessFailedStatus;
use PhpProfiler\Tooling\RunnerRetry;

$usage = 'runner-retry.php <repository> <quality-run-id>';
Expand Down Expand Up @@ -47,13 +48,18 @@
$repository,
$get,
$branchHead,
static fn() => Process::check([
'gh',
'api',
'--method',
'POST',
"repos/{$repository}/actions/runs/{$runId}/rerun-failed-jobs",
]),
static function () use ($repository, $runId): bool {
$command = ['gh', 'api', '--method', 'POST', "repos/{$repository}/actions/runs/{$runId}/rerun-failed-jobs"];
$result = Process::run($command);
if ($result['status'] === 0) {
return true;
}
// Someone reran the run after it was inspected: GitHub refuses a second rerun.
if (str_contains($result['stdout'] . $result['stderr'], 'This workflow is already running')) {
return false;
}
throw new ProcessFailedStatus($command, $result['status'] ?? -1, $result['stderr']);
},
static fn() => Process::check([
'gh',
'workflow',
Expand Down
25 changes: 21 additions & 4 deletions tests/tools/RunnerRetryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,13 @@ function unassignedJobs(): array
* Runs RunnerRetry::retry() against attempts that follow one another on each rerun; each entry
* is [run changes, jobs]. Returns the outcome, the reruns, the release dispatches and sleeps.
*/
function retryScenario(array $attempts, array $run = [], int $polls = 330, bool $finishes = true): array
{
function retryScenario(
array $attempts,
array $run = [],
int $polls = 330,
bool $finishes = true,
bool $accepted = true,
): array {
$state = ['attempt' => 0, 'reruns' => 0, 'releases' => 0, 'sleeps' => 0];
$current = static function () use (&$state, $attempts, $run, $finishes): array {
[$changes] = $attempts[$state['attempt']];
Expand All @@ -77,9 +82,13 @@ function retryScenario(array $attempts, array $run = [], int $polls = 330, bool
RETRY_REPOSITORY,
$get,
static fn(string $branch): ?string => $branch === 'gone' ? null : RETRY_SHA,
static function () use (&$state): void {
static function () use (&$state, $accepted): bool {
$state['reruns']++;
if (!$accepted) {
return false;
}
$state['attempt']++;
return true;
},
static function () use (&$state): void {
$state['releases']++;
Expand Down Expand Up @@ -215,6 +224,13 @@ function passedJobs(): array
same([1, 0, 2], [$reruns, $releases, $sleeps]);
same('quality run 7: attempt 2 did not complete in time', $outcome);
},
'a run already rerun elsewhere is left to that rerun' => static function (): void {
// GitHub refuses the request when someone reran the run after it was inspected.
$failed = [['conclusion' => 'failure'], unassignedJobs()];
[$outcome, $reruns, $releases, $sleeps] = retryScenario([$failed], ['event' => 'push'], accepted: false);
same([1, 0, 0], [$reruns, $releases, $sleeps]);
same('quality run 7 attempt 1: already rerun elsewhere', $outcome);
},
'unexpected API answers stop without a rerun' => static function (): void {
$calls = 0;
$never = static function () use (&$calls): void {
Expand Down Expand Up @@ -258,8 +274,9 @@ function passedJobs(): array
RETRY_REPOSITORY,
$get,
static fn(): string => RETRY_SHA,
static function () use (&$counts): void {
static function () use (&$counts): bool {
$counts['reruns']++;
return true;
},
static function () use (&$counts): void {
$counts['releases']++;
Expand Down
Loading