Skip to content

Commit

Permalink
Merge pull request #34 from zzak/rack-3-gemfile
Browse files Browse the repository at this point in the history
Use env for Rack 3 jobs for Gemfile
  • Loading branch information
rafaelfranca authored Jan 25, 2023
2 parents 49d8163 + 8b0e26b commit 11b476f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
30 changes: 27 additions & 3 deletions pipeline-generate
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def short_ruby(ruby)
end
end

def step_for(subdirectory, rake_task, ruby: nil, service: "default")
def step_for(subdirectory, rake_task, ruby: nil, service: "default", pre_steps: [])
return unless REPO_ROOT.join(subdirectory).exist?

label = +"#{subdirectory} #{rake_task.sub(/[:_]test|test:/, "")}"
Expand All @@ -152,6 +152,9 @@ def step_for(subdirectory, rake_task, ruby: nil, service: "default")
env["RUBY_YJIT_ENABLE"] = "1"
end

if !pre_steps.empty?
env["PRE_STEPS"] = pre_steps.join(" && ")
end
command = "rake #{rake_task}"

timeout = 30
Expand Down Expand Up @@ -186,6 +189,10 @@ def step_for(subdirectory, rake_task, ruby: nil, service: "default")
},
{
DOCKER_COMPOSE_PLUGIN => {
"env" => [
"PRE_STEPS",
"RACK"
],
"run" => service,
"pull" => service,
"config" => ".buildkite/docker-compose.yml",
Expand All @@ -206,13 +213,13 @@ def step_for(subdirectory, rake_task, ruby: nil, service: "default")
STEPS << hash
end

def steps_for(subdirectory, rake_task, service: "default", &block)
def steps_for(subdirectory, rake_task, service: "default", pre_steps: [], &block)
RUBIES.each do |ruby|
if rake_task == "mysql:test"
next unless ruby =~ /^ruby:(.*)/ && Gem::Version.new($1) < Gem::Version.new("2.4.x")
end

step_for(subdirectory, rake_task, ruby: ruby, service: service, &block)
step_for(subdirectory, rake_task, ruby: ruby, service: service, pre_steps: pre_steps, &block)
end
end

Expand Down Expand Up @@ -301,6 +308,19 @@ steps_for("railties", "test", service: "railties") do |x|
x["parallelism"] = 12 if REPO_ROOT.join("railties/Rakefile").read.include?("BUILDKITE_PARALLEL")
end

step_for("actionpack", "test", service: "default", pre_steps: ["bundle install"]) do |x|
x["label"] += " [rack-3]"
x["env"]["RACK"] = "~> 3.0"
x["soft_fail"] = true
end

step_for("railties", "test", service: "railties", pre_steps: ["bundle install"]) do |x|
x["parallelism"] = 12 if REPO_ROOT.join("railties/Rakefile").read.include?("BUILDKITE_PARALLEL")
x["label"] += " [rack-3]"
x["env"]["RACK"] = "~> 3.0"
x["soft_fail"] = true
end

# Ugly hacks to just get the build passing for now
STEPS.find { |s| s["label"] == "activestorage (2.2)" }&.tap do |s|
s["soft_fail"] = true
Expand Down Expand Up @@ -343,6 +363,10 @@ puts YAML.dump("steps" => [
DOCKER_COMPOSE_PLUGIN => {
"build" => "base",
"config" => ".buildkite/docker-compose.yml",
"env" => [
"PRE_STEPS",
"RACK"
],
"image-name" => image_name_for(ruby, short: true),
"cache-from" => [
REBUILD_ID && "base:" + image_name_for(ruby, REBUILD_ID),
Expand Down
9 changes: 8 additions & 1 deletion runner
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ set -e
dir="$1"
cmd="$2"

if [ -n "$PRE_STEPS" ]; then
echo
echo "--- pre steps"
eval "$PRE_STEPS"
echo "+++ "
fi

echo
echo "--- bundle env"
bundle env
Expand All @@ -16,5 +23,5 @@ fi

echo "+++ $dir: $cmd"

cd $dir
cd "$dir"
exec bundle exec /bin/sh -e -c "$cmd"

0 comments on commit 11b476f

Please sign in to comment.