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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/.gitignore export-ignore
/composer.lock export-ignore
/demo export-ignore
/docker export-ignore
/phpstan.neon export-ignore
/phpunit.xml export-ignore
/pint.json export-ignore
Expand Down
8 changes: 4 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ PHPStan, Rector and the type coverage read `src` and `tests`; Pint reads the who
The code must run on PHP 8.4 and 8.5, on macOS, and on Linux with glibc and with musl. The Docker
jobs in CI run the suites as a non-root user, so that the file-mode tests run. To run
such a job locally, use a clean clone, because the command copies the whole directory. Use `debian`
or `alpine` as the directory in `.github/docker/`:
or `alpine` as the directory in `docker/`:

```sh
docker build --quiet --tag tests .github/docker/debian
docker build --quiet --tag tests docker/debian
docker run --rm --volume "$PWD:/src:ro" --entrypoint sh tests -euc '
cp -a /src /work
chown -R www-data /work
Expand All @@ -71,9 +71,9 @@ A workflow uses zizmor to audit the workflows and the Dependabot configuration i
actionlint to check the workflows. Run both when you change anything there:

```sh
docker build --quiet --tag zizmor .github/docker/zizmor
docker build --quiet --tag zizmor docker/zizmor
docker run --rm --volume "$PWD:/src:ro" --workdir /src zizmor --offline .github
docker build --quiet --tag actionlint .github/docker/actionlint
docker build --quiet --tag actionlint docker/actionlint
docker run --rm --volume "$PWD:/src:ro" --workdir /src actionlint -no-color
```

Expand Down
11 changes: 6 additions & 5 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ updates:
actions:
patterns: ['*']

# The images the jobs of Alpine, Debian and the workflows run in, and the image of the demo.
# The images the jobs of Alpine, Debian and the workflows run in, and the image of the demo. None
# is under .github: GitHub refuses a pull request of this ecosystem that changes a file there.
- package-ecosystem: docker
directories:
- /demo
- /.github/docker/actionlint
- /.github/docker/alpine
- /.github/docker/debian
- /.github/docker/zizmor
- /docker/actionlint
- /docker/alpine
- /docker/debian
- /docker/zizmor
schedule:
interval: monthly
cooldown:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ on:
permissions:
contents: read

# Dependabot updates the actions and the images of `.github/docker`. Composer, pinned by digest in
# `tools`, is updated by hand, to the version of the Composer image in `.github/docker`.
# Dependabot updates the actions and the images of `docker`. Composer, pinned by digest in
# `tools`, is updated by hand, to the version of the Composer image in `docker`.

concurrency:
group: tests-${{ github.ref }}
Expand Down Expand Up @@ -249,7 +249,7 @@ jobs:
key: frankenphp-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('tests/Fixtures/frankenphp/release.lock') }}

- name: Build
run: docker build --quiet --tag tests .github/docker/alpine
run: docker build --quiet --tag tests docker/alpine

# On the runner, because the image has no gh to check the attestation. Into the tree, so the
# cache keeps it and the container of the test copies it.
Expand Down Expand Up @@ -293,7 +293,7 @@ jobs:
key: frankenphp-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('tests/Fixtures/frankenphp/release.lock') }}

- name: Build
run: docker build --quiet --tag tests .github/docker/debian
run: docker build --quiet --tag tests docker/debian

# On the runner, because the image has no gh to check the attestation. Into the tree, so the
# cache keeps it and the container of the test copies it.
Expand Down Expand Up @@ -331,10 +331,10 @@ jobs:

- name: Audit
run: |
docker build --quiet --tag zizmor .github/docker/zizmor
docker build --quiet --tag zizmor docker/zizmor
docker run --rm --volume "$PWD:/src:ro" --workdir /src zizmor --offline .github

- name: Lint
run: |
docker build --quiet --tag actionlint .github/docker/actionlint
docker build --quiet --tag actionlint docker/actionlint
docker run --rm --volume "$PWD:/src:ro" --workdir /src actionlint -no-color
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
<testsuite name="Example">
<directory>tests/Example</directory>
</testsuite>
<testsuite name="Repo">
<directory>tests/Repo</directory>
</testsuite>
</testsuites>
<source>
<include>
Expand Down
4 changes: 2 additions & 2 deletions tests/GoNetHttp/GoNetHttpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ function scopeEvents(array $events, string $bytes, Closure $shown, int $maxHead)

expect('go'.$go)->toBe(GoReference::version())
->and(file_get_contents(__DIR__.'/install-go.php'))->toContain("'go".$go."' => [")
->and(file_get_contents(__DIR__.'/../../.github/docker/debian/Dockerfile'))->toContain('FROM golang:'.$go.'@')
->and(file_get_contents(__DIR__.'/../../.github/docker/alpine/Dockerfile'))->toContain('FROM golang:'.$go.'-alpine@');
->and(file_get_contents(__DIR__.'/../../docker/debian/Dockerfile'))->toContain('FROM golang:'.$go.'@')
->and(file_get_contents(__DIR__.'/../../docker/alpine/Dockerfile'))->toContain('FROM golang:'.$go.'-alpine@');
})->group('pins');

// A git blob is the SHA-1 of `blob <length>\0<bytes>`. VERSION is not in go.lock, because it
Expand Down
39 changes: 39 additions & 0 deletions tests/Repo/DependabotTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

it('names each directory with a Dockerfile to Dependabot, and none under .github', function (): void {
$root = dirname(__DIR__, 2);
$config = (string) file_get_contents($root.'/.github/dependabot.yml');
$start = strpos($config, " - package-ecosystem: docker\n");
assert(is_int($start));
preg_match('/^ directories:\n((?: - \S+\n)+)/m', substr($config, $start), $match);
$directories = array_map(static fn (string $line): string => substr($line, 8), explode("\n", trim($match[1] ?? '', "\n")));

$dockerfiles = [];
$iterator = new RecursiveIteratorIterator(new RecursiveCallbackFilterIterator(
new RecursiveDirectoryIterator($root, FilesystemIterator::SKIP_DOTS),
static fn (SplFileInfo $file): bool => ! in_array($file->getFilename(), ['.claude', '.frankenphp', '.git', '.go', '.tmp', 'vendor'], true),
));

foreach ($iterator as $file) {
assert($file instanceof SplFileInfo);

if ($file->getFilename() === 'Dockerfile') {
$dockerfiles[] = substr($file->getPath(), strlen($root));
}
}

sort($dockerfiles);

// GitHub refuses a pull request of the docker ecosystem that changes a file under .github.
expect(array_values(array_filter($directories, static fn (string $directory): bool => str_starts_with($directory, '/.github'))))->toBe([])
->and($directories)->toBe($dockerfiles)
->toContain('/demo', '/docker/debian');
});

it('leaves the Dockerfiles out of the package', function (): void {
$attributes = (string) file_get_contents(dirname(__DIR__, 2).'/.gitattributes');

expect($attributes)->toContain("\n/docker export-ignore\n", "\n/demo export-ignore\n");
});
Loading