-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow skipping of update phases when they were already executed #931
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,11 @@ def run | |
PHASES.each do |phase| | ||
return run_rollback if quit? | ||
|
||
run_phase(phase) | ||
if skip?(phase) | ||
skip_phase(phase) | ||
else | ||
run_phase(phase) | ||
end | ||
end | ||
|
||
finish_update unless quit? | ||
|
@@ -90,12 +94,22 @@ def run_phase(phase) | |
@ask_to_confirm_update = phase == :pre_update_checks | ||
end | ||
|
||
def skip_phase(skipped_phase) | ||
with_non_empty_scenario(skipped_phase) do |scenario| | ||
@reporter.before_scenario_starts(scenario) | ||
@reporter.puts <<~MESSAGE | ||
Skipping #{skipped_phase} phase as it was already run before. | ||
MESSAGE | ||
@reporter.after_scenario_finishes(scenario) | ||
end | ||
end | ||
|
||
private | ||
|
||
def rollback_pre_migrations | ||
raise "Unexpected phase #{phase}, expecting pre_migrations" unless phase == :pre_migrations | ||
|
||
rollback_needed = scenario(:pre_migrations).steps.any? { |s| s.executed? && s.success? } | ||
rollback_needed = find_scenario(:pre_migrations).steps.any? { |s| s.executed? && s.success? } | ||
Comment on lines
-98
to
+112
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am amazed this was not noticed |
||
if rollback_needed | ||
@quit = false | ||
# prevent the unnecessary confirmation questions | ||
|
@@ -110,7 +124,7 @@ def rollback_pre_migrations | |
end | ||
|
||
def with_non_empty_scenario(phase) | ||
next_scenario = scenario(phase) | ||
next_scenario = find_scenario(phase) | ||
Comment on lines
126
to
+127
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this was unused, so nobody noticed |
||
unless next_scenario.nil? || next_scenario.steps.empty? | ||
yield next_scenario | ||
end | ||
|
@@ -153,6 +167,11 @@ def confirm_scenario(scenario) | |
@ask_to_confirm_update = false | ||
end | ||
|
||
def skip?(next_phase) | ||
# the next_phase was run before the current phase | ||
PHASES.index(next_phase) < PHASES.index(phase) | ||
end | ||
|
||
def phase=(phase) | ||
raise "Unknown phase #{phase}" unless PHASES.include?(phase) | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to 3a2fa00 there is currently no way to re-run a skipped phase tho :(