Skip to content

Commit a6c0f74

Browse files
committed
Merge remote-tracking branch 'dunglas/main' into rpm
2 parents fe951ed + 1d74b2c commit a6c0f74

31 files changed

+955
-237
lines changed

.github/workflows/static.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ jobs:
177177
"${BINARY}" list-modules | grep http.handlers.mercure
178178
"${BINARY}" list-modules | grep http.handlers.mercure
179179
"${BINARY}" list-modules | grep http.handlers.vulcain
180+
"${BINARY}" php-cli -r "echo 'Sanity check passed';"
180181
env:
181182
BINARY: ./frankenphp-linux-${{ matrix.platform == 'linux/amd64' && 'x86_64' || 'aarch64' }}${{ matrix.debug && '-debug' || '' }}${{ matrix.mimalloc && '-mimalloc' || '' }}
182183

@@ -284,6 +285,7 @@ jobs:
284285
"${BINARY}" list-modules | grep http.handlers.mercure
285286
"${BINARY}" list-modules | grep http.handlers.mercure
286287
"${BINARY}" list-modules | grep http.handlers.vulcain
288+
"${BINARY}" php-cli -r "echo 'Sanity check passed';"
287289
env:
288290
BINARY: ./gh-output/frankenphp-linux-${{ matrix.platform == 'linux/amd64' && 'x86_64' || 'aarch64' }}-gnu
289291

@@ -327,8 +329,8 @@ jobs:
327329
working-directory: /tmp/metadata-gnu
328330
run: |
329331
# shellcheck disable=SC2046,SC2086
330-
docker buildx imagetools create $(jq -cr '.target."static-builder-gnu".tags | map("-t " + . + "-gnu") | join(" ")' <<< "${GNU_METADATA}") \
331-
$(printf "${IMAGE_NAME}-gnu@sha256:%s " *)
332+
docker buildx imagetools create $(jq -cr '.target."static-builder-gnu".tags | map("-t " + .) | join(" ")' <<< "${GNU_METADATA}") \
333+
$(printf "${IMAGE_NAME}@sha256:%s " *)
332334
env:
333335
GNU_METADATA: ${{ needs.prepare.outputs.gnu_metadata }}
334336
- name: Inspect image
@@ -400,5 +402,6 @@ jobs:
400402
"${BINARY}" list-modules | grep http.handlers.mercure
401403
"${BINARY}" list-modules | grep http.handlers.mercure
402404
"${BINARY}" list-modules | grep http.handlers.vulcain
405+
"${BINARY}" php-cli -r "echo 'Sanity check passed';"
403406
env:
404407
BINARY: dist/frankenphp-mac-${{ matrix.platform }}

.github/workflows/tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
- name: Run integrations tests
6969
run: ./reload_test.sh
7070
- name: Lint Go code
71-
uses: golangci/golangci-lint-action@v7
71+
uses: golangci/golangci-lint-action@v8
7272
if: matrix.php-versions == '8.4'
7373
with:
7474
version: latest

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ You can also run command-line scripts with:
4343
frankenphp php-cli /path/to/your/script.php
4444
```
4545

46-
> ![WARNING]
46+
> [!WARNING]
4747
>
4848
> In production, prefer using [the Docker images](#docker), [the Brew package](#homebrew)
4949
> or [compiling FrankenPHP from sources](https://frankenphp.dev/docs/compile/).

build-static.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,9 @@ if [ "${SPC_LIBC}" = "musl" ] && [[ "${SPC_OPT_BUILD_ARGS}" != *"--disable-opcac
4646
fi
4747
# init spc download additional args
4848
if [ -z "${SPC_OPT_DOWNLOAD_ARGS}" ]; then
49+
SPC_OPT_DOWNLOAD_ARGS="--ignore-cache-sources=php-src --retry 5"
4950
if [ "${SPC_LIBC}" = "musl" ]; then
50-
SPC_OPT_DOWNLOAD_ARGS="--prefer-pre-built --ignore-cache-sources=php-src"
51-
else
52-
SPC_OPT_DOWNLOAD_ARGS="--ignore-cache-sources=php-src"
51+
SPC_OPT_DOWNLOAD_ARGS="${SPC_OPT_DOWNLOAD_ARGS} --prefer-pre-built"
5352
fi
5453
fi
5554
# if we need debug symbols, disable strip

caddy/admin_test.go

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package caddy_test
22

33
import (
4+
"bytes"
45
"encoding/json"
6+
"fmt"
7+
"github.com/dunglas/frankenphp/internal/fastabs"
58
"io"
69
"net/http"
710
"sync"
@@ -213,3 +216,82 @@ func getDebugState(t *testing.T, tester *caddytest.Tester) frankenphp.FrankenPHP
213216

214217
return debugStates
215218
}
219+
220+
func TestAddModuleWorkerViaAdminApi(t *testing.T) {
221+
// Initialize a server with admin API enabled
222+
tester := caddytest.NewTester(t)
223+
tester.InitServer(`
224+
{
225+
skip_install_trust
226+
admin localhost:2999
227+
http_port `+testPort+`
228+
229+
frankenphp
230+
}
231+
232+
localhost:`+testPort+` {
233+
route {
234+
root ../testdata
235+
php
236+
}
237+
}
238+
`, "caddyfile")
239+
240+
// Get initial debug state to check number of workers
241+
initialDebugState := getDebugState(t, tester)
242+
initialWorkerCount := 0
243+
for _, thread := range initialDebugState.ThreadDebugStates {
244+
if thread.Name != "" && thread.Name != "ready" {
245+
initialWorkerCount++
246+
}
247+
}
248+
249+
// Create a Caddyfile configuration with a module worker
250+
workerConfig := `
251+
{
252+
skip_install_trust
253+
admin localhost:2999
254+
http_port ` + testPort + `
255+
256+
frankenphp
257+
}
258+
259+
localhost:` + testPort + ` {
260+
route {
261+
root ../testdata
262+
php {
263+
worker ../testdata/worker-with-counter.php 1
264+
}
265+
}
266+
}
267+
`
268+
269+
// Send the configuration to the admin API
270+
adminUrl := "http://localhost:2999/load"
271+
r, err := http.NewRequest("POST", adminUrl, bytes.NewBufferString(workerConfig))
272+
assert.NoError(t, err)
273+
r.Header.Set("Content-Type", "text/caddyfile")
274+
resp := tester.AssertResponseCode(r, http.StatusOK)
275+
defer resp.Body.Close()
276+
277+
// Get the updated debug state to check if the worker was added
278+
updatedDebugState := getDebugState(t, tester)
279+
updatedWorkerCount := 0
280+
workerFound := false
281+
filename, _ := fastabs.FastAbs("../testdata/worker-with-counter.php")
282+
for _, thread := range updatedDebugState.ThreadDebugStates {
283+
if thread.Name != "" && thread.Name != "ready" {
284+
updatedWorkerCount++
285+
if thread.Name == "Worker PHP Thread - "+filename {
286+
workerFound = true
287+
}
288+
}
289+
}
290+
291+
// Assert that the worker was added
292+
assert.Greater(t, updatedWorkerCount, initialWorkerCount, "Worker count should have increased")
293+
assert.True(t, workerFound, fmt.Sprintf("Worker with name %q should be found", "Worker PHP Thread - "+filename))
294+
295+
// Make a request to the worker to verify it's working
296+
tester.AssertGetResponse("http://localhost:"+testPort+"/worker-with-counter.php", http.StatusOK, "requests:1")
297+
}

0 commit comments

Comments
 (0)