From 491c662f879fe9f2e9abae05f4676c3870099d86 Mon Sep 17 00:00:00 2001 From: stefansorge <3419073+sorge-it@users.noreply.github.com> Date: Sat, 21 Nov 2026 09:34:36 +0100 Subject: [PATCH] docs: move the community files to .github and add a pull request template GitHub's community profile looks for CONTRIBUTING, CODE_OF_CONDUCT, SECURITY and the pull request template in .github, as safe-unzip has them. The root keeps README, CHANGELOG and LICENSE. --- .gitattributes | 2 - .../CODE_OF_CONDUCT.md | 0 CONTRIBUTING.md => .github/CONTRIBUTING.md | 119 ++++++++++-------- SECURITY.md => .github/SECURITY.md | 7 +- .github/pull_request_template.md | 10 ++ CHANGELOG.md | 5 + README.md | 9 +- composer.json | 2 +- 8 files changed, 90 insertions(+), 64 deletions(-) rename CODE_OF_CONDUCT.md => .github/CODE_OF_CONDUCT.md (100%) rename CONTRIBUTING.md => .github/CONTRIBUTING.md (89%) rename SECURITY.md => .github/SECURITY.md (65%) create mode 100644 .github/pull_request_template.md diff --git a/.gitattributes b/.gitattributes index ce4464a..e7ce42a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6,8 +6,6 @@ /.gitattributes export-ignore /.gitignore export-ignore /composer.lock export-ignore -/CONTRIBUTING.md export-ignore -/CODE_OF_CONDUCT.md export-ignore /demo export-ignore /phpstan.neon export-ignore /phpunit.xml export-ignore diff --git a/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md similarity index 100% rename from CODE_OF_CONDUCT.md rename to .github/CODE_OF_CONDUCT.md diff --git a/CONTRIBUTING.md b/.github/CONTRIBUTING.md similarity index 89% rename from CONTRIBUTING.md rename to .github/CONTRIBUTING.md index 1fd9e0f..1ea6c93 100644 --- a/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -2,8 +2,9 @@ Pull requests are welcome. The issue tracker is closed: report a bug as a pull request with a failing test; a fix is welcome but not required. Vulnerabilities are the exception: report them -privately; see [SECURITY.md](SECURITY.md). Everyone who takes part follows the -[Code of Conduct](CODE_OF_CONDUCT.md). +privately; see the [security policy](https://github.com/sorge-it/http-server/security/policy). +Everyone who takes part follows the +[Code of Conduct](https://github.com/sorge-it/http-server/blob/main/.github/CODE_OF_CONDUCT.md). ## Setup @@ -27,57 +28,15 @@ composer test # Pint and Rector dry runs, PHPStan, 100% type cove `.frankenphp/`, verifies the SHA-256 against the GitHub API, and checks the versions the binary reports; the suite runs `frankenphp:install` itself before it starts FrankenPHP. FrankenPHP publishes no binary for macOS on x64, so those suites cannot run there; use a Docker job instead - (see [Before you open a pull request](#before-you-open-a-pull-request)). + (see [Tests](#tests)). - Where `gh` has a login or a token, `frankenphp:install` also uses `gh attestation verify` to check that FrankenPHP's workflow built the binary. A binary that fails the check is deleted. The check comes before the binary first runs. Where `gh` has neither, as in a Docker image, the binary runs unchecked; so in CI, a Docker job installs the binary on the runner, which has `gh`. -## Reporting a bug +## Tests -Open a pull request that contains only a failing test (see [Writing a test](#writing-a-test)), and -say what you expected. A maintainer adds the fix. - -## Fixing a bug - -Open a pull request with: - -- a test that fails without the change; see [Writing a test](#writing-a-test); -- the change; -- a line under `[Unreleased]` in `CHANGELOG.md` when the package's behavior changes; -- a description of what went wrong and why the change fixes it, and the output of `php -v`. - -If you do not know how to fix it, describe the problem to a coding agent and let it draft the pull -request. Review the change and run the tests before you open it. - -### Writing a test - -- Where Go `net/http` decides the result, the test is a probe in - `tests/Fixtures/go-net-http/cases.json`, with the fields `group`, `name`, `source: "probe"`, - `rule` (Go's file and function) and `request`, and the limits `maxHeaderBytes` or - `maxHeaderValueCount` where needed. Then run `composer go:extract`. The `GoNetHttp` suite sends - the probe to Go for the parser and to FrankenPHP for the response, and compares the bytes. -- Where Caddy decides, the probe goes into `tests/Fixtures/caddy/cases.json` in the same form, with - Caddy's file and function as `rule`, and the `FrankenPhp` suite compares it against FrankenPHP. -- No test spells out a FrankenPHP response as a literal. Where the handler must be PHP, compare - `answers()` with `modelAnswers()`. -- Other tests go into the suite that covers their part. - [tests/Fixtures/README.md](tests/Fixtures/README.md) describes the fixtures. - -## Proposing a feature - -Read [Scope](README.md#scope) and [HTTP behavior](README.md#http-behavior) first. A feature -outside the scope, such as TLS or a public address, will not be merged. - -- Each out-of-scope row of Scope has its guard in [`tests/Scope/out.php`](tests/Scope/out.php): a - pattern, a request, or the reason the row has none. A new out-of-scope row comes with its guard. -- A change that removes out-of-scope behavior adds a pattern or a request that detects the behavior - if it comes back. Where neither can, the row's reason says why and names the test that detects - it. -- A new limit comes with a `Limits` property, a status, a test for each side of the limit, and a - line with its default in [Limits and timeouts](README.md#limits-and-timeouts). - -## Before you open a pull request +Before you open a pull request: ```sh composer test:coverage # 100% line coverage, needs pcov or Xdebug @@ -118,6 +77,23 @@ docker build --quiet --tag actionlint .github/docker/actionlint docker run --rm --volume "$PWD:/src:ro" --workdir /src actionlint -no-color ``` +### Writing a test + +- Where Go `net/http` decides the result, the test is a probe in + `tests/Fixtures/go-net-http/cases.json`, with the fields `group`, `name`, `source: "probe"`, + `rule` (Go's file and function) and `request`, and the limits `maxHeaderBytes` or + `maxHeaderValueCount` where needed. Then run `composer go:extract`. The `GoNetHttp` suite sends + the probe to Go for the parser and to FrankenPHP for the response, and compares the bytes. +- Where Caddy decides, the probe goes into `tests/Fixtures/caddy/cases.json` in the same form, with + Caddy's file and function as `rule`, and the `FrankenPhp` suite compares it against FrankenPHP. +- No test spells out a FrankenPHP response as a literal. Where the handler must be PHP, compare + `answers()` with `modelAnswers()`. +- Other tests go into the suite that covers their part. + [tests/Fixtures/README.md](https://github.com/sorge-it/http-server/blob/main/tests/Fixtures/README.md) + describes the fixtures. + +### Mutation tests + A workflow runs the mutation tests every week, split into four parts of `src/`. Run them with pcov when you change `src/`. They run one mutant after another, and all of `src/` takes several hours, so run only the files you changed, with `--path`. Do not use `--parallel`: with it, Pest Mutate @@ -138,13 +114,7 @@ Two kinds of results can be misleading: - A mutant whose run takes too long counts as killed. Run such a mutant alone with `--id` before you count it as killed. -## Review - -A maintainer reviews a pull request once it is ready for review and the `tests` workflow passes. A -bug report may fail only in the test that it adds. Inactive drafts may be closed. Pull requests -opened in bulk are closed without review. - -## Updating the pins (maintainers) +### Updating the pins (maintainers) FrankenPHP rebuilds the binaries of its newest release every night: new bytes, and sometimes a new PHP or Caddy. That is why `release.lock` names the versions of FrankenPHP, PHP and Caddy, not a @@ -173,3 +143,44 @@ composer frankenphp:lock # new FrankenPHP versions into release.lock, needs gh - Then update each lock file that the `pins` group test in `tests/FrankenPhp/FrankenPhpTest.php` reads, each version that it names, and the tags in `tests/Fixtures/README.md`. The README names no pinned version. + +## Scope + +Read [Scope](https://github.com/sorge-it/http-server#scope) and +[HTTP behavior](https://github.com/sorge-it/http-server#http-behavior) in the README first. A +feature outside the scope, such as TLS or a public address, will not be merged. + +- Each out-of-scope row of Scope has its guard in + [`tests/Scope/out.php`](https://github.com/sorge-it/http-server/blob/main/tests/Scope/out.php): a + pattern, a request, or the reason the row has none. A new out-of-scope row comes with its guard. +- A change that removes out-of-scope behavior adds a pattern or a request that detects the behavior + if it comes back. Where neither can, the row's reason says why and names the test that detects + it. +- A new limit comes with a `Limits` property, a status, a test for each side of the limit, and a + line with its default in + [Limits and timeouts](https://github.com/sorge-it/http-server#limits-and-timeouts). + +## Pull requests + +### Reporting a bug + +Open a pull request that contains only a failing test (see [Writing a test](#writing-a-test)), and +say what you expected. A maintainer adds the fix. + +### Fixing a bug + +Open a pull request with: + +- a test that fails without the change; see [Writing a test](#writing-a-test); +- the change; +- a line under `[Unreleased]` in `CHANGELOG.md` when the package's behavior changes; +- a description of what went wrong and why the change fixes it, and the output of `php -v`. + +If you do not know how to fix it, describe the problem to a coding agent and let it draft the pull +request. Review the change and run the tests before you open it. + +### Review + +A maintainer reviews a pull request once it is ready for review and the `tests` workflow passes. A +bug report may fail only in the test that it adds. Inactive drafts may be closed. Pull requests +opened in bulk are closed without review. diff --git a/SECURITY.md b/.github/SECURITY.md similarity index 65% rename from SECURITY.md rename to .github/SECURITY.md index f66c483..5fccdd3 100644 --- a/SECURITY.md +++ b/.github/SECURITY.md @@ -12,6 +12,7 @@ Do not report a vulnerability in a public issue or pull request. Report it priva Include the raw request bytes that reproduce the vulnerability, and the output of `php -v`. If you have a fix, say so in the report. There is no fixed response time. -The server is not for production. The README's [Scope](README.md#scope) names what it is for and -what it does not limit. [HTTP behavior](README.md#http-behavior) names what it reads and what it -rejects. +The server is not for production. The README's +[Scope](https://github.com/sorge-it/http-server#scope) names what it is for and what it does not +limit. [HTTP behavior](https://github.com/sorge-it/http-server#http-behavior) names what it reads +and what it rejects. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..42955af --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,10 @@ + + +**What goes wrong, or what the feature does:** + +**The row of Scope in the README that it touches, and the layer that decides it:** + +- [ ] A test that fails without the change; a probe in `cases.json` where Go or Caddy decides +- [ ] The output of `php -v` +- [ ] `composer test` passes; in a bug report without a fix, only the new test fails +- [ ] A line under `[Unreleased]` in `CHANGELOG.md` when the package's behavior changes diff --git a/CHANGELOG.md b/CHANGELOG.md index 75b5f44..b648cd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ All notable changes to this package are in this file. The format follows ## [Unreleased] +### Changed + +- `SECURITY.md` moved to `.github/` and is no longer in the package. The security link in + `composer.json` points to the security policy on GitHub. + ### Fixed - `new Server()` refuses a host that resolves to an address that is not loopback, such as diff --git a/README.md b/README.md index 45a52c8..ded0501 100644 --- a/README.md +++ b/README.md @@ -1266,7 +1266,7 @@ and the suite that tests them. ### The suites The suites that compare live need the Go version and the FrankenPHP binary that -[CONTRIBUTING.md](CONTRIBUTING.md#setup) installs. +[CONTRIBUTING.md](.github/CONTRIBUTING.md#setup) installs. | Suite | What it checks | Compared live with | |---|---|---| @@ -1293,13 +1293,14 @@ Debian and Alpine. Weekly jobs run the mutation tests, with a minimum score of 9 compare against the newest Caddy and FrankenPHP and against the Go version that the pinned FrankenPHP uses. One job runs the handlers of [Works with](#works-with-symfony-laravel-and-psr-15) with the newest Symfony, Laravel and Slim. Every action and every Docker image is pinned to a commit -or a digest. [CONTRIBUTING.md](CONTRIBUTING.md) covers the setup and what a pull request needs. +or a digest. [CONTRIBUTING.md](.github/CONTRIBUTING.md) covers the setup and what a pull request +needs. ## Support Found a bug? Open a pull request with a failing test; a fix is welcome but not required. The issue -tracker is closed; see [CONTRIBUTING.md](CONTRIBUTING.md). Report a vulnerability privately through -GitHub; see [SECURITY.md](SECURITY.md). +tracker is closed; see [CONTRIBUTING.md](.github/CONTRIBUTING.md). Report a vulnerability privately +through GitHub; see [SECURITY.md](.github/SECURITY.md). ## License diff --git a/composer.json b/composer.json index eafe809..1d424be 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "support": { "source": "https://github.com/sorge-it/http-server", "docs": "https://github.com/sorge-it/http-server#readme", - "security": "https://github.com/sorge-it/http-server/blob/main/SECURITY.md" + "security": "https://github.com/sorge-it/http-server/security/policy" }, "require": { "php": "^8.4",