Allow for prerequisites to be declared and run #149
Allow for prerequisites to be declared and run #149saturnflyer wants to merge 3 commits intomainfrom
Conversation
cseeman
left a comment
There was a problem hiding this comment.
Looking good Jim. Just a heads up that discharger hasn't been changed over to git fragments yet, and is still on changelog. Also with these new pre-steps, they probably should be documented in the README somewhere. Maybe around the Using Default Steps section?
Setup tasks like setting environment variables and installing system dependencies need to run before Rails loads. This allows bin/setup to remain minimal while configuring pre-Rails steps in setup.yml. Version: minor Added: Unified setup entry point with pre-steps support
These generated files should not be tracked.
Add respond_to? guards for config accessors in DockerCommand for consistency with PgToolsCommand. Document pre_steps in README. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Hey Jim, looks great, the respond_to? guards and README section are exactly what I was hoping for. Nice placement before "Using Default Steps" too.
One thing I noticed while re-reading: the evaluate_condition method in prerequisites_loader.rb handles File.exist?('...') but doesn't have a case for the negated form !File.exist?('...'). The README example uses condition: "!File.exist?('.env')" which would fall through to the else branch and always return false, silently skipping the step.
Might just need another when clause like the ENV patterns already have. Something like:
when /^!File\.exist\?\(['"](.+)['"]\)$/
!File.exist?($1)Not a blocker, just wanted to flag it before it trips someone up!
Adds a unified setup entry point (Discharger::Setup) that orchestrates the full application setup lifecycle, including tasks that must run before Rails loads.
Problem
Some setup tasks need to run before Rails initializes—setting environment variables that database.yml reads, installing Homebrew, or ensuring PostgreSQL client tools are available. Previously, developers were adding this logic directly to
bin/setup, which defeats the purpose of configuring setup throughsetup.yml.Solution
The setup lifecycle is now split into phases:
New configuration in
setup.yml:Simplified bin/setup:
Key files
lib/discharger/setup.rb— Main orchestratorlib/discharger/setup_runner/prerequisites_loader.rb— Handles pre-Rails setuplib/discharger/setup_runner/pre_commands/— Built-in pre-commands (Homebrew, PostgreSQL tools)lib/discharger/setup_runner/configuration.rb— Added pre_steps attribute