From 6773391a397c8a78a2a446931eebb2f6777a0e72 Mon Sep 17 00:00:00 2001 From: X1aomu Date: Wed, 16 Apr 2025 17:16:22 +0800 Subject: [PATCH] ci: add Github actions --- .github/workflows/linux.yml | 75 ++++++++++++++++++++++++++++++++++ .github/workflows/old_gcc.yml | 77 +++++++++++++++++++++++++++++++++++ .github/workflows/windows.yml | 72 ++++++++++++++++++++++++++++++++ 3 files changed, 224 insertions(+) create mode 100644 .github/workflows/linux.yml create mode 100644 .github/workflows/old_gcc.yml create mode 100644 .github/workflows/windows.yml diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 0000000..859fe93 --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,75 @@ +name: Test on Linux + +on: + push: + branches: + - main + - ci/** + pull_request: + branches: + - main + +jobs: + build-and-test: + strategy: + fail-fast: false + + matrix: + os: [ubuntu-22.04, ubuntu-24.04] + cppstd: ['17', '20', '23'] + build-type: [Debug, Release] + include: + - os: ubuntu-22.04 + gcc-version: 11 + - os: ubuntu-24.04 + gcc-version: 13 + - build-type: Debug + cmake-preset: conan-debug + - build-type: Release + cmake-preset: conan-release + + name: GCC ${{ matrix.gcc-version }} - C++${{ matrix.cppstd }} - ${{ matrix.build-type }} + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + + - name: Check GCC Version + shell: bash + run: | + gcc -dumpversion + (( $(gcc -dumpversion | cut -d. -f1) == ${{ matrix.gcc-version }} )) + + - name: Install Conan + uses: turtlebrowser/get-conan@main + + - name: Setup Conan + run: | + conan --version + conan profile detect + + - name: Install CMake + uses: lukka/get-cmake@latest + + - name: Install dependencies + run: > + conan install . + -s compiler.cppstd=${{ matrix.cppstd }} + -s build_type=${{ matrix.build-type }} + -b missing + + - name: CMake Configure + run: | + cmake --list-presets + cmake --preset ${{ matrix.cmake-preset }} + + - name: Build + run: | + cmake --build --list-presets + cmake --build --preset ${{ matrix.cmake-preset }} + + - name: Test + run: | + ctest --list-presets + ctest --preset ${{ matrix.cmake-preset }} diff --git a/.github/workflows/old_gcc.yml b/.github/workflows/old_gcc.yml new file mode 100644 index 0000000..1a3121f --- /dev/null +++ b/.github/workflows/old_gcc.yml @@ -0,0 +1,77 @@ +name: Test on Linux (Old GCC) + +on: + push: + branches: + - main + - ci/** + pull_request: + branches: + - main + +jobs: + build-and-test: + strategy: + fail-fast: false + + matrix: + os: [ubuntu-22.04] + gcc-version: [9] + cppstd: ['17', '20'] + build-type: [Debug, Release] + include: + - build-type: Debug + cmake-preset: conan-debug + - build-type: Release + cmake-preset: conan-release + + name: GCC ${{ matrix.gcc-version }} - C++${{ matrix.cppstd }} - ${{ matrix.build-type }} + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + + - name: Setup GCC + uses: egor-tensin/setup-gcc@v1 + with: + version: ${{ matrix.gcc-version }} + + - name: Check GCC Version + shell: bash + run: | + gcc -dumpversion + (( $(gcc -dumpversion | cut -d. -f1) == ${{ matrix.gcc-version }} )) + + - name: Install Conan + uses: turtlebrowser/get-conan@main + + - name: Setup Conan + run: | + conan --version + conan profile detect + + - name: Install CMake + uses: lukka/get-cmake@latest + + - name: Install dependencies + run: > + conan install . + -s compiler.cppstd=${{ matrix.cppstd }} + -s build_type=${{ matrix.build-type }} + -b missing + + - name: CMake Configure + run: | + cmake --list-presets + cmake --preset ${{ matrix.cmake-preset }} + + - name: Build + run: | + cmake --build --list-presets + cmake --build --preset ${{ matrix.cmake-preset }} + + - name: Test + run: | + ctest --list-presets + ctest --preset ${{ matrix.cmake-preset }} diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 0000000..58f2040 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,72 @@ +name: Test on Windows + +on: + push: + branches: + - main + - ci/** + pull_request: + branches: + - main + +jobs: + build-and-test: + strategy: + fail-fast: false + + matrix: + os: [windows-2019, windows-2022] + cppstd: ['17', '20', '23'] + build-type: [Debug, Release] + exclude: + - os: windows-2019 + cppstd: '23' + include: + - os: windows-2019 + msvc-version: 142 + - os: windows-2022 + msvc-version: 143 + - build-type: Debug + cmake-preset: conan-debug + - build-type: Release + cmake-preset: conan-release + + name: MSVC ${{ matrix.msvc-version }} - C++${{ matrix.cppstd }} - ${{ matrix.build-type }} + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + + - name: Install Conan + uses: turtlebrowser/get-conan@main + + - name: Setup Conan + run: | + conan --version + conan profile detect + + - name: Install CMake + uses: lukka/get-cmake@latest + + - name: Install dependencies + run: > + conan install . + -s compiler.cppstd=${{ matrix.cppstd }} + -s build_type=${{ matrix.build-type }} + -b missing + + - name: CMake Configure + run: | + cmake --list-presets + cmake --preset conan-default + + - name: Build + run: | + cmake --build --list-presets + cmake --build --preset ${{ matrix.cmake-preset }} + + - name: Test + run: | + ctest --list-presets + ctest --preset ${{ matrix.cmake-preset }}