loomio tests: reproduce entrypoint env for the Rails console
continuous-integration/drone/push Build is failing

This commit is contained in:
notplants
2026-11-26 02:50:48 +00:00
parent d35e3265e3
commit f6cf16a220
+18 -1
View File
@@ -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,
)