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
6 changes: 4 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,10 @@ composer frankenphp:lock # new FrankenPHP versions into release.lock, needs gh
```

- The `check:` commands need `composer install`, git and the network, but no token. `check:go` first
runs `frankenphp:install`, as the suites do. `check:go`, `check:frankenphp` and `frankenphp:lock`
also need PHP's curl extension.
runs `frankenphp:install`, as the suites do. Each `check:` command and `frankenphp:lock` also
needs PHP's curl extension.
- The newest FrankenPHP is its newest release, not its newest tag: upstream tags a version and
publishes the release hours later.
- `check:frankenphp` downloads the newest FrankenPHP binary into `.frankenphp/newest` and runs it.
When it finds new versions, run `composer frankenphp:lock`. It writes the versions of the newest
binary into `release.lock` after `gh attestation verify` shows that FrankenPHP's workflow built
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/caddy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,6 @@ jobs:
run: composer install --no-interaction --prefer-dist

- name: Compare with caddy.lock and frankenphp.lock
env:
GITHUB_TOKEN: ${{ github.token }}
run: composer check:caddy
7 changes: 4 additions & 3 deletions tests/Caddy/check-caddy.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
declare(strict_types=1);

// composer check:caddy compares caddy.lock with the newest release of Caddy, and frankenphp.lock of
// the layer of Caddy with that of FrankenPHP: a tag vX.Y.Z, without beta or rc. Another blob fails
// the check, but does not stop the next comparison.
// the layer of Caddy with that of the newest release of FrankenPHP. For Caddy, that is the newest tag
// vX.Y.Z, without beta or rc. Another blob fails the check, but does not stop the next comparison.

use SorgeIt\HttpServer\Tests\FrankenPhp\Release;
use SorgeIt\HttpServer\Tests\Upstream;

require __DIR__.'/../../vendor/autoload.php';
Expand All @@ -14,7 +15,7 @@
const FRANKENPHP = 'https://github.com/php/frankenphp.git';

$caddy = Upstream::newestTag(CADDY, '/^v2\.\d+\.\d+$/');
$frankenphp = Upstream::newestTag(FRANKENPHP, '/^v1\.\d+\.\d+$/');
$frankenphp = Release::newest();
echo 'Newest Caddy: '.$caddy.'. Newest FrankenPHP: '.$frankenphp.'.'.PHP_EOL;
$same = Upstream::locks(__DIR__.'/../Fixtures/caddy/caddy.lock', CADDY, $caddy);
$same = Upstream::locks(__DIR__.'/../Fixtures/caddy/frankenphp.lock', FRANKENPHP, $frankenphp) && $same;
Expand Down
25 changes: 23 additions & 2 deletions tests/FrankenPhp/Release.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ public static function attest(string $file, string $asset): void
*/
public static function digests(string $version): array
{
$token = getenv('GITHUB_TOKEN');
$release = json_decode(self::load('https://api.github.com/repos/php/frankenphp/releases/tags/'.$version, ['Accept: application/vnd.github+json', 'User-Agent: sorge-it/http-server', ...(is_string($token) && $token !== '' ? ['Authorization: Bearer '.$token] : [])]), true, flags: JSON_THROW_ON_ERROR);
$release = self::api('releases/tags/'.$version);
$sha256 = [];

foreach (is_array($release) && is_array($release['assets'] ?? null) ? $release['assets'] : [] as $asset) {
Expand All @@ -118,6 +117,17 @@ public static function digests(string $version): array
return $sha256;
}

/**
* The tag of the newest release, such as `v1.13.6`. Not the newest tag: upstream tags a version
* and publishes its release hours later.
*/
public static function newest(): string
{
$release = self::api('releases/latest');

return is_array($release) && is_string($release['tag_name'] ?? null) ? $release['tag_name'] : throw new RuntimeException('The API of GitHub names no newest release of FrankenPHP.');
}

/**
* Puts the asset of the release into the file, executable, after a check of its SHA-256.
*/
Expand All @@ -137,6 +147,17 @@ public static function download(string $version, string $asset, string $sha256,
rename($part, $file);
}

/**
* The JSON of the path below the repository of FrankenPHP in the API of GitHub. A
* `GITHUB_TOKEN` raises the limit of 60 calls in an hour, but no call needs it.
*/
private static function api(string $path): mixed
{
$token = getenv('GITHUB_TOKEN');

return json_decode(self::load('https://api.github.com/repos/php/frankenphp/'.$path, ['Accept: application/vnd.github+json', 'User-Agent: sorge-it/http-server', ...(is_string($token) && $token !== '' ? ['Authorization: Bearer '.$token] : [])]), true, flags: JSON_THROW_ON_ERROR);
}

/**
* The body of the URL, or with a file, the body in that file.
*
Expand Down
4 changes: 2 additions & 2 deletions tests/FrankenPhp/check-frankenphp.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
declare(strict_types=1);

// composer check:frankenphp compares frankenphp.lock, release.lock and php-src.lock with the newest
// FrankenPHP, a tag vX.Y.Z. A difference does not stop the next comparison. Its binary for this
// release of FrankenPHP. A difference does not stop the next comparison. Its binary for this
// machine stays in .frankenphp/newest; the output `binary` names it for a workflow.

use SorgeIt\HttpServer\Tests\FrankenPhp\Release;
Expand All @@ -13,7 +13,7 @@

const FRANKENPHP = 'https://github.com/php/frankenphp.git';

$tag = Upstream::newestTag(FRANKENPHP, '/^v1\.\d+\.\d+$/');
$tag = Release::newest();
echo 'Newest FrankenPHP: '.$tag.PHP_EOL;
$same = Upstream::locks(__DIR__.'/../Fixtures/frankenphp/frankenphp.lock', FRANKENPHP, $tag);

Expand Down
2 changes: 1 addition & 1 deletion tests/FrankenPhp/lock-frankenphp.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

require __DIR__.'/../../vendor/autoload.php';

$tag = Upstream::newestTag('https://github.com/php/frankenphp.git', '/^v1\.\d+\.\d+$/');
$tag = Release::newest();
$digests = Release::digests($tag);
$assets = array_values(Release::ASSETS);
sort($assets);
Expand Down
Loading