Skip to content
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

WIP - Trigger custom rake tasks at end of deploy process #330

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions hatchet.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"sharpstone/bad_ruby_version"
],
"rack": [
"sharpstone/finish_deploy",
"sharpstone/default_ruby",
"sharpstone/mri_187_nokogiri",
"sharpstone/mri_192",
Expand Down Expand Up @@ -55,6 +56,9 @@
"rails41": [
"sharpstone/rails41_scaffold"
],
"rails42": [
"sharpstone/rails42_finish_deploy"
],
"multibuildpack": [
"sharpstone/node_multi"
]
Expand Down
11 changes: 11 additions & 0 deletions lib/language_pack/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,23 @@ def compile
install_binaries
run_assets_precompile_rake_task
end
finish_deploy
super
end
end

private

def finish_deploy
task = rake.task("finish:deploy")
if task.is_defined?
task.invoke(env: rake_env)
raise BuildpackError, "Expected `rake finish:deploy` to return non-zero exit code" unless task.success?
else
topic("Skipping finish:deploy rake task, not found")
end
end

# the base PATH environment variable to be used
# @return [String] the resulting PATH
def default_path
Expand Down
6 changes: 6 additions & 0 deletions spec/rack_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@
expect(app.run("env")).to match(custom_env)
end
end

it "should trigger custom rake tasks" do
Hatchet::Runner.new("finish_deploy").deploy do |app|
expect(app.output).to include("Hello from a custom rake task")
end
end
end
9 changes: 9 additions & 0 deletions spec/rails_42_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require_relative 'spec_helper'

describe "Rails 4.2.x" do
it "call the `finish:deploy` rake task if defined" do
Hatchet::Runner.new("rails42_finish_deploy").deploy do |app, heroku|
expect(app.output).to include("Hello from a custom rake task")
end
end
end