Skip to content

Commit 3f7bbef

Browse files
committed
Simplify Rakefile and CI by keeping only local builds
Non-local build doesn't work with Qemu, but only with a build cluster of both node types.
1 parent 62c33da commit 3f7bbef

File tree

3 files changed

+55
-89
lines changed

3 files changed

+55
-89
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,7 @@ jobs:
103103
- name: Change docker to a cache-able driver
104104
run: |
105105
docker buildx create --driver docker-container --use
106-
- name: Build docker image
107-
if: runner.arch == 'X64'
108-
run: |
109-
bundle exec rake build:x86:${{ matrix.platform }} RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,dest=tmp/build-cache-new"
110-
- name: Build docker image
111-
if: runner.arch == 'ARM64'
112-
run: |
113-
bundle exec rake build:arm:${{ matrix.platform }} RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,dest=tmp/build-cache-new"
106+
bundle exec rake build:${{ matrix.platform }} RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,dest=tmp/build-cache-new"
114107
- name: Show docker images
115108
run: docker images
116109
- name: Update and prune docker buildx layer cache

.github/workflows/publish-images.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,7 @@ jobs:
5050
- name: Change docker to a cache-able driver
5151
run: |
5252
docker buildx create --driver docker-container --use
53-
- name: Build docker image
54-
if: runner.arch == 'X64'
55-
run: |
56-
bundle exec rake build:x86:${{ matrix.platform }} RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,dest=tmp/build-cache-new"
57-
- name: Build docker image
58-
if: runner.arch == 'ARM64'
59-
run: |
60-
bundle exec rake build:arm:${{ matrix.platform }} RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,dest=tmp/build-cache-new"
53+
bundle exec rake build:${{ matrix.platform }} RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,dest=tmp/build-cache-new"
6154
- name: Show docker images
6255
run: docker images
6356
- name: Update and prune docker buildx layer cache

Rakefile

Lines changed: 53 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -59,68 +59,48 @@ namespace :build do
5959

6060
mkdir_p "tmp/docker"
6161

62-
host_platforms.each do |docker_platform, rake_platform|
63-
namespace rake_platform do
64-
65-
platforms.each do |platform, target|
66-
sdf = "tmp/docker/Dockerfile.mri.#{platform}.#{rake_platform}"
67-
df = ERB.new(File.read("Dockerfile.mri.erb"), trim_mode: ">").result(binding)
68-
File.write(sdf, df)
69-
CLEAN.include(sdf)
70-
end
71-
sdf = "tmp/docker/Dockerfile.jruby.#{rake_platform}"
72-
df = File.read("Dockerfile.jruby")
73-
File.write(sdf, df)
74-
75-
builder = RakeCompilerDock::ParallelDockerBuild.new(platforms.map{|pl, _| "tmp/docker/Dockerfile.mri.#{pl}.#{rake_platform}" } + ["tmp/docker/Dockerfile.jruby.#{rake_platform}"], workdir: "tmp/docker", task_prefix: "common-#{rake_platform}-", platform: docker_platform)
76-
77-
platforms.each do |platform, target|
78-
sdf = "tmp/docker/Dockerfile.mri.#{platform}.#{rake_platform}"
79-
80-
if docker_platform == local_platform[0]
81-
# Load image after build on local platform only
82-
desc "Build and load image for platform #{platform} on #{docker_platform}"
83-
task platform => sdf do
84-
build_mri_images([platform], [local_platform], output: 'load')
85-
end
86-
else
87-
desc "Build image for platform #{platform} on #{docker_platform}"
88-
task platform => sdf
89-
end
90-
multitask :all => platform
91-
end
62+
docker_platform, rake_platform, _ = local_platform
63+
platforms.each do |platform, target|
64+
sdf = "tmp/docker/Dockerfile.mri.#{platform}.#{rake_platform}"
65+
df = ERB.new(File.read("Dockerfile.mri.erb"), trim_mode: ">").result(binding)
66+
File.write(sdf, df)
67+
CLEAN.include(sdf)
68+
end
69+
sdf = "tmp/docker/Dockerfile.jruby.#{rake_platform}"
70+
df = File.read("Dockerfile.jruby")
71+
File.write(sdf, df)
9272

93-
sdf = "tmp/docker/Dockerfile.jruby.#{rake_platform}"
94-
if docker_platform == local_platform[0]
95-
# Load image after build on local platform only
96-
desc "Build and load image for JRuby on #{docker_platform}"
97-
task :jruby => sdf do
98-
build_jruby_images([local_platform], output: 'load')
99-
end
100-
else
101-
desc "Build image for JRuby on #{docker_platform}"
102-
task :jruby => sdf
103-
end
104-
multitask :all => :jruby
73+
RakeCompilerDock::ParallelDockerBuild.new(platforms.map{|pl, _| "tmp/docker/Dockerfile.mri.#{pl}.#{rake_platform}" } + ["tmp/docker/Dockerfile.jruby.#{rake_platform}"], workdir: "tmp/docker", task_prefix: "common-#{rake_platform}-", platform: docker_platform)
74+
75+
platforms.each do |platform, target|
76+
sdf = "tmp/docker/Dockerfile.mri.#{platform}.#{rake_platform}"
77+
78+
# Load image after build on local platform only
79+
desc "Build and load image for platform #{platform} on #{docker_platform}"
80+
task platform => sdf do
81+
build_mri_images([platform], [local_platform], output: 'load')
10582
end
106-
desc "Build all images on #{docker_platform} in parallel"
107-
task rake_platform => "#{rake_platform}:all"
83+
multitask :all => platform
10884
end
10985

110-
all_mri_images = host_platforms.flat_map do |_, rake_platform|
111-
platforms.map do |platform, |
112-
"#{rake_platform}:#{platform}"
113-
end
86+
sdf = "tmp/docker/Dockerfile.jruby.#{rake_platform}"
87+
# Load image after build on local platform only
88+
desc "Build and load image for JRuby on #{docker_platform}"
89+
task :jruby => sdf do
90+
build_jruby_images([local_platform], output: 'load')
11491
end
115-
desc "Build images for all MRI platforms and hosts in parallel"
92+
multitask :all => :jruby
93+
94+
all_mri_images = platforms.map(&:first)
95+
desc "Build images for all MRI platforms in parallel"
11696
if ENV['RCD_USE_BUILDX_CACHE']
11797
task :mri => all_mri_images
11898
else
11999
multitask :mri => all_mri_images
120100
end
121101

122-
all_images = all_mri_images + host_platforms.map { |_, pl| "#{pl}:jruby" }
123-
desc "Build images for all platforms and hosts in parallel"
102+
all_images = all_mri_images + ["jruby"]
103+
desc "Build images for all platforms in parallel"
124104
if ENV['RCD_USE_BUILDX_CACHE']
125105
task :all => all_images
126106
else
@@ -130,6 +110,28 @@ end
130110

131111
task :build => "build:all"
132112

113+
namespace :release do
114+
host_pl = host_platforms.map(&:first).join(",")
115+
116+
desc "Push image for JRuby on #{host_pl}"
117+
task :jruby do
118+
build_jruby_images(host_platforms, output: 'push')
119+
end
120+
121+
desc "Push all docker images on #{host_pl}"
122+
multitask :images => :jruby
123+
124+
platforms.each do |platform, target|
125+
desc "Push image for platform #{platform} on #{host_pl}"
126+
task platform do
127+
build_mri_images([platform], host_platforms, output: 'push')
128+
end
129+
130+
desc "Push all docker images on #{host_pl}"
131+
multitask :images => platform
132+
end
133+
end
134+
133135
namespace :prepare do
134136
desc "Build cross compiler for x64-mingw-ucrt aka RubyInstaller-3.1+"
135137
task "mingw64-ucrt" do
@@ -172,25 +174,3 @@ task :update_lists do
172174
EOT
173175
end
174176
end
175-
176-
namespace :release do
177-
host_pl = host_platforms.map(&:first).join(",")
178-
179-
desc "Push image for JRuby on #{host_pl}"
180-
task :jruby => ["build:x86:jruby", "build:arm:jruby"] do
181-
build_jruby_images(host_platforms, output: 'push')
182-
end
183-
184-
desc "Push all docker images on #{host_pl}"
185-
multitask :images => :jruby
186-
187-
platforms.each do |platform, target|
188-
desc "Push image for platform #{platform} on #{host_pl}"
189-
task platform => ["build:x86:#{platform}", "build:arm:#{platform}"] do
190-
build_mri_images([platform], host_platforms, output: 'push')
191-
end
192-
193-
desc "Push all docker images on #{host_pl}"
194-
multitask :images => platform
195-
end
196-
end

0 commit comments

Comments
 (0)