File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,16 @@ http://{{ caddy.addresses.webhook }} {
4646 }
4747 }
4848
49+ handle /ping {
50+ reverse_proxy * localhost:1234 {
51+ # Don't leak out internal problems.
52+ @error status 4xx 5xx
53+ handle_response @error {
54+ error 503
55+ }
56+ }
57+ }
58+
4959 handle {
5060 error 404
5161 }
Original file line number Diff line number Diff line change @@ -65,6 +65,15 @@ async def test_update_repo(tmp_path_factory):
6565 assert dest_commit == src_commit
6666
6767
68+ async def test_ping (aiohttp_client , monkeypatch , tmp_path ):
69+ """Test ping always works."""
70+ monkeypatch .setenv ('SITE_DIR' , str (tmp_path ))
71+ client = await aiohttp_client (create_app ())
72+
73+ resp = await client .get ('/ping' )
74+ assert resp .status == 200
75+
76+
6877async def test_github_webhook_errors (aiohttp_client , monkeypatch , tmp_path ):
6978 """Test invalid inputs to webhook."""
7079 monkeypatch .setenv ('SITE_DIR' , str (tmp_path ))
Original file line number Diff line number Diff line change @@ -173,6 +173,11 @@ async def github_webhook(request: web.Request):
173173 return web .Response (status = 200 )
174174
175175
176+ async def ping (request : web .Request ):
177+ """Respond to a ping, thus verifying the webhook service is alive."""
178+ return web .Response (status = 200 )
179+
180+
176181def create_app ():
177182 """Create the aiohttp app and setup routes."""
178183 site_dir = Path (os .environ .get ('SITE_DIR' , 'sites' )).resolve ()
@@ -182,6 +187,7 @@ def create_app():
182187 app ['site_dir' ] = site_dir
183188 app .add_routes ([
184189 web .post ('/gh/{repo}' , github_webhook ),
190+ web .get ('/ping' , ping ),
185191 ])
186192 return app
187193
You can’t perform that action at this time.
0 commit comments