Skip to content

Commit

Permalink
soft skip extensions in tests so the step still shows up in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegn committed Oct 30, 2024
1 parent c270001 commit 8ea62fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
12 changes: 6 additions & 6 deletions deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,9 @@
end
end

if !DEPLOY_ONLY && get_env("SKIP_EXTENSIONS").nil?
if !DEPLOY_ONLY
if FLY_PG
in_step Step::FLY_POSTGRES_CREATE do
in_step Step::FLY_POSTGRES_CREATE, skip: !get_env("SKIP_EXTENSIONS").nil? do
pg_name = FLY_PG["app_name"]
region = APP_REGION

Expand Down Expand Up @@ -350,7 +350,7 @@
exec_capture("flyctl pg attach #{pg_name} --app #{APP_NAME} -y")
end
elsif SUPABASE
in_step Step::SUPABASE_POSTGRES do
in_step Step::SUPABASE_POSTGRES, skip: !get_env("SKIP_EXTENSIONS").nil? do
cmd = "flyctl ext supabase create --org #{ORG_SLUG} --name #{SUPABASE["db_name"]} --region #{SUPABASE["region"]} --app #{APP_NAME} --yes"

artifact Artifact::SUPABASE_POSTGRES, { config: SUPABASE }
Expand All @@ -360,7 +360,7 @@
end

if UPSTASH
in_step Step::UPSTASH_REDIS do
in_step Step::UPSTASH_REDIS, skip: !get_env("SKIP_EXTENSIONS").nil? do
db_name = "#{APP_NAME}-redis"

cmd = "flyctl redis create --name #{db_name} --org #{ORG_SLUG} --region #{APP_REGION}"
Expand All @@ -384,7 +384,7 @@
end

if TIGRIS
in_step Step::TIGRIS_OBJECT_STORAGE do
in_step Step::TIGRIS_OBJECT_STORAGE, skip: !get_env("SKIP_EXTENSIONS").nil? do
cmd = "flyctl ext tigris create --org #{ORG_SLUG} --app #{APP_NAME} --yes"

if (name = TIGRIS["name"]) && !name.empty?
Expand All @@ -410,7 +410,7 @@
end

if SENTRY
in_step Step::SENTRY do
in_step Step::SENTRY, skip: !get_env("SKIP_EXTENSIONS").nil? do
exec_capture("flyctl ext sentry create --app #{APP_NAME} --yes")
end
end
Expand Down
8 changes: 6 additions & 2 deletions deploy/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,16 @@ def exec_capture(cmd, display: nil, log: true)
output
end

def in_step(step, &block)
def in_step(step, skip: false, &block)
old_step = Step.current()
Step.set_current(step)
event :start
ret = begin
yield block
if skip
event :skip
else
yield block
end
rescue StandardError => e
event :error, { type: :uncaught, message: e }
exit 1
Expand Down

0 comments on commit 8ea62fb

Please sign in to comment.