duque #1275
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: C/C++ CI | |
on: | |
push: | |
branches: [ "master", "next" ] | |
pull_request: | |
branches: [ "master", "next" ] | |
jobs: | |
ubuntu: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install latest available GCC | |
run: | | |
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test | |
sudo apt-get update | |
# 查找版本号最高的 g++ 包 | |
LATEST_GCC_VERSION=$(apt-cache search g\+\+ | grep -oP '^g\+\+-\K[0-9]+' | sort -rn | head -n 1) | |
echo "Found latest GCC version: ${LATEST_GCC_VERSION}" | |
sudo apt-get install -y g++-${LATEST_GCC_VERSION} | |
# 设置新版本为默认编译器 | |
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${LATEST_GCC_VERSION} 100 | |
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-${LATEST_GCC_VERSION} 100 | |
- name: Verify GCC version | |
run: g++ --version | |
- name: Install ninja-build tool | |
uses: seanmiddleditch/gha-setup-ninja@v5 | |
- name: cmake | |
run: cmake -GNinja . -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=On -DCMAKE_CXX_FLAGS="-fsanitize=address,undefined -Wall -Wextra -Wpedantic -Wmisleading-indentation -Wunused -Wuninitialized -Wshadow -Wconversion -Werror" | |
- name: ninja | |
run: ninja | |
- name: ninja test | |
run: ninja test | |
windows: | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ilammy/msvc-dev-cmd@v1.13.0 | |
- name: cmake | |
run: cmake -GNinja . -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=On -DCMAKE_CXX_FLAGS="/EHsc" -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl | |
- name: ninja | |
run: ninja | |
- name: ninja test | |
run: ninja test | |
windows-debug: | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ilammy/msvc-dev-cmd@v1.13.0 | |
- name: cmake | |
run: cmake -GNinja . -DCMAKE_BUILD_TYPE=Release -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreadedDebugDLL" -DENABLE_TESTS=On -DCMAKE_CXX_FLAGS="/fsanitize=address /EHsc" -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl | |
- name: ninja | |
run: ninja | |
- name: ninja test | |
run: ninja test | |
#macos: | |
# runs-on: macos-latest | |
# steps: | |
# - uses: actions/checkout@v3 | |
# - name: Install ninja-build tool | |
# uses: seanmiddleditch/gha-setup-ninja@v4 | |
# - name: cmake | |
# run: cmake -GNinja . -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=On -DCMAKE_CXX_FLAGS="-fsanitize=address,undefined -Wall -Wextra -Wpedantic -Wmisleading-indentation -Wunused -Wuninitialized -Wshadow -Wconversion -Werror" | |
# - name: ninja | |
# run: ninja | |
# - name: ninja test | |
# run: ninja test | |