Skip to content

Commit 05dbca5

Browse files
ci: Optimize Caching
Cache Python Base before installing PIP Requirements for specific Zephyr SDK Version.
1 parent b41d7f1 commit 05dbca5

1 file changed

Lines changed: 22 additions & 16 deletions

File tree

.github/workflows/workflow.yml

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -114,20 +114,36 @@ jobs:
114114
zephyr-workspace/tools
115115
key: west-workspace-${{ steps.generate-vars.outputs.sdk-hash }}
116116

117-
- name: 📦 Cache Python venv
118-
id: cache-venv
117+
- name: 📦 Cache PIP Requirements
118+
id: cache-pip
119119
uses: actions/cache@v5
120+
with:
121+
path: ~/.venv
122+
key: venv-pip-${{ env.ZEPHYR_SDK_VERSION }}
123+
124+
- name: 📦 Restore Python venv
125+
if: steps.cache-pip.outputs.cache-hit != 'true'
126+
id: restore-venv
127+
uses: actions/cache/restore@v5
120128
with:
121129
path: ~/.venv
122130
key: venv-${{ env.ZEPHYR_SDK_VERSION }}
123131

124132
- name: 🐍 Setup Python venv + West
125133
id: setup-venv
126-
if: steps.cache-venv.outputs.cache-hit != 'true'
134+
if: ${{ steps.cache-pip.outputs.cache-hit != 'true' && steps.restore-venv.outputs.cache-hit != 'true' }}
127135
run: |
128136
python3 -m venv ~/.venv
129137
~/.venv/bin/pip install west ninja
130138
139+
- name: 📦 Cache Python venv
140+
if: steps.restore-venv.outputs.cache-hit != 'true'
141+
id: cache-venv
142+
uses: actions/cache/save@v5
143+
with:
144+
path: ~/.venv
145+
key: venv-${{ env.ZEPHYR_SDK_VERSION }}
146+
131147
- name: ♻️ Initialize Zephyr Workspace
132148
id: init-west
133149
run: |
@@ -140,13 +156,6 @@ jobs:
140156
west update --narrow -o=--depth=1
141157
west zephyr-export
142158
143-
- name: 📦 Cache PIP Requirements
144-
id: cache-pip
145-
uses: actions/cache@v5
146-
with:
147-
path: ~/.venv
148-
key: venv-pip-${{ env.ZEPHYR_SDK_VERSION }}-${{ hashFiles('zephyr-workspace/zephyr/scripts/requirements.txt') }}
149-
150159
- name: 🐍 Install Zephyr Python Requirements
151160
id: install-pip
152161
if: steps.cache-pip.outputs.cache-hit != 'true'
@@ -246,15 +255,12 @@ jobs:
246255
key: west-workspace-${{ needs.setup.outputs.sdk-hash }}
247256
fail-on-cache-miss: true
248257

249-
- name: 📦 Restore Python venv
250-
id: restore-venv
258+
- name: 📦 Restore PIP Requirements
259+
id: restore-pip
251260
uses: actions/cache/restore@v5
252261
with:
253262
path: ~/.venv
254-
key: venv-pip-${{ env.ZEPHYR_SDK_VERSION }}-${{ hashFiles('zephyr-workspace/zephyr/scripts/requirements.txt') }}
255-
restore-keys: |
256-
venv-pip-
257-
venv-
263+
key: venv-pip-${{ env.ZEPHYR_SDK_VERSION }}
258264
fail-on-cache-miss: true
259265

260266
- name: ♻️ Register Zephyr Workspace

0 commit comments

Comments
 (0)