Skip to content

Commit 5e6bdf5

Browse files
authored
Merge pull request #4406 from Cyan4973/separate-cmake-tests
cmake CI tests refactor
2 parents 88bea95 + 9a6fe9a commit 5e6bdf5

File tree

10 files changed

+412
-257
lines changed

10 files changed

+412
-257
lines changed

.github/workflows/cmake-tests.yml

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
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

.github/workflows/dev-short-tests.yml

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -72,40 +72,6 @@ jobs:
7272
# candidate test (for discussion) : underlink test
7373
# LDFLAGS=-Wl,--no-undefined : will make the linker fail if dll is underlinked
7474

75-
cmake-build-and-test-check:
76-
runs-on: ubuntu-latest
77-
steps:
78-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
79-
- name: cmake build and test
80-
run: |
81-
sudo apt install liblzma-dev
82-
FUZZERTEST=-T1mn ZSTREAM_TESTTIME=-T1mn make cmakebuild V=1
83-
84-
cmake-source-directory-with-spaces:
85-
runs-on: ${{ matrix.os }}
86-
strategy:
87-
matrix:
88-
include:
89-
- os: ubuntu-latest
90-
generator: "Unix Makefiles"
91-
- os: windows-latest
92-
generator: "NMake Makefiles"
93-
- os: macos-latest
94-
generator: "Unix Makefiles"
95-
env:
96-
SRC_DIR: "source directory with spaces"
97-
steps:
98-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
99-
with:
100-
path: "${{ env.SRC_DIR }}"
101-
- uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
102-
if: ${{ matrix.generator == 'NMake Makefiles' }}
103-
- name: cmake build on a source directory with spaces
104-
run: |
105-
cmake -S "${{ env.SRC_DIR }}/build/cmake" -B build -DBUILD_TESTING=ON -G "${{ matrix.generator }}" -DCMAKE_BUILD_TYPE=Release --install-prefix "${{ runner.temp }}/install"
106-
cmake --build build --config Release
107-
cmake --install build --config Release
108-
10975
cpp-gnu90-c99-compatibility:
11076
runs-on: ubuntu-latest
11177
steps:
@@ -339,34 +305,6 @@ jobs:
339305
run: |
340306
meson install -C builddir --destdir staging/
341307
342-
cmake-visual-2022:
343-
strategy:
344-
matrix:
345-
include:
346-
- generator: "Visual Studio 17 2022"
347-
flags: "-A x64"
348-
- generator: "Visual Studio 17 2022"
349-
flags: "-A Win32"
350-
- generator: "MinGW Makefiles"
351-
- generator: "Visual Studio 17 2022"
352-
flags: "-T ClangCL"
353-
- generator: "Visual Studio 17 2022"
354-
flags: "-T ClangCL -A x64 -DCMAKE_C_FLAGS=/arch:AVX2"
355-
runs-on: windows-2022
356-
steps:
357-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
358-
- name: Add MSBuild to PATH
359-
uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # tag=v2.0.0
360-
- name: Build & Test
361-
working-directory: ${{env.GITHUB_WORKSPACE}}
362-
run: |
363-
cd build\cmake
364-
mkdir build
365-
cd build
366-
cmake.exe -G "${{matrix.generator}}" ${{matrix.flags}} -DCMAKE_BUILD_TYPE=Debug -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DZSTD_BUILD_TESTS:BOOL=ON -DZSTD_ZSTREAM_FLAGS=-T30s -DZSTD_FUZZER_FLAGS=-T30s -DZSTD_FULLBENCH_FLAGS=-i0 ..
367-
cmake.exe --build .
368-
ctest.exe -V -C Debug
369-
370308
msbuild-visual-studio:
371309
strategy:
372310
fail-fast: false # 'false' means Don't stop matrix workflows even if some matrix failed.

0 commit comments

Comments
 (0)