Skip to content

Refactor CI/CD workflow by removing dependency cache #12

Refactor CI/CD workflow by removing dependency cache

Refactor CI/CD workflow by removing dependency cache #12

Workflow file for this run

name: KWS Workspace CI
on:
push:
branches: [ chore/setup-cicd ]
jobs:
simulate-kws:
name: Build & Simulate KWS Model
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Free up disk space
run: |
echo "Disk space before cleanup:"
df -h
# Remove huge unnecessary tools to free up ~26GB
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/share/swift
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/.ghcup
sudo docker system prune -a -f
sudo apt-get clean
sudo rm -rf /var/lib/apt/lists/*
sudo rm -rf /tmp/* /tmp/.* 2>/dev/null || true
echo "Disk space after cleanup:"
df -h
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.8"
cache: "pip"
- name: Install system dependencies (Boost, build essentials)
run: |
sudo apt-get update
sudo apt-get install -y \
libboost-filesystem-dev \
libboost-system-dev \
libboost-program-options-dev \
build-essential \
ninja-build \
cmake \
libzstd-dev
- name: Create MLonMCU virtualenv
working-directory: mlonmcu
shell: bash
run: |
echo "Setting up virtual environment..."
python3 -m venv venv
source venv/bin/activate
pip install -e .
- name: Cache MLonMCU workspace
id: cache-mlonmcu
uses: actions/cache@v4
with:
path: |
mlonmcu/workspace_kws
key: mlonmcu-workspace-${{ runner.os }}-${{ hashFiles('mlonmcu/requirements.txt', 'mlonmcu/setup.py', 'mlonmcu/mlonmcu/setup/tasks/*.py') }}
restore-keys: |
mlonmcu-workspace-${{ runner.os }}-
- name: Initialize MLonMCU workspace if cache missed
if: steps.cache-mlonmcu.outputs.cache-hit != 'true'
working-directory: mlonmcu
shell: bash
run: |
source venv/bin/activate
python3 -m mlonmcu.cli.main init -t kws workspace_kws --clone-models --non-interactive --allow-exists
- name: Set MLONMCU_HOME env
run: echo "MLONMCU_HOME=$GITHUB_WORKSPACE/mlonmcu/workspace_kws" >> $GITHUB_ENV
- name: Configure Git to use HTTPS with token
run: |
git config --global url."https://${{ secrets.GITHUB_TOKEN }}@github.com/".insteadOf "git@github.com:"
- name: Setup MLonMCU toolchain
if: steps.cache-mlonmcu.outputs.cache-hit != 'true'
working-directory: mlonmcu
shell: bash
run: |
source venv/bin/activate
rm -f $MLONMCU_HOME/.deps_lock
echo "Running mlonmcu setup"
python3 -m mlonmcu.cli.main setup -g
python3 -m pip install -r $MLONMCU_HOME/requirements_addition.txt
python3 -m mlonmcu.cli.main setup --task clone_etiss_perf -v
python3 -m mlonmcu.cli.main setup --task clone_etiss_perf_plugin -v
# Patch ETISS Channel.h for missing cstdint include
CHANNEL_H="$MLONMCU_HOME/deps/src/etiss_perf/PluginImpl/SoftwareEvalLib/libs/backends/include/api/softwareEval-backends/Channel.h"
if [ -f "$CHANNEL_H" ]; then
if ! grep -q "#include <cstdint>" "$CHANNEL_H"; then
echo "Patching Channel.h: adding missing #include <cstdint>"
sed -i '/#include <stdbool.h>/a #include <cstdint>' "$CHANNEL_H"
else
echo "Channel.h already patched"
fi
else
echo "Warning: Channel.h not found at expected location"
ls -la "$MLONMCU_HOME/deps/src/etiss_perf/PluginImpl/" || true
fi
# Force removal of static libzstd to make CMake use shared library
sudo rm -f /usr/lib/x86_64-linux-gnu/libzstd.a
python3 -m mlonmcu.cli.main setup -v --progress -c cmake.use_system=true
echo "Setup completed successfully!"
- name: Run KWS Model Simulation
shell: bash
run: |
source $GITHUB_WORKSPACE/mlonmcu/venv/bin/activate
cd /tmp
echo "Testing mlonmcu import:"
python3 -c "import mlonmcu; print(f'mlonmcu: {mlonmcu.__file__}')"
python3 -c "import mlonmcu.setup.gen_requirements; print('OK')"
python3 $GITHUB_WORKSPACE/run.py kws_1 --print simulate --core_model esp32c3
- name: Upload simulation results
uses: actions/upload-artifact@v4
if: always()
with:
name: simulation-results
path: |
mlonmcu/workspace_kws/temp/sessions/latest/report.csv
mlonmcu/workspace_kws/temp/sessions/latest/*.log
retention-days: 7