Skip to content

Commit e336692

Browse files
committed
CI: Always upload package cache even if overall build fails
When we don't trigger CI for more than 1 week, or if the gettext/libsodium packages were updated, CI needs to re-generate the artifacts and cache them. However, if the overall build fails later due to unrelated test failures, previously it would stop the cache from being uploaded at all, making iterating on fixing the test failure quite painful as we need to rebuild the artifact every run until it passes. This change now makes it so we always upload the cache as long as the package was built correctly, so that CI runs after the first failure will be much smoother.
1 parent 6779b85 commit e336692

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

.github/actions/universal-package/action.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,15 @@ runs:
6060
6161
echo '::endgroup::'
6262
63-
- name: Cache keg
64-
id: cache-keg
65-
uses: actions/cache@v4
63+
- name: Restore keg cache
64+
id: cache-keg-restore
65+
uses: actions/cache/restore@v4
6666
with:
6767
path: ${{ steps.setup-formula.outputs.brew_prefix }}/Cellar/${{ inputs.formula }}
6868
key: ${{ inputs.formula }}-homebrew-cache-custom-unified-prefix${{ steps.setup-formula.outputs.brew_prefix }}-xcode${{ steps.setup-formula.outputs.xcode_version }}-${{ hashFiles(format('{0}.rb', inputs.formula)) }}
6969

7070
- name: Install formula
71+
id: install-formula
7172
shell: bash
7273
run: |
7374
echo '::group::Install formula'
@@ -100,3 +101,16 @@ runs:
100101
done
101102
102103
echo '::endgroup::'
104+
105+
- name: Save keg cache
106+
id: cache-keg-save
107+
uses: actions/cache/save@v4
108+
# We always save the generated artifact even if the whole run
109+
# fails due to other issues. This helps debugging build
110+
# failure issues faster if the cache doesn't already exist as
111+
# we want subsequent runs to not have to re-generate this
112+
# artifact again.
113+
if: always() && steps.cache-keg-restore.outputs.cache-hit != 'true' && steps.install-formula.conclusion == 'success'
114+
with:
115+
path: ${{ steps.setup-formula.outputs.brew_prefix }}/Cellar/${{ inputs.formula }}
116+
key: ${{ steps.cache-keg-restore.outputs.cache-primary-key }}

0 commit comments

Comments
 (0)