Skip to content
25 changes: 18 additions & 7 deletions .github/workflows/03-macos-linux-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ jobs:
with:
submodules: recursive

- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ inputs.platform }}-${{ inputs.os }}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

把compiler也加到key上吧,不然也容易cache miss吧?


- name: Set up Python
uses: actions/setup-python@v6
with:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
16 changes: 4 additions & 12 deletions .github/workflows/04-android-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/06-ios-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是不是可以去掉?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不需要。目前多平台(除windows)的ci都是加了两层cache加速。整个cache用量目前在2G左右。

image

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

macOS和linux的是一层cache吧?两层指的是?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

两层cache加速的效果应该不大吧?另外这里的cache size也会随着action的运行累加,比如此时此刻

Image

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

主要是ios的cache比较大(~890MB+350MB),这里用两层感觉有点浪费

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@feihongxu0824

macOS和linux的是一层cache吧?两层指的是?

ccache + action@cache

with:
Expand All @@ -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"
Expand Down Expand Up @@ -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

Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/clang_tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,18 @@ 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

- 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
Expand Down
Loading