Skip to content

Commit 1168a5e

Browse files
authored
[infra] Split workflow cache restore and save (#16321)
This commit splits the generic caching step into separate 'restore' and 'save' steps for more precise cache management. This change improves cache key specificity and reduce unnecessary cache save for PR. ONE-DCO-1.0-Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
1 parent d3db9b9 commit 1168a5e

File tree

6 files changed

+163
-31
lines changed

6 files changed

+163
-31
lines changed

.github/workflows/build-pub-dev-docker.yml

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,19 @@ jobs:
7272
- name: Checkout
7373
uses: actions/checkout@v4
7474

75-
- name: Caching externals
76-
uses: actions/cache@v4
75+
- name: Restore onecc external cache
76+
uses: actions/cache/restore@v4
7777
with:
7878
path: externals
79-
key: external-onert-${{ matrix.ubuntu_code }}-${{ hashFiles('infra/nnfw/cmake/packages/**/*.cmake') }}
79+
key: external-onecc-${{ hashFiles('infra/cmake/packages/**/*.cmake') }}
80+
restore-keys: |
81+
external-onecc-
82+
83+
- name: Restore externals cache
84+
uses: actions/cache/restore@v4
85+
with:
86+
path: runtime/externals
87+
key: external-onert-${{ matrix.ubuntu_code }}-${{ hashFiles('runtime/infra/cmake/packages/**/*.cmake') }}
8088
restore-keys: |
8189
external-onert-${{ matrix.ubuntu_code }}-
8290
@@ -115,11 +123,19 @@ jobs:
115123
- name: Checkout
116124
uses: actions/checkout@v4
117125

118-
- name: Caching externals
119-
uses: actions/cache@v4
126+
- name: Restore onecc external cache
127+
uses: actions/cache/restore@v4
120128
with:
121129
path: externals
122-
key: external-onert-${{ matrix.ubuntu_code }}-${{ hashFiles('infra/nnfw/cmake/packages/**/*.cmake') }}
130+
key: external-onecc-${{ hashFiles('infra/cmake/packages/**/*.cmake') }}
131+
restore-keys: |
132+
external-onecc-
133+
134+
- name: Restore externals cache
135+
uses: actions/cache/restore@v4
136+
with:
137+
path: runtime/externals
138+
key: external-onert-${{ matrix.ubuntu_code }}-${{ hashFiles('runtime/infra/cmake/packages/**/*.cmake') }}
123139
restore-keys: |
124140
external-onert-${{ matrix.ubuntu_code }}-
125141
@@ -145,11 +161,19 @@ jobs:
145161
- name: Checkout
146162
uses: actions/checkout@v4
147163

148-
- name: Caching externals
149-
uses: actions/cache@v4
164+
- name: Restore onecc external cache
165+
uses: actions/cache/restore@v4
150166
with:
151167
path: externals
152-
key: external-onert-ndk-${{ hashFiles('infra/nnfw/cmake/packages/**/*.cmake') }}
168+
key: external-onecc-${{ hashFiles('infra/cmake/packages/**/*.cmake') }}
169+
restore-keys: |
170+
external-onecc-
171+
172+
- name: Restore externals cache
173+
uses: actions/cache/restore@v4
174+
with:
175+
path: runtime/externals
176+
key: external-onert-ndk-${{ hashFiles('runtime/infra/cmake/packages/**/*.cmake') }}
153177
restore-keys: |
154178
external-onert-ndk-
155179
@@ -178,10 +202,18 @@ jobs:
178202
- name: Checkout
179203
uses: actions/checkout@v4
180204

181-
- name: Caching externals
182-
uses: actions/cache@v4
205+
- name: Restore onecc external cache
206+
uses: actions/cache/restore@v4
183207
with:
184208
path: externals
209+
key: external-onecc-${{ hashFiles('infra/cmake/packages/**/*.cmake') }}
210+
restore-keys: |
211+
external-onecc-
212+
213+
- name: Restore externals cache
214+
uses: actions/cache/restore@v4
215+
with:
216+
path: runtime/externals
185217
key: external-onert-${{ matrix.ubuntu_code }}-${{ hashFiles('infra/nnfw/cmake/packages/**/*.cmake') }}
186218
restore-keys: |
187219
external-onert-${{ matrix.ubuntu_code }}-

.github/workflows/pub-onert-pypi.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ jobs:
4444
- name: Checkout
4545
uses: actions/checkout@v4
4646

47-
- name: Caching externals
48-
uses: actions/cache@v4
47+
- name: Restore externals cache
48+
uses: actions/cache/restore@v4
4949
with:
5050
path: runtime/externals
5151
key: external-onert-jammy-${{ hashFiles('runtime/infra/cmake/packages/**/*.cmake') }}

.github/workflows/run-onecc-build.yml

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,26 @@ jobs:
7575
apt-get -qqy install python3.10 python3.10-dev python3.10-venv
7676
python3.10 -m ensurepip --upgrade
7777
78-
- name: Caching externals
79-
uses: actions/cache@v4
78+
- name: Restore externals cache
79+
uses: actions/cache/restore@v4
80+
id: externals-cache
8081
with:
8182
path: externals
8283
key: external-onecc-${{ hashFiles('infra/cmake/packages/**/*.cmake') }}
8384
restore-keys: |
8485
external-onecc-
8586
external-
8687
87-
- name: Caching overlay
88-
uses: actions/cache@v4
88+
- name: Restore overlay cache
89+
uses: actions/cache/restore@v4
90+
id: overlay-cache
8991
with:
9092
path: ${{ env.NNCC_WORKSPACE }}/overlay
9193
key: overlay-onecc-${{ matrix.ubuntu_code }}-${{ hashFiles('compiler/common-artifacts/CMakeLists.txt') }}-${{ hashFiles('infra/cmake/packages/**/*.cmake') }}
9294

93-
- name: Caching ccache
94-
uses: actions/cache@v4
95+
- name: Restore ccache cache
96+
uses: actions/cache/restore@v4
97+
id: ccache-cache
9598
with:
9699
path: ~/.cache/ccache
97100
key: ccache-onecc-${{ matrix.ubuntu_code }}-${{ matrix.type }}-${{ github.sha }}
@@ -105,6 +108,31 @@ jobs:
105108
./nncc build "-j$(nproc)"
106109
cmake --build "${NNCC_WORKSPACE}" -- install
107110
111+
# Save cache on push to reduce the size of cache storage
112+
# ccache cache: only for master branch
113+
# overlay cache: only for master branch and Release build
114+
# externals cache: only for master branch and Release build and jammy
115+
- name: Save ccache cache
116+
if: github.event_name == 'push' && github.ref_name == 'master'
117+
uses: actions/cache/save@v4
118+
with:
119+
path: ~/.cache/ccache
120+
key: ${{ steps.ccache-cache.outputs.cache-primary-key }}
121+
122+
- name: Save overlay cache
123+
if: github.event_name == 'push' && github.ref_name == 'master' && matrix.type == 'Release'
124+
uses: actions/cache/save@v4
125+
with:
126+
path: ${{ env.NNCC_WORKSPACE }}/overlay
127+
key: ${{ steps.overlay-cache.outputs.cache-primary-key }}
128+
129+
- name: Save externals cache
130+
if: github.event_name == 'push' && github.ref_name == 'master' && matrix.type == 'Release' && matrix.ubuntu_code == 'jammy'
131+
uses: actions/cache/save@v4
132+
with:
133+
path: externals
134+
key: ${{ steps.externals-cache.outputs.cache-primary-key }}
135+
108136
- name: Test(Debug)
109137
if: matrix.type == 'Debug'
110138
env:

.github/workflows/run-onert-android-build.yml

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,26 @@ jobs:
5555
- name: Checkout
5656
uses: actions/checkout@v4
5757

58-
- name: Caching externals
59-
uses: actions/cache@v4
58+
- name: Restore onecc external cache
59+
uses: actions/cache/restore@v4
60+
with:
61+
path: externals
62+
key: external-onecc-${{ hashFiles('infra/cmake/packages/**/*.cmake') }}
63+
restore-keys: |
64+
external-onecc-
65+
66+
- name: Restore externals cache
67+
uses: actions/cache/restore@v4
68+
id: cache-externals
6069
with:
6170
path: runtime/externals
6271
key: external-onert-ndk-${{ hashFiles('runtime/infra/cmake/packages/**/*.cmake') }}
6372
restore-keys: |
6473
external-onert-ndk-
6574
66-
- name: Caching ccache
67-
uses: actions/cache@v4
75+
- name: Restore ccache cache
76+
uses: actions/cache/restore@v4
77+
id: cache-ccache
6878
with:
6979
path: ~/.cache/ccache
7080
key: ccache-onert-android-${{ github.sha }}
@@ -87,3 +97,20 @@ jobs:
8797
- name: Build onert
8898
run: |
8999
make -f Makefile.template
100+
101+
# Save cache on push to reduce the size of cache storage
102+
# ccache cache: only for master branch
103+
# externals cache: only for master branch
104+
- name: Save ccache cache
105+
uses: actions/cache/save@v4
106+
if: github.event_name == 'push' && github.ref_name == 'master'
107+
with:
108+
path: ~/.cache/ccache
109+
key: ${{ steps.cache-ccache.outputs.cache-primary-key }}
110+
111+
- name: Save externals cache
112+
uses: actions/cache/save@v4
113+
if: github.event_name == 'push' && github.ref_name == 'master'
114+
with:
115+
path: runtime/externals
116+
key: ${{ steps.cache-externals.outputs.cache-primary-key }}

.github/workflows/run-onert-cross-build.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,25 @@ jobs:
6464
- name: Checkout
6565
uses: actions/checkout@v4
6666

67-
- name: Caching externals
68-
uses: actions/cache@v4
67+
- name: Restore onecc external cache
68+
uses: actions/cache/restore@v4
69+
with:
70+
path: externals
71+
key: external-onecc-${{ hashFiles('infra/cmake/packages/**/*.cmake') }}
72+
restore-keys: |
73+
external-onecc-
74+
75+
- name: Restore externals cache
76+
uses: actions/cache/restore@v4
6977
with:
7078
path: runtime/externals
7179
key: external-onert-${{ matrix.ubuntu_code }}-${{ hashFiles('runtime/infra/cmake/packages/**/*.cmake') }}
7280
restore-keys: |
7381
external-onert-${{ matrix.ubuntu_code }}-
7482
75-
- name: Caching ccache
76-
uses: actions/cache@v4
83+
- name: Restore ccache cache
84+
uses: actions/cache/restore@v4
85+
id: ccache-cache
7786
with:
7887
path: ~/.cache/ccache
7988
key: ccache-onert-${{ matrix.ubuntu_code }}-${{ matrix.arch }}-${{ matrix.type }}-${{ github.sha }}
@@ -96,6 +105,15 @@ jobs:
96105
run: |
97106
make -f Makefile.template create-testsuite
98107
108+
# Save cache on push to reduce the size of cache storage
109+
# ccache cache: only for master branch
110+
- name: Save ccache cache
111+
uses: actions/cache/save@v4
112+
if: github.event_name == 'push' && github.ref_name =='master'
113+
with:
114+
path: ~/.cache/ccache
115+
key: ${{ steps.ccache-cache.outputs.cache-primary-key }}
116+
99117
- name: Upload artifacts
100118
uses: actions/upload-artifact@v4
101119
if: matrix.type == 'release'

.github/workflows/run-onert-native-build.yml

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,26 @@ jobs:
6666
- name: Checkout
6767
uses: actions/checkout@v4
6868

69-
- name: Caching externals
70-
uses: actions/cache@v4
69+
- name: Restore onecc external cache
70+
uses: actions/cache/restore@v4
71+
with:
72+
path: externals
73+
key: external-onecc-${{ hashFiles('infra/cmake/packages/**/*.cmake') }}
74+
restore-keys: |
75+
external-onecc-
76+
77+
- name: Restore externals cache
78+
uses: actions/cache/restore@v4
79+
id: external-cache
7180
with:
7281
path: runtime/externals
7382
key: external-onert-${{ matrix.ubuntu_code }}-${{ hashFiles('runtime/infra/cmake/packages/**/*.cmake') }}
7483
restore-keys: |
7584
external-onert-${{ matrix.ubuntu_code }}-
7685
77-
- name: Caching ccache
78-
uses: actions/cache@v4
86+
- name: Restore ccache cache
87+
uses: actions/cache/restore@v4
88+
id: ccache-cache
7989
with:
8090
path: ~/.cache/ccache
8191
key: ccache-onert-${{ matrix.ubuntu_code }}-${{ matrix.arch }}-${{ matrix.type }}-${{ github.sha }}
@@ -89,3 +99,20 @@ jobs:
8999
run: |
90100
./Product/out/test/onert-test unittest
91101
./Product/out/test/onert-test unittest --unittestdir=./Product/out/nnapi-gtest
102+
103+
# Save cache on push to reduce the size of cache storage
104+
# ccache cache: only for master branch
105+
# externals cache: only for master branch and Release build and x86_64
106+
- name: Save ccache cache
107+
uses: actions/cache/save@v4
108+
if: github.event_name == 'push' && github.ref_name =='master'
109+
with:
110+
path: ~/.cache/ccache
111+
key: ${{ steps.ccache-cache.outputs.cache-primary-key }}
112+
113+
- name: Save externals cache
114+
uses: actions/cache/save@v4
115+
if: github.event_name == 'push' && github.ref_name =='master' && matrix.type =='release' && matrix.arch == 'x86_64'
116+
with:
117+
path: runtime/externals
118+
key: ${{ steps.external-cache.outputs.cache-primary-key }}

0 commit comments

Comments
 (0)