diff --git a/.github/workflows/03-macos-linux-build.yml b/.github/workflows/03-macos-linux-build.yml index 1dd1e45c..66e814fe 100644 --- a/.github/workflows/03-macos-linux-build.yml +++ b/.github/workflows/03-macos-linux-build.yml @@ -40,6 +40,11 @@ jobs: with: submodules: recursive + - name: Setup ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ inputs.platform }}-${{ inputs.os }} + - name: Set up Python uses: actions/setup-python@v6 with: @@ -95,18 +100,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 +126,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 +139,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 092bacb3..ede1c9ba 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,12 @@ 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 }} - 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 26ffbbfc..bdc65282 100644 --- a/.github/workflows/06-ios-build.yml +++ b/.github/workflows/06-ios-build.yml @@ -31,6 +31,11 @@ jobs: with: submodules: recursive + - name: Setup ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ios-${{ matrix.platform }} + - name: Cache host protoc build uses: actions/cache@v5 with: @@ -42,7 +47,9 @@ jobs: - 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" @@ -72,7 +79,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 49e85eb6..67c63c8a 100644 --- a/.github/workflows/clang_tidy.yml +++ b/.github/workflows/clang_tidy.yml @@ -29,11 +29,18 @@ jobs: sudo apt-get update sudo apt-get install -y clang-tidy=1:18.0-59~exp2 cmake ninja-build + - name: Setup ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: clang-tidy + - 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