Skip to content

Commit 0bbc012

Browse files
committed
Add accessors for parallel build dependencies
to be used for gha job generation.
1 parent 9316620 commit 0bbc012

File tree

7 files changed

+1823
-418
lines changed

7 files changed

+1823
-418
lines changed

.github/workflows/publish-images.yml

Lines changed: 817 additions & 145 deletions
Large diffs are not rendered by default.

.github/workflows/publish-images.yml.erb

Lines changed: 22 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -22,40 +22,17 @@ concurrency:
2222
group: "${{github.workflow}}-${{github.ref}}"
2323
cancel-in-progress: true
2424

25-
26-
<%
27-
platforms = %w[
28-
aarch64-linux-gnu
29-
aarch64-linux-musl
30-
aarch64-mingw-ucrt
31-
arm-linux-gnu
32-
arm-linux-musl
33-
arm64-darwin
34-
jruby
35-
x64-mingw-ucrt
36-
x64-mingw32
37-
x86-linux-gnu
38-
x86-linux-musl
39-
x86-mingw32
40-
x86_64-darwin
41-
x86_64-linux-gnu
42-
x86_64-linux-musl
43-
]
44-
%>
45-
4625
jobs:
47-
build:
48-
name: "build ${{ matrix.platform }} ${{ matrix.os }}"
26+
<% (parallel_docker_build.tree_deps.values + parallel_docker_build.tree_deps.keys).uniq.each do |job| %>
27+
<%= job %>:
28+
name: "build ${{ matrix.os }} <%= job %>"
29+
<%= need = parallel_docker_build.tree_deps[job]; "needs: #{need}" if need %>
4930
strategy:
5031
fail-fast: false
5132
matrix:
5233
os:
5334
- ubuntu-latest
5435
- ubuntu-24.04-arm
55-
platform:
56-
<% platforms.each do |pl| %>
57-
<%= "- #{pl}" %>
58-
<% end %>
5936
runs-on: ${{ matrix.os }}
6037
steps:
6138
- uses: actions/checkout@v4
@@ -72,24 +49,27 @@ jobs:
7249
uses: actions/cache@v4
7350
with:
7451
path: tmp/build-cache-${{ runner.arch }}
75-
key: ${{ runner.os }}-on-${{ runner.arch }}-${{ matrix.platform }}-buildxz-${{ github.sha }}
76-
restore-keys: ${{ runner.os }}-on-${{ runner.arch }}-${{ matrix.platform }}-buildxz
52+
key: ${{ runner.os }}-on-${{ runner.arch }}-<%= job %>-${{ github.sha }}
53+
restore-keys: |
54+
${{ runner.os }}-on-${{ runner.arch }}-<%= job %>
55+
${{ runner.os }}-on-${{ runner.arch }}-<%= need %>
7756
enableCrossOsArchive: true
78-
- name: Build the image for platform ${{ matrix.platform }} on ${{ runner.arch }}
57+
- name: Build the image for platform <%= job %> on ${{ runner.arch }}
7958
run: |
8059
# Change docker to a cache-able driver
8160
docker buildx create --driver docker-container --use
82-
bundle exec rake build:${{ matrix.platform }} RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,compression=zstd,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,compression=zstd,dest=tmp/build-cache-new"
61+
bundle exec rake build:<%= job %> RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,compression=zstd,src=tmp/build-cache-${{ runner.arch }} --cache-to=type=local,compression=zstd,dest=tmp/build-cache-new"
8362
- name: Show docker images
8463
run: docker images
8564
- name: Update and prune docker buildx layer cache
8665
run: |
8766
rm -rf tmp/build-cache-${{ runner.arch }}
8867
mv tmp/build-cache-new tmp/build-cache-${{ runner.arch }}
68+
<% end %>
8969

9070
push:
9171
name: push
92-
needs: build
72+
needs: [<%= parallel_docker_build.final_deps.values.join(",") %>]
9373
strategy:
9474
fail-fast: false
9575
runs-on: ubuntu-24.04-arm
@@ -105,24 +85,24 @@ jobs:
10585
sudo apt clean
10686
df -h
10787

108-
<% platforms.each do |pl| %>
109-
- name: Use X64 cache from primary pipeline of <%= pl %>
88+
<% parallel_docker_build.final_deps.each do |dockerfile, tree_dep| %>
89+
- name: Use X64 cache from tree pipeline of <%= dockerfile %>
11090
uses: actions/cache/restore@v4
11191
with:
11292
path: tmp/build-cache-X64
113-
key: ${{ runner.os }}-on-X64-<%= pl %>-buildxz-${{ github.sha }}
114-
restore-keys: ${{ runner.os }}-on-X64-<%= pl %>-buildxz
93+
key: ${{ runner.os }}-on-X64-<%= tree_dep %>-${{ github.sha }}
94+
restore-keys: ${{ runner.os }}-on-X64-<%= tree_dep %>
11595
enableCrossOsArchive: true
116-
- run: mv tmp/build-cache-X64 tmp/build-cache-X64-<%= pl %>
117-
- name: Use ARM64 cache from primary pipeline of <%= pl %>
96+
- run: mv tmp/build-cache-X64 tmp/build-cache-X64-<%= tree_dep %>
97+
- name: Use ARM64 cache from tree pipeline of <%= dockerfile %>
11898
uses: actions/cache/restore@v4
11999
with:
120100
path: tmp/build-cache-ARM64
121-
key: ${{ runner.os }}-on-ARM64-<%= pl %>-buildxz-${{ github.sha }}
122-
restore-keys: ${{ runner.os }}-on-ARM64-<%= pl %>-buildxz
101+
key: ${{ runner.os }}-on-ARM64-<%= tree_dep %>-${{ github.sha }}
102+
restore-keys: ${{ runner.os }}-on-ARM64-<%= tree_dep %>
123103
enableCrossOsArchive: true
124104
fail-on-cache-miss: true
125-
- run: mv tmp/build-cache-ARM64 tmp/build-cache-ARM64-<%= pl %>
105+
- run: mv tmp/build-cache-ARM64 tmp/build-cache-ARM64-<%= tree_dep %>
126106
<% end %>
127107
- uses: ruby/setup-ruby@v1
128108
with:
@@ -136,7 +116,7 @@ jobs:
136116
- name: Use cache and push docker image
137117
env:
138118
RCD_IMAGE_VERSION: snapshot
139-
RCD_DOCKER_BUILD: docker buildx build <%= platforms.map{|pl| "--cache-from=type=local,compression=zstd,src=tmp/build-cache-X64-#{pl} --cache-from=type=local,compression=zstd,src=tmp/build-cache-ARM64-#{pl} " }.join %> --cache-to=type=local,compression=zstd,dest=tmp/build-cache-new
119+
RCD_DOCKER_BUILD: docker buildx build <%= parallel_docker_build.final_deps.values.map{|tree_dep| "--cache-from=type=local,compression=zstd,src=tmp/build-cache-X64-#{tree_dep} --cache-from=type=local,compression=zstd,src=tmp/build-cache-ARM64-#{tree_dep} " }.join %> --cache-to=type=local,compression=zstd,dest=tmp/build-cache-new
140120
run: |
141121
docker buildx create --driver docker-container --use
142122
bundle exec rake release:images

0 commit comments

Comments
 (0)