Skip to content

Commit f116776

Browse files
wyattwalterclaude
andcommitted
ci: fix Caddy route tests and run them on Caddy config changes
The Caddy route tests workflow has failed on every weekly scheduled run since late 2024, because the test harness fell behind three changes to the code it tests: - caddy-reconfigure.mjs templates 404.html alongside index.html (#37672), but the harness only created a fake index.html, so every spec died with ENOENT before any route assertions ran. - caddy-reconfigure.mjs invokes the Caddy binary via _APPSMITH_CADDY, which only the production entrypoint exports. - The generated Caddyfile now binds the admin API to a unix socket (#41847), but the harness started Caddy with no config, leaving the admin API on the default TCP port where reloads could not reach it. The harness now bootstraps Caddy with the same admin socket, matching how the production entrypoint starts it. Two further breakages came from unpinned tooling in the test image: - Current Caddy no longer compresses the 512-byte test file; the test file is now 4096 bytes. - hurl 8 no longer picks up HURL_* environment variables, so the frame_ancestors default is passed with an explicit --variable flag, which spec-specific definitions still override. The workflow's weekly cron never caught regressions at the moment they were introduced and let it stay red quietly. It is replaced with push and pull_request triggers path-filtered to the files the workflow actually exercises. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 8ac6dc9 commit f116776

2 files changed

Lines changed: 32 additions & 8 deletions

File tree

.github/workflows/caddy-routes-test.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,24 @@ name: Caddy route tests
22

33
on:
44
workflow_dispatch:
5-
schedule:
6-
- cron: "0 0 * * MON"
5+
push:
6+
branches:
7+
- release
8+
paths:
9+
- .github/workflows/caddy-routes-test.yml
10+
- deploy/docker/fs/opt/appsmith/caddy-reconfigure.mjs
11+
- deploy/docker/fs/opt/appsmith/templates/docker.env.sh
12+
- deploy/docker/route-tests/**
13+
- deploy/docker/tests/**
14+
pull_request:
15+
branches:
16+
- release
17+
paths:
18+
- .github/workflows/caddy-routes-test.yml
19+
- deploy/docker/fs/opt/appsmith/caddy-reconfigure.mjs
20+
- deploy/docker/fs/opt/appsmith/templates/docker.env.sh
21+
- deploy/docker/route-tests/**
22+
- deploy/docker/tests/**
723

824
jobs:
925
build:

deploy/docker/route-tests/entrypoint.sh

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ reload-caddy() {
2323
}
2424

2525
run-hurl() {
26+
# Default value for the frame_ancestors variable; specs override it by
27+
# passing their own --variable frame_ancestors=... (the last definition wins).
2628
hurl --test \
29+
--variable "frame_ancestors=$default_frame_ancestors" \
2730
--resolve local.com:80:127.0.0.1 \
2831
--resolve custom-domain.com:80:127.0.0.1 \
2932
--resolve custom-domain.com:443:127.0.0.1 \
@@ -43,15 +46,17 @@ echo
4346

4447
export TMP=/tmp/appsmith
4548
export WWW_PATH="$TMP/www"
49+
export _APPSMITH_CADDY=caddy
4650

4751
# Fake files needed by the caddy-reconfigure script
4852
mkdir -p "$WWW_PATH" /opt/appsmith/editor
4953
echo -n 'index.html body, this will be replaced' > "$WWW_PATH/index.html"
5054
echo '{}' > /opt/appsmith/info.json
5155
echo -n 'actual index.html body' > /opt/appsmith/editor/index.html
52-
# A file large enough (>256 bytes) for Caddy's encode directive to compress.
56+
echo -n 'actual 404.html body' > /opt/appsmith/editor/404.html
57+
# A file large enough to exceed the encode directive's minimum length, so Caddy compresses it.
5358
mkdir -p /opt/appsmith/editor/static
54-
printf 'a%.0s' {1..512} > /opt/appsmith/editor/static/test-encoding.txt
59+
printf 'a%.0s' {1..4096} > /opt/appsmith/editor/static/test-encoding.txt
5560
mkcert -install
5661

5762
# Start echo server
@@ -60,13 +65,16 @@ XDG_DATA_HOME="$TMP/echo-data" \
6065
caddy start --config echo.caddyfile --adapter caddyfile \
6166
>> "$TMP/echo-caddy.log" 2>&1
6267

63-
# Start Caddy for use with our config to test
64-
caddy start >> "$TMP/caddy.log" 2>&1
68+
# Start Caddy for use with our config to test. The admin endpoint must be the
69+
# same unix socket that the generated Caddyfile declares, so that reloads can
70+
# reach this instance.
71+
printf '{\n\tadmin unix/%s/caddy.sock\n}\n' "$TMP" > "$TMP/bootstrap.caddyfile"
72+
caddy start --config "$TMP/bootstrap.caddyfile" --adapter caddyfile >> "$TMP/caddy.log" 2>&1
6573

6674
sleep 1
6775

6876
# Default values for Hurl variables
69-
export HURL_frame_ancestors="'self'"
77+
default_frame_ancestors="'self'"
7078

7179

7280
# Run tests, scenario by scenario
@@ -126,7 +134,7 @@ reload-caddy
126134
run-hurl common/*.hurl
127135

128136

129-
new-spec "Spec 7: Frame ancestors value with extra CSP directives"
137+
new-spec "Spec 8: Frame ancestors value with extra CSP directives"
130138
export APPSMITH_ALLOWED_FRAME_ANCESTORS="something.com; script-src something more not allowed"
131139
node /caddy-reconfigure.mjs
132140
reload-caddy

0 commit comments

Comments
 (0)