Fix frontend release version recording (#342)

Add a scoped release-gate endpoint for exact frontend SHA recording and independent readback.
This commit is contained in:
Jeppe B
2026-08-03 16:11:09 +02:00
committed by GitHub
parent 1f03b46564
commit 842b06c93f
3 changed files with 120 additions and 0 deletions
@@ -87,6 +87,51 @@ it('verifies CI release gate bearer tokens from dedicated release credentials',
}
});
it('normalizes gate-authenticated frontend release version updates', function (): void {
$release = release_manager::normalizeFrontendVersionGateInput([
'version' => 'A' . str_repeat('b', 39),
'repository' => 'https://github.com/copenhagentruckwash/pleno-vue.git',
'branch' => 'master',
'build_id' => '30818161014-2',
]);
expect($release)->toBe([
'version' => 'a' . str_repeat('b', 39),
'repository' => 'copenhagentruckwash/pleno-vue',
'branch' => 'master',
'build_id' => '30818161014-2',
]);
});
it('rejects untrusted frontend release version updates', function (array $payload, string $message): void {
expect(fn () => release_manager::normalizeFrontendVersionGateInput($payload))->toThrow(RuntimeException::class, $message);
})->with([
'short commit' => [[
'version' => 'deadbeef',
'repository' => 'copenhagentruckwash/pleno-vue',
'branch' => 'master',
'build_id' => '123-1',
], 'full commit SHA'],
'wrong repository' => [[
'version' => str_repeat('a', 40),
'repository' => 'copenhagentruckwash/api',
'branch' => 'master',
'build_id' => '123-1',
], 'repository is not authorized'],
'wrong branch' => [[
'version' => str_repeat('a', 40),
'repository' => 'copenhagentruckwash/pleno-vue',
'branch' => 'beta',
'build_id' => '123-1',
], 'branch must be master'],
'invalid build id' => [[
'version' => str_repeat('a', 40),
'repository' => 'copenhagentruckwash/pleno-vue',
'branch' => 'master',
'build_id' => '../release',
], 'build id is invalid'],
]);
it('normalizes app-specific release gate auto-sync metadata', function (): void {
$manager = new release_manager();
$normalizeGate = new ReflectionMethod(release_manager::class, 'normalizeReleaseGateInput');
@@ -1182,7 +1227,11 @@ it('defines release manager schema, routes, permissions, and system-status integ
expect($route)->toContain('/release/timeline/events');
expect($route)->toContain('/release/github/webhook');
expect($route)->toContain('/release/gate/test-runs');
expect($route)->toContain('/release/gate/frontend-version');
expect($route)->toContain('releaseGateToken');
expect($route)->toContain('normalizeFrontendVersionGateInput');
expect($route)->toContain("redis->set('worker_target_version'");
expect($route)->toContain("redis->get('worker_target_version'");
expect($route)->toContain('/superuser/releases/config');
expect($route)->toContain('/superuser/releases/github/repositories');
expect($route)->toContain('/superuser/releases/github/branches');