|
| 1 | +name: cmake-tests |
| 2 | +# CMake-specific build and test workflows |
| 3 | +# This workflow validates zstd builds across different CMake configurations, |
| 4 | +# platforms, and edge cases to ensure broad compatibility. |
| 5 | + |
| 6 | +concurrency: |
| 7 | + group: cmake-${{ github.ref }} |
| 8 | + cancel-in-progress: true |
| 9 | + |
| 10 | +on: |
| 11 | + pull_request: |
| 12 | + branches: [ dev, release, actionsTest ] |
| 13 | + |
| 14 | +permissions: read-all |
| 15 | + |
| 16 | +env: |
| 17 | + # Centralized test timeouts for consistency |
| 18 | + QUICK_TEST_TIME: "30s" |
| 19 | + STANDARD_TEST_TIME: "1mn" |
| 20 | + # Common CMake flags |
| 21 | + COMMON_CMAKE_FLAGS: "-DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DZSTD_BUILD_TESTS=ON" |
| 22 | + |
| 23 | +jobs: |
| 24 | + # Ubuntu-based cmake build using make wrapper |
| 25 | + # This test uses the make-driven cmake build to ensure compatibility |
| 26 | + # with the existing build system integration |
| 27 | + cmake-ubuntu-basic: |
| 28 | + name: "CMake Ubuntu Basic Build" |
| 29 | + runs-on: ubuntu-latest |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2 |
| 32 | + - name: Install dependencies |
| 33 | + run: | |
| 34 | + sudo apt install liblzma-dev # Required for compression algorithms |
| 35 | + - name: CMake build and test via make |
| 36 | + run: | |
| 37 | + # Use make wrapper for cmake build with quick test timeouts |
| 38 | + FUZZERTEST=-T${{ env.STANDARD_TEST_TIME }} ZSTREAM_TESTTIME=-T${{ env.STANDARD_TEST_TIME }} make cmakebuild V=1 |
| 39 | +
|
| 40 | + # Cross-platform cmake build with edge case: source paths containing spaces |
| 41 | + # This test ensures cmake handles filesystem paths with spaces correctly |
| 42 | + # across different operating systems and build generators |
| 43 | + cmake-cross-platform-spaces: |
| 44 | + name: "CMake Cross-Platform (Spaces in Path)" |
| 45 | + runs-on: ${{ matrix.os }} |
| 46 | + strategy: |
| 47 | + matrix: |
| 48 | + include: |
| 49 | + - os: ubuntu-latest |
| 50 | + generator: "Unix Makefiles" |
| 51 | + name: "Linux" |
| 52 | + - os: windows-latest |
| 53 | + generator: "NMake Makefiles" |
| 54 | + name: "Windows NMake" |
| 55 | + - os: macos-latest |
| 56 | + generator: "Unix Makefiles" |
| 57 | + name: "macOS" |
| 58 | + env: |
| 59 | + SRC_DIR: "source directory with spaces" |
| 60 | + steps: |
| 61 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2 |
| 62 | + with: |
| 63 | + path: "${{ env.SRC_DIR }}" |
| 64 | + - uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0 |
| 65 | + if: ${{ matrix.generator == 'NMake Makefiles' }} |
| 66 | + - name: "CMake build and install (${{ matrix.name }})" |
| 67 | + run: | |
| 68 | + # Test Release build with installation to verify packaging |
| 69 | + cmake -S "${{ env.SRC_DIR }}/build/cmake" -B build -DBUILD_TESTING=ON -G "${{ matrix.generator }}" -DCMAKE_BUILD_TYPE=Release --install-prefix "${{ runner.temp }}/install" |
| 70 | + cmake --build build --config Release |
| 71 | + cmake --install build --config Release |
| 72 | +
|
| 73 | + # Windows-specific cmake testing with Visual Studio 2022 |
| 74 | + # Tests multiple generators and toolchains to ensure broad Windows compatibility |
| 75 | + # including MSVC (x64, Win32, ARM64), MinGW, and Clang-CL with various architectures and optimizations |
| 76 | + cmake-windows-comprehensive: |
| 77 | + name: "CMake Windows VS2022 (${{ matrix.name }})" |
| 78 | + runs-on: ${{ matrix.runner }} |
| 79 | + strategy: |
| 80 | + fail-fast: false |
| 81 | + matrix: |
| 82 | + include: |
| 83 | + - generator: "Visual Studio 17 2022" |
| 84 | + flags: "-A x64" |
| 85 | + name: "MSVC x64" |
| 86 | + runner: "windows-2022" |
| 87 | + cmake_extra_flags: "-DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DZSTD_BUILD_TESTS=ON" |
| 88 | + - generator: "Visual Studio 17 2022" |
| 89 | + flags: "-A Win32" |
| 90 | + name: "MSVC Win32" |
| 91 | + runner: "windows-2022" |
| 92 | + cmake_extra_flags: "-DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DZSTD_BUILD_TESTS=ON" |
| 93 | + - generator: "Visual Studio 17 2022" |
| 94 | + flags: "-A x64" |
| 95 | + name: "MSVC x64 (No ZSTD_BUILD_TESTS)" |
| 96 | + runner: "windows-2022" |
| 97 | + # Intentionally omit ZSTD_BUILD_TESTS to reproduce the CXX language configuration bug |
| 98 | + cmake_extra_flags: "-DCMAKE_COMPILE_WARNING_AS_ERROR=ON" |
| 99 | + # - generator: "Visual Studio 17 2022" |
| 100 | + # flags: "-A ARM64" |
| 101 | + # name: "MSVC ARM64" |
| 102 | + # runner: "windows-2022-arm64" # Disabled due to very long queue times |
| 103 | + - generator: "MinGW Makefiles" |
| 104 | + flags: "" |
| 105 | + name: "MinGW" |
| 106 | + runner: "windows-2022" |
| 107 | + cmake_extra_flags: "-DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DZSTD_BUILD_TESTS=ON" |
| 108 | + - generator: "Visual Studio 17 2022" |
| 109 | + flags: "-T ClangCL" |
| 110 | + name: "Clang-CL" |
| 111 | + runner: "windows-2022" |
| 112 | + cmake_extra_flags: "-DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DZSTD_BUILD_TESTS=ON" |
| 113 | + - generator: "Visual Studio 17 2022" |
| 114 | + flags: "-T ClangCL -A x64 -DCMAKE_C_FLAGS=/arch:AVX2" |
| 115 | + name: "Clang-CL AVX2" |
| 116 | + runner: "windows-2022" |
| 117 | + cmake_extra_flags: "-DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DZSTD_BUILD_TESTS=ON" |
| 118 | + steps: |
| 119 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2 |
| 120 | + - name: Add MSBuild to PATH |
| 121 | + uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # tag=v2.0.0 |
| 122 | + - name: "Configure CMake (${{ matrix.name }})" |
| 123 | + run: | |
| 124 | + cd build\cmake |
| 125 | + mkdir build |
| 126 | + cd build |
| 127 | + cmake.exe -G "${{matrix.generator}}" ${{matrix.flags}} -DCMAKE_BUILD_TYPE=Debug ${{ matrix.cmake_extra_flags }} -DZSTD_ZSTREAM_FLAGS=-T${{ env.QUICK_TEST_TIME }} -DZSTD_FUZZER_FLAGS=-T${{ env.QUICK_TEST_TIME }} -DZSTD_FULLBENCH_FLAGS=-i0 .. |
| 128 | + - name: "Build (${{ matrix.name }})" |
| 129 | + run: | |
| 130 | + cd build\cmake\build |
| 131 | + cmake.exe --build . |
| 132 | + - name: "Test (${{ matrix.name }})" |
| 133 | + run: | |
| 134 | + cd build\cmake\build |
| 135 | + ctest.exe -V -C Debug |
| 136 | +
|
| 137 | + # macOS ARM64 (Apple Silicon) specific cmake testing |
| 138 | + # Validates zstd builds and runs correctly on Apple Silicon architecture |
| 139 | + # Uses native ARM64 hardware for optimal performance and compatibility testing |
| 140 | + cmake-macos-arm64: |
| 141 | + name: "CMake macOS ARM64 (Apple Silicon)" |
| 142 | + runs-on: macos-14 # ARM64 runner |
| 143 | + steps: |
| 144 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2 |
| 145 | + - name: "CMake build and test (ARM64)" |
| 146 | + run: | |
| 147 | + # Configure and build with ARM64-specific optimizations |
| 148 | + cd build/cmake |
| 149 | + mkdir build |
| 150 | + cd build |
| 151 | + cmake -DCMAKE_BUILD_TYPE=Release ${{ env.COMMON_CMAKE_FLAGS }} -DZSTD_ZSTREAM_FLAGS=-T${{ env.QUICK_TEST_TIME }} -DZSTD_FUZZER_FLAGS=-T${{ env.QUICK_TEST_TIME }} -DZSTD_FULLBENCH_FLAGS=-i1 .. |
| 152 | + make -j$(sysctl -n hw.ncpu) |
| 153 | + ctest -V |
0 commit comments