Spaces:
Running
Running
| name: "CI-CMake" | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| workflow_dispatch: | |
| inputs: | |
| REFRESH_CACHE: | |
| description: 'Refresh build cache' | |
| type: boolean | |
| default: false | |
| permissions: | |
| contents: read | |
| actions: write | |
| env: | |
| MODEL_KEY: gemma-3-1b-it-v1 | |
| MODEL_PATH: ./models/gemma3-1b-it-int4.litertlm | |
| MODEL_URL: https://huggingface.co/litert-community/Gemma3-1B-IT/resolve/main/gemma3-1b-it-int4.litertlm | |
| CCACHE_DIR: "${{ github.workspace }}/.ccache" | |
| CCACHE_SLOPPINESS: "time_macros" | |
| jobs: | |
| presubmit: | |
| name: "Presubmit-CMake-Linux" | |
| runs-on: LiteRT_Linux_x64 | |
| container: | |
| image: ubuntu:24.04 | |
| steps: | |
| - name: Install System Dependencies | |
| run: | | |
| apt-get update && apt-get install -y \ | |
| build-essential cmake make gdb pkg-config \ | |
| openjdk-17-jre-headless git wget curl unzip \ | |
| tar python3 python3-dev python3-pip \ | |
| python3-numpy ccache zlib1g-dev libssl-dev \ | |
| libpng-dev libcurl4-openssl-dev libfftw3-dev \ | |
| apt-file && apt-file update | |
| - name: Install Rust | |
| run: | | |
| curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
| echo "$HOME/.cargo/bin" >> $GITHUB_PATH | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Download Model | |
| env: | |
| HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
| run: | | |
| mkdir -p ./models | |
| echo "Downloading model from Hugging Face..." | |
| curl -L --retry 5 -f \ | |
| -H "Authorization: Bearer $HF_TOKEN" \ | |
| -o ${{ env.MODEL_PATH }} \ | |
| "${{ env.MODEL_URL }}" | |
| ls -lh ${{ env.MODEL_PATH }} | |
| - name: Cache FetchContent Deps | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| cmake/build/_deps | |
| cmake/build/third_party | |
| key: ${{ runner.os }}-fc-deps-${{ hashFiles('cmake/modules/fetch_content.cmake') }} | |
| - name: Cache ExternalProject Deps | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| cmake/build/external/abseil-cpp | |
| cmake/build/external/protobuf | |
| cmake/build/external/re2 | |
| cmake/build/external/sentencepiece | |
| cmake/build/external/tokenizers-cpp | |
| cmake/build/external/opencl_headers | |
| key: ${{ runner.os }}-ext-deps-${{ hashFiles('cmake/packages/absl/**', 'cmake/packages/protobuf/**', 'cmake/packages/re2/**', 'cmake/packages/sentencepiece/**', 'cmake/packages/tokenizers/**', 'cmake/packages/opencl/**') }} | |
| - name: Cache TensorFlow | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| cmake/build/external/tensorflow | |
| key: ${{ runner.os }}-tflite-${{ hashFiles('cmake/packages/tflite/**') }} | |
| restore-keys: | | |
| ${{ runner.os }}-tflite- | |
| - name: Cache LiteRT | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| cmake/build/external/litert | |
| key: ${{ runner.os }}-litert-${{ hashFiles('cmake/packages/litert/**') }} | |
| restore-keys: | | |
| ${{ runner.os }}-litert- | |
| - name: Cache CCache | |
| uses: actions/cache@v4 | |
| with: | |
| path: .ccache | |
| key: ${{ runner.os }}-ccache-${{ hashFiles('**/CMakeLists.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-ccache- | |
| - name: Cache Generated Sourcetree & Flatbuffers | |
| id: cache-generated | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| cmake/build/generated | |
| cmake/build/external/flatbuffers | |
| key: ${{ runner.os }}-generated-src-v1-${{ hashFiles('schema/**/*.fbs', 'cmake/modules/generators.cmake', 'cmake/packages/flatbuffers/**', 'c/**/*.{cc,h}', 'schema/**/*.{cc,h}', 'runtime/**/*.{cc,h}') }} | |
| - name: Configure CMake | |
| run: | | |
| # The restored caches will populate external/ and _deps/ before this runs. | |
| cmake -B cmake/build -G "Unix Makefiles" -S . \ | |
| -DCMAKE_BUILD_TYPE=Release \ | |
| -DCMAKE_CXX_COMPILER=g++ \ | |
| -DCMAKE_C_COMPILER=gcc \ | |
| -DENABLE_CCACHE=ON | |
| - name: Build | |
| run: cmake --build cmake/build --config Release --parallel $(nproc) | |
| - name: Install pytest | |
| run: python3 -m pip install --break-system-packages pytest==8.3.4 | |
| - name: Run pytest | |
| run: pytest tools/test/ --model-path=${{ env.MODEL_PATH }} --build-system=cmake | |