Add CI workflow for KWS model setup and simulation #10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: Cache MLonMCU dependencies (ETISS, toolchains, etc.) | |
| id: cache-deps | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| mlonmcu/workspace_kws/deps | |
| key: mlonmcu-deps-${{ runner.os }}-v3-${{ hashFiles('mlonmcu/requirements.txt', 'mlonmcu/setup.py') }} | |
| restore-keys: | | |
| mlonmcu-deps-${{ runner.os }}-v3- | |
| mlonmcu-deps-${{ runner.os }}- | |
| - 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-deps.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!" | |