Skip to content

Commit 2793339

Browse files
author
Minh Hai Chu
authored
Refactor MLonMCU CI/CD caching and installation steps
Updated caching strategy for MLonMCU dependencies and workspace. Removed unnecessary steps and improved cache key management.
1 parent 6323805 commit 2793339

File tree

1 file changed

+38
-30
lines changed

1 file changed

+38
-30
lines changed

.github/workflows/cicd.yml

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,24 @@ jobs:
5252
cmake \
5353
libzstd-dev
5454
55-
- name: Cache Python virtualenv with dependencies
55+
- name: Cache MLonMCU workspace
56+
id: cache-mlonmcu
57+
uses: actions/cache@v4
58+
with:
59+
path: |
60+
mlonmcu/workspace_kws
61+
key: mlonmcu-workspace-${{ runner.os }}-${{ hashFiles('mlonmcu/requirements.txt', 'mlonmcu/setup.py', 'mlonmcu/mlonmcu/setup/tasks/*.py') }}
62+
restore-keys: |
63+
mlonmcu-workspace-${{ runner.os }}-
64+
65+
- name: Cache Python virtualenv
5666
id: cache-venv
5767
uses: actions/cache@v4
5868
with:
5969
path: mlonmcu/venv
60-
key: venv-${{ runner.os }}-v2-${{ hashFiles('mlonmcu/setup.py', 'mlonmcu/requirements*.txt') }}
70+
key: venv-${{ runner.os }}-v1-${{ hashFiles('mlonmcu/setup.py', 'mlonmcu/requirements*.txt', 'mlonmcu/workspace_kws/requirements_addition.txt') }}
6171
restore-keys: |
62-
venv-${{ runner.os }}-v2-
72+
venv-${{ runner.os }}-v1-
6373
6474
- name: Create MLonMCU virtualenv
6575
if: steps.cache-venv.outputs.cache-hit != 'true'
@@ -70,34 +80,13 @@ jobs:
7080
python3 -m venv venv
7181
source venv/bin/activate
7282
pip install -e .
73-
echo "Venv created with all dependencies"
7483
75-
- name: Reinstall mlonmcu package in editable mode (fixes paths after cache)
84+
- name: Reinstall mlonmcu in editable mode (fixes paths after cache restore)
7685
working-directory: mlonmcu
7786
shell: bash
7887
run: |
7988
source venv/bin/activate
8089
pip install -e . --no-deps
81-
echo "Verifying critical dependencies:"
82-
python3 -c "import mlonmcu; print(f'✓ mlonmcu: {mlonmcu.__file__}')" || {
83-
echo "ERROR: mlonmcu import failed, reinstalling..."
84-
pip install -e .
85-
}
86-
python3 -c "import tensorflow; print(f'✓ tensorflow: {tensorflow.__version__}')" || {
87-
echo "WARNING: tensorflow missing, installing all dependencies..."
88-
pip install -e .
89-
}
90-
python3 -c "import mlonmcu.setup.gen_requirements; print('✓ mlonmcu.setup accessible')"
91-
92-
- name: Cache MLonMCU workspace
93-
id: cache-mlonmcu
94-
uses: actions/cache@v4
95-
with:
96-
path: |
97-
mlonmcu/workspace_kws
98-
key: mlonmcu-workspace-${{ runner.os }}-${{ hashFiles('mlonmcu/requirements.txt', 'mlonmcu/setup.py', 'mlonmcu/mlonmcu/setup/tasks/*.py') }}
99-
restore-keys: |
100-
mlonmcu-workspace-${{ runner.os }}-
10190
10291
- name: Initialize MLonMCU workspace if cache missed
10392
if: steps.cache-mlonmcu.outputs.cache-hit != 'true'
@@ -110,12 +99,22 @@ jobs:
11099
- name: Set MLONMCU_HOME env
111100
run: echo "MLONMCU_HOME=$GITHUB_WORKSPACE/mlonmcu/workspace_kws" >> $GITHUB_ENV
112101

102+
- name: Cache MLonMCU dependencies (ETISS, toolchains, etc.)
103+
id: cache-deps
104+
uses: actions/cache@v4
105+
with:
106+
path: |
107+
mlonmcu/workspace_kws/deps
108+
key: mlonmcu-deps-${{ runner.os }}-v3-${{ hashFiles('mlonmcu/requirements.txt', 'mlonmcu/setup.py') }}
109+
restore-keys: |
110+
mlonmcu-deps-${{ runner.os }}-v3-
111+
mlonmcu-deps-${{ runner.os }}-
113112
- name: Configure Git to use HTTPS with token
114113
run: |
115114
git config --global url."https://${{ secrets.GITHUB_TOKEN }}@github.com/".insteadOf "git@github.com:"
116115
117116
- name: Setup MLonMCU toolchain
118-
if: steps.cache-mlonmcu.outputs.cache-hit != 'true'
117+
if: steps.cache-deps.outputs.cache-hit != 'true'
119118
working-directory: mlonmcu
120119
shell: bash
121120
run: |
@@ -126,8 +125,6 @@ jobs:
126125
echo "Running mlonmcu setup"
127126
python3 -m mlonmcu.cli.main setup -g
128127
python3 -m pip install -r $MLONMCU_HOME/requirements_addition.txt
129-
130-
python3 -m mlonmcu.cli.main setup --task clone_etiss_perf -v
131128
python3 -m mlonmcu.cli.main setup --task clone_etiss_perf_plugin -v
132129
133130
# Patch ETISS Channel.h for missing cstdint include
@@ -150,7 +147,19 @@ jobs:
150147
python3 -m mlonmcu.cli.main setup -v --progress -c cmake.use_system=true
151148
152149
echo "Setup completed successfully!"
153-
150+
151+
- name: Install workspace dependencies (tensorflow, etc.)
152+
working-directory: mlonmcu
153+
shell: bash
154+
run: |
155+
source venv/bin/activate
156+
if [ -f "$MLONMCU_HOME/requirements_addition.txt" ]; then
157+
echo "Installing dependencies from requirements_addition.txt..."
158+
pip install -r $MLONMCU_HOME/requirements_addition.txt
159+
else
160+
echo "Warning: requirements_addition.txt not found"
161+
fi
162+
154163
- name: Run KWS Model Simulation
155164
shell: bash
156165
run: |
@@ -170,4 +179,3 @@ jobs:
170179
mlonmcu/workspace_kws/temp/sessions/latest/report.csv
171180
mlonmcu/workspace_kws/temp/sessions/latest/*.log
172181
retention-days: 7
173-

0 commit comments

Comments
 (0)