Skip to content

Commit 0a5c87c

Browse files
committed
Revert gha cache type to local path type
The gha type is faster, but for some reason the gha cache type is not reliable. It repeatedly has cache misses when there should be a cache hit. The local storage cache in combination with achtions/cache doesn't show this behaviour.
1 parent 7a122bf commit 0a5c87c

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

.github/workflows/ci.yml.erb

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,26 @@ jobs:
4040
ruby-version: "3.4"
4141
bundler-cache: true
4242

43-
- name: Expose GitHub Runtime for docker cache
44-
uses: crazy-max/ghaction-github-runtime@v3
43+
- name: Fetch docker buildx layer cache
44+
uses: actions/cache@v4
45+
with:
46+
path: tmp/build-cache-${{ runner.arch }}
47+
key: ${{ runner.os }}-on-${{ runner.arch }}-<%= job %>-${{ github.sha }}
48+
restore-keys: |
49+
${{ runner.os }}-on-${{ runner.arch }}-<%= job %>
50+
${{ runner.os }}-on-${{ runner.arch }}-<%= need %>
51+
enableCrossOsArchive: true
4552
- name: Build the image layers <%= job %> on ${{ runner.arch }}
4653
env:
4754
RCD_TASK_DEPENDENCIES: "false"
4855
run: |
4956
# Change docker to a cache-able driver
5057
docker buildx create --driver docker-container --use
51-
bundle exec rake build:<%= tree_dep %> RCD_DOCKER_BUILD="docker buildx build --cache-from type=gha,scope=${{ runner.os }}-on-${{ runner.arch }}-<%= need %> --cache-from type=gha,scope=${{ runner.os }}-on-${{ runner.arch }}-<%= job %> --cache-to=type=gha,mode=max,scope=${{ runner.os }}-on-${{ runner.arch }}-<%= job %>"
58+
bundle exec rake build:<%= tree_dep %> 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"
59+
- name: Update and prune docker buildx layer cache
60+
run: |
61+
rm -rf tmp/build-cache-${{ runner.arch }}
62+
mv tmp/build-cache-new tmp/build-cache-${{ runner.arch }}
5263
<% end %>
5364

5465
build_source_gem:
@@ -128,14 +139,21 @@ jobs:
128139
ruby-version: "3.3"
129140
bundler-cache: true
130141

131-
- name: Expose GitHub Runtime for docker cache
132-
uses: crazy-max/ghaction-github-runtime@v3
142+
- name: Fetch docker buildx layer cache
143+
uses: actions/cache@v4
144+
with:
145+
path: tmp/build-cache-${{ runner.arch }}
146+
key: ${{ runner.os }}-on-${{ runner.arch }}-${{ matrix.platform }}-${{ github.sha }}
147+
restore-keys: ${{ runner.os }}-on-${{ runner.arch }}-${{ matrix.platform }}
148+
enableCrossOsArchive: true
149+
133150
- name: Build the image from already filled cache
134151
env:
135152
RCD_TASK_DEPENDENCIES: "false"
136153
run: |
137154
docker buildx create --driver docker-container --use
138-
bundle exec rake build:${{ matrix.platform }} RCD_DOCKER_BUILD="docker buildx build --cache-from type=gha,scope=${{ runner.os }}-on-${{ runner.arch }}-${{ matrix.platform }}"
155+
bundle exec rake build:${{ matrix.platform }} RCD_DOCKER_BUILD="docker buildx build --cache-from=type=local,compression=zstd,src=tmp/build-cache-${{ runner.arch }}"
156+
139157
- name: Show docker images
140158
run: docker images
141159

0 commit comments

Comments
 (0)