diff --git a/.github/workflows/03-macos-linux-build.yml b/.github/workflows/03-macos-linux-build.yml index 1dd1e45..4ea8c74 100644 --- a/.github/workflows/03-macos-linux-build.yml +++ b/.github/workflows/03-macos-linux-build.yml @@ -40,6 +40,12 @@ jobs: with: submodules: recursive + - name: Setup ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ inputs.platform }}-${{ inputs.os }}-${{ inputs.compiler || 'gcc' }} + max-size: 150M + - name: Set up Python uses: actions/setup-python@v6 with: @@ -95,18 +101,20 @@ jobs: run: | cd "$GITHUB_WORKSPACE" - CMAKE_GENERATOR="Unix Makefiles" \ + CMAKE_GENERATOR="Ninja" \ CMAKE_BUILD_PARALLEL_LEVEL="$NPROC" \ python -m pip install -v . \ --no-build-isolation \ - --config-settings='cmake.define.BUILD_TOOLS="ON"' \ + --config-settings='cmake.define.BUILD_TOOLS=ON' \ + --config-settings='cmake.define.CMAKE_C_COMPILER_LAUNCHER=ccache' \ + --config-settings='cmake.define.CMAKE_CXX_COMPILER_LAUNCHER=ccache' \ ${{ matrix.arch_flag }} shell: bash - name: Run C++ Tests run: | cd "$GITHUB_WORKSPACE/build" - make unittest -j$NPROC + cmake --build . --target unittest --parallel $NPROC shell: bash - name: Run Python Tests @@ -119,8 +127,10 @@ jobs: run: | cd "$GITHUB_WORKSPACE/examples/c++" mkdir build && cd build - cmake .. -DCMAKE_BUILD_TYPE=Release - make -j $NPROC + cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + cmake --build . --parallel $NPROC ./db-example ./core-example ./ailego-example @@ -130,8 +140,10 @@ jobs: run: | cd "$GITHUB_WORKSPACE/examples/c" mkdir build && cd build - cmake .. -DCMAKE_BUILD_TYPE=Release - make -j $NPROC + cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + cmake --build . --parallel $NPROC ./c_api_basic_example ./c_api_collection_schema_example ./c_api_doc_example diff --git a/.github/workflows/04-android-build.yml b/.github/workflows/04-android-build.yml index 092bacb..b635205 100644 --- a/.github/workflows/04-android-build.yml +++ b/.github/workflows/04-android-build.yml @@ -25,11 +25,6 @@ jobs: matrix: abi: [x86_64] api: ${{ github.event.inputs.api && fromJSON(format('["{0}"]', github.event.inputs.api)) || fromJSON('["34"]') }} - env: - CCACHE_BASEDIR: ${{ github.workspace }} - CCACHE_NOHASHDIR: '1' - CCACHE_SLOPPINESS: clang_index_store,file_stat_matches,include_file_mtime,locale,time_macros - steps: # ── Environment setup ────────────────────────────────────────────── - name: Checkout @@ -42,15 +37,13 @@ jobs: sudo apt-get update sudo apt-get install -y --no-install-recommends \ cmake ninja-build git ca-certificates python3 \ - build-essential make ccache unzip curl + build-essential make unzip curl - - name: Cache ccache - uses: actions/cache@v5 + - name: Setup ccache + uses: hendrikmuhs/ccache-action@v1.2 with: - path: ~/.ccache - key: ${{ runner.os }}-ccache-android-${{ matrix.abi }}-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-ccache-android-${{ matrix.abi }}- + key: android-${{ matrix.abi }} + max-size: 300M - name: Setup Java 17 uses: actions/setup-java@v5 diff --git a/.github/workflows/06-ios-build.yml b/.github/workflows/06-ios-build.yml index 26ffbbf..802716d 100644 --- a/.github/workflows/06-ios-build.yml +++ b/.github/workflows/06-ios-build.yml @@ -31,29 +31,31 @@ jobs: with: submodules: recursive + - name: Setup ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ios-${{ matrix.platform }} + max-size: 150M + - name: Cache host protoc build uses: actions/cache@v5 with: path: build_host - key: macos-host-protoc-${{ hashFiles('src/**', 'CMakeLists.txt') }} + key: macos-host-protoc-${{ hashFiles('thirdparty/protobuf/**', 'CMakeLists.txt') }} restore-keys: | macos-host-protoc- - name: Build host protoc run: | if [ ! -f "build_host/bin/protoc" ]; then - cmake -S . -B build_host -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 + cmake -S . -B build_host -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache cmake --build build_host --target protoc --parallel $(sysctl -n hw.ncpu) else echo "Using cached host protoc" fi - - name: Cache iOS build - uses: actions/cache@v5 - with: - path: build_ios_${{ matrix.platform }} - key: ios-build-${{ matrix.platform }}-${{ hashFiles('src/**', 'CMakeLists.txt', 'cmake/**', 'thirdparty/**') }} - - name: Configure and Build run: | git submodule foreach --recursive 'git stash --include-untracked' || true @@ -72,7 +74,9 @@ jobs: -DCMAKE_INSTALL_PREFIX="./install" \ -DGLOBAL_CC_PROTOBUF_PROTOC="$GITHUB_WORKSPACE/build_host/bin/protoc" \ -DIOS=ON \ - -DCMAKE_POLICY_VERSION_MINIMUM=3.5 + -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache cmake --build build_ios_${{ matrix.platform }} --parallel $NPROC diff --git a/.github/workflows/clang_tidy.yml b/.github/workflows/clang_tidy.yml index 0b595b6..aba45c5 100644 --- a/.github/workflows/clang_tidy.yml +++ b/.github/workflows/clang_tidy.yml @@ -29,11 +29,19 @@ jobs: sudo apt-get update sudo apt-get install -y clang-tidy=1:18.0-59~exp2 cmake ninja-build libomp-dev + - name: Setup ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: clang-tidy + max-size: 100M + - name: Configure CMake and export compile commands run: | cmake -S . -B build -G Ninja \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ - -DBUILD_TOOLS=ON + -DBUILD_TOOLS=ON \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - name: Collect changed C/C++ files id: changed_files