From f6cf16a220ae0456a8b07dc5ed6b73b55c7221b1 Mon Sep 17 00:00:00 2001 From: notplants <@notplants> Date: Thu, 26 Nov 2026 02:50:48 +0000 Subject: [PATCH] loomio tests: reproduce entrypoint env for the Rails console --- tests/loomio/custom/_loomio.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/loomio/custom/_loomio.py b/tests/loomio/custom/_loomio.py index ce18072..6b067f8 100644 --- a/tests/loomio/custom/_loomio.py +++ b/tests/loomio/custom/_loomio.py @@ -74,10 +74,27 @@ puts "DISCUSSION_KEY=" + discussion.reload.key.to_s ) +# The app's entrypoint exports these from the mounted secrets and derives DATABASE_URL before +# puma starts; a bare `docker exec` does not inherit them (the image ships no config/database.yml), +# so reproduce the entrypoint env here. `$1` carries the Ruby program (passed as an argv element, so +# no quoting of the program itself is needed). +_ENTRYPOINT_ENV = """ +export DEVISE_SECRET="$(cat /run/secrets/devise_secret)" +export SECRET_COOKIE_TOKEN="$(cat /run/secrets/secret_cookie_token)" +export POSTGRES_PASSWORD="$(cat /run/secrets/db_password)" +export DB_HOST=db +export DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db/${POSTGRES_DB}" +exec bundle exec rails runner "$1" +""" + + def _rails(domain: str, code: str) -> str: """Run Ruby through the app's Rails console (the same process the API controllers run in).""" return lifecycle.exec_in_app( - domain, ["bundle", "exec", "rails", "runner", code], service="app", timeout=300 + domain, + ["sh", "-c", _ENTRYPOINT_ENV, "loomio-runner", code], + service="app", + timeout=300, )