| 1 |
name: CI |
| 2 |
on: [pull_request] |
| 3 |
|
| 4 |
jobs: |
| 5 |
x86_64-build-and-test: |
| 6 |
name: Build and test (x86_64, ${{ matrix.os }}, ${{ matrix.compiler }}) |
| 7 |
strategy: |
| 8 |
matrix: |
| 9 |
os: [ubuntu-24.04, ubuntu-22.04] |
| 10 |
compiler: [gcc, clang] |
| 11 |
runs-on: ${{ matrix.os }} |
| 12 |
env: |
| 13 |
CC: ${{ matrix.compiler }} |
| 14 |
steps: |
| 15 |
- uses: actions/checkout@v4 |
| 16 |
- name: Install dependencies |
| 17 |
run: | |
| 18 |
sudo apt-get update |
| 19 |
sudo apt-get install -y clang llvm libz-dev valgrind |
| 20 |
- run: scripts/run_tests.sh |
| 21 |
- name: Direct compilation without official build system |
| 22 |
run: $CC -O2 -Wall -Werror lib/*{,/*}.c programs/{gzip,prog_util,tgetopt}.c -o libdeflate-gzip |
| 23 |
|
| 24 |
other-arch-build-and-test: |
| 25 |
name: Build and test (${{ matrix.arch }}, ${{ matrix.distro }}, ${{ matrix.compiler }}) |
| 26 |
strategy: |
| 27 |
matrix: |
| 28 |
include: |
| 29 |
# - { arch: armv6, distro: bookworm, compiler: gcc } |
| 30 |
# - { arch: armv6, distro: bookworm, compiler: clang } |
| 31 |
- { arch: armv7, distro: bookworm, compiler: gcc } |
| 32 |
- { arch: armv7, distro: bookworm, compiler: clang } |
| 33 |
- { arch: aarch64, distro: bookworm, compiler: gcc } |
| 34 |
- { arch: aarch64, distro: bookworm, compiler: clang } |
| 35 |
- { arch: s390x, distro: bookworm, compiler: gcc } |
| 36 |
- { arch: s390x, distro: bookworm, compiler: clang } |
| 37 |
- { arch: ppc64le, distro: bookworm, compiler: gcc } |
| 38 |
- { arch: ppc64le, distro: bookworm, compiler: clang } |
| 39 |
- { arch: riscv64, distro: ubuntu_latest, compiler: gcc } |
| 40 |
- { arch: riscv64, distro: ubuntu_latest, compiler: clang } |
| 41 |
runs-on: ubuntu-latest |
| 42 |
steps: |
| 43 |
- uses: actions/checkout@v4 |
| 44 |
- uses: uraimo/[email protected] |
| 45 |
with: |
| 46 |
arch: ${{ matrix.arch }} |
| 47 |
distro: ${{ matrix.distro }} |
| 48 |
githubToken: ${{ github.token }} |
| 49 |
install: | |
| 50 |
apt-get update |
| 51 |
apt-get install -y build-essential cmake clang llvm libz-dev |
| 52 |
run: | |
| 53 |
tests=(regular) |
| 54 |
if [ ${{matrix.compiler}} = clang ]; then |
| 55 |
tests+=(ubsan) |
| 56 |
fi |
| 57 |
CC=${{matrix.compiler}} scripts/run_tests.sh "${tests[@]}" |
| 58 |
|
| 59 |
macos-build-and-test: |
| 60 |
name: Build and test (macOS) |
| 61 |
runs-on: macos-latest |
| 62 |
env: |
| 63 |
CFLAGS: -Werror -DLIBDEFLATE_ENABLE_ASSERTIONS |
| 64 |
steps: |
| 65 |
- uses: actions/checkout@v4 |
| 66 |
- run: cmake -B build -DLIBDEFLATE_BUILD_TESTS=1 |
| 67 |
- run: cmake --build build --verbose |
| 68 |
- run: DESTDIR=build/install cmake --install build --verbose |
| 69 |
- run: ctest --test-dir build |
| 70 |
- name: Direct compilation without official build system |
| 71 |
run: cc -O2 -Wall -Werror lib/*{,/*}.c programs/{gzip,prog_util,tgetopt}.c -o libdeflate-gzip |
| 72 |
|
| 73 |
windows-msys2-build-and-test: |
| 74 |
name: Build and test (Windows, MSYS2, ${{matrix.sys}}) |
| 75 |
runs-on: windows-latest |
| 76 |
strategy: |
| 77 |
matrix: |
| 78 |
include: |
| 79 |
- { sys: mingw64, env: x86_64 } |
| 80 |
- { sys: mingw32, env: i686 } |
| 81 |
defaults: |
| 82 |
run: |
| 83 |
shell: msys2 {0} |
| 84 |
env: |
| 85 |
CFLAGS: -Werror -DLIBDEFLATE_ENABLE_ASSERTIONS |
| 86 |
steps: |
| 87 |
- uses: actions/checkout@v4 |
| 88 |
- uses: msys2/setup-msys2@v2 |
| 89 |
with: |
| 90 |
msystem: ${{matrix.sys}} |
| 91 |
update: true |
| 92 |
install: > |
| 93 |
make |
| 94 |
mingw-w64-${{matrix.env}}-cc |
| 95 |
mingw-w64-${{matrix.env}}-cmake |
| 96 |
mingw-w64-${{matrix.env}}-ninja |
| 97 |
mingw-w64-${{matrix.env}}-zlib |
| 98 |
# Note: as per the CMake documentation, DESTDIR is unsupported on Windows. |
| 99 |
- run: cmake -B build -G Ninja -DLIBDEFLATE_BUILD_TESTS=1 -DCMAKE_INSTALL_PREFIX=build\install |
| 100 |
- run: cmake --build build --verbose |
| 101 |
- run: cmake --install build --verbose |
| 102 |
- run: ctest --test-dir build |
| 103 |
- name: Direct compilation without official build system |
| 104 |
run: cc -O2 -Wall -Werror -municode lib/*{,/*}.c programs/{gzip,prog_util,tgetopt}.c -o libdeflate-gzip.exe |
| 105 |
|
| 106 |
windows-visualstudio-build-and-test: |
| 107 |
name: Build and test (Windows, ${{matrix.gen}}, ${{matrix.toolset}}, ${{matrix.vs}}) |
| 108 |
strategy: |
| 109 |
matrix: |
| 110 |
include: |
| 111 |
- {os: windows-latest, gen: "Visual Studio 17 2022", toolset: v143, vs: x64, vcpkg: x64-windows} |
| 112 |
- {os: windows-latest, gen: "Visual Studio 17 2022", toolset: ClangCL, vs: x64, vcpkg: x64-windows} |
| 113 |
- {os: windows-latest, gen: "Visual Studio 17 2022", toolset: v143, vs: Win32, vcpkg: x86-windows} |
| 114 |
- {os: windows-latest, gen: "Visual Studio 17 2022", toolset: ClangCL, vs: Win32, vcpkg: x86-windows} |
| 115 |
runs-on: ${{matrix.os}} |
| 116 |
steps: |
| 117 |
- uses: actions/checkout@v4 |
| 118 |
- uses: microsoft/setup-msbuild@v2 |
| 119 |
- run: vcpkg install zlib:${{matrix.vcpkg}} |
| 120 |
- run: > |
| 121 |
echo C:\vcpkg\packages\zlib_${{matrix.vcpkg}}\bin |
| 122 |
| Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append |
| 123 |
# Note: as per the CMake documentation, DESTDIR is unsupported on Windows. |
| 124 |
- run: > |
| 125 |
cmake -B build -G "${{matrix.gen}}" -T ${{matrix.toolset}} |
| 126 |
-A ${{matrix.vs}} -DLIBDEFLATE_BUILD_TESTS=1 |
| 127 |
-DCMAKE_C_FLAGS="/W4 /WX /DLIBDEFLATE_ENABLE_ASSERTIONS" |
| 128 |
-DZLIB_LIBRARY=C:\vcpkg\packages\zlib_${{matrix.vcpkg}}\lib\zlib.lib |
| 129 |
-DZLIB_INCLUDE_DIR=C:\vcpkg\packages\zlib_${{matrix.vcpkg}}\include |
| 130 |
-DCMAKE_INSTALL_PREFIX=build\install |
| 131 |
- run: cmake --build build --verbose --config Debug |
| 132 |
- run: cmake --install build --verbose --config Debug |
| 133 |
- run: ctest --test-dir build -C Debug |
| 134 |
|
| 135 |
windows-visualstudio-build: |
| 136 |
name: Build (Windows, Visual Studio ${{matrix.toolset}}, ${{matrix.platform}}) |
| 137 |
strategy: |
| 138 |
matrix: |
| 139 |
platform: [ARM64, ARM64EC] |
| 140 |
toolset: [v143, ClangCL] |
| 141 |
exclude: # Exclude unsupported combinations |
| 142 |
- platform: ARM64EC |
| 143 |
toolset: ClangCL |
| 144 |
runs-on: windows-latest |
| 145 |
steps: |
| 146 |
- uses: actions/checkout@v4 |
| 147 |
- uses: microsoft/setup-msbuild@v2 |
| 148 |
# Note: as per the CMake documentation, DESTDIR is unsupported on Windows. |
| 149 |
- run: > |
| 150 |
cmake -B build -G "Visual Studio 17 2022" -T ${{matrix.toolset}} |
| 151 |
-A ${{matrix.platform}} -DCMAKE_C_FLAGS="/W4 /WX" |
| 152 |
-DCMAKE_INSTALL_PREFIX=build\install -DCMAKE_SYSTEM_VERSION=10 |
| 153 |
- run: cmake --build build --verbose --config Release |
| 154 |
- run: cmake --install build --verbose --config Release |
| 155 |
|
| 156 |
run-clang-static-analyzer: |
| 157 |
name: Run clang static analyzer |
| 158 |
runs-on: ubuntu-latest |
| 159 |
steps: |
| 160 |
- uses: actions/checkout@v4 |
| 161 |
- name: Install dependencies |
| 162 |
run: | |
| 163 |
sudo apt-get update |
| 164 |
sudo apt-get install -y clang-tools |
| 165 |
- run: scan-build cmake -B build -DLIBDEFLATE_BUILD_TESTS=1 |
| 166 |
- run: scan-build cmake --build build --verbose |
| 167 |
|
| 168 |
run-shellcheck: |
| 169 |
name: Run shellcheck |
| 170 |
runs-on: ubuntu-latest |
| 171 |
steps: |
| 172 |
- uses: actions/checkout@v4 |
| 173 |
- name: Install dependencies |
| 174 |
run: | |
| 175 |
sudo apt-get update |
| 176 |
sudo apt-get install -y shellcheck |
| 177 |
- name: Run shellcheck |
| 178 |
run: shellcheck scripts/*.sh |
| 179 |
|
| 180 |
cross-compile-for-windows: |
| 181 |
name: Cross compile for Windows |
| 182 |
runs-on: ubuntu-latest |
| 183 |
env: |
| 184 |
CFLAGS: -Werror -DLIBDEFLATE_ENABLE_ASSERTIONS |
| 185 |
steps: |
| 186 |
- uses: actions/checkout@v4 |
| 187 |
- name: Install dependencies |
| 188 |
run: | |
| 189 |
sudo apt-get update |
| 190 |
sudo apt-get install -y gcc-mingw-w64-i686 gcc-mingw-w64-x86-64 libz-mingw-w64-dev |
| 191 |
# Unfortunately Ubuntu doesn't have {i686,x86_64}-w64-mingw32-cmake like |
| 192 |
# some distros have, so we have to provide our own toolchain files here. |
| 193 |
- name: 32-bit build |
| 194 |
run: | |
| 195 |
scripts/cmake-helper.sh -DLIBDEFLATE_BUILD_TESTS=1 \ |
| 196 |
-DCMAKE_TOOLCHAIN_FILE=scripts/toolchain-i686-w64-mingw32.cmake |
| 197 |
cmake --build build --verbose |
| 198 |
DESTDIR=build/install cmake --install build --verbose |
| 199 |
- name: 64-bit build |
| 200 |
run: | |
| 201 |
scripts/cmake-helper.sh -DLIBDEFLATE_BUILD_TESTS=1 \ |
| 202 |
-DCMAKE_TOOLCHAIN_FILE=scripts/toolchain-x86_64-w64-mingw32.cmake |
| 203 |
cmake --build build --verbose |
| 204 |
DESTDIR=build/install cmake --install build --verbose |
| 205 |
|
| 206 |
cross-compile-for-android: |
| 207 |
name: Cross compile for ${{matrix.abi}} Android on ${{matrix.os}} |
| 208 |
strategy: |
| 209 |
matrix: |
| 210 |
os: [ubuntu-latest, macos-latest] |
| 211 |
abi: [armeabi-v7a, arm64-v8a, x86, x86_64] |
| 212 |
runs-on: ${{matrix.os}} |
| 213 |
env: |
| 214 |
CFLAGS: -Werror -DLIBDEFLATE_ENABLE_ASSERTIONS |
| 215 |
steps: |
| 216 |
- uses: actions/checkout@v4 |
| 217 |
- run: | |
| 218 |
scripts/cmake-helper.sh \ |
| 219 |
-DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK_LATEST_HOME"/build/cmake/android.toolchain.cmake \ |
| 220 |
-DANDROID_ABI=${{matrix.abi}} \ |
| 221 |
-DANDROID_PLATFORM=28 \ |
| 222 |
-DLIBDEFLATE_BUILD_TESTS=1 |
| 223 |
cmake --build build --verbose |
| 224 |
DESTDIR=build/install cmake --install build --verbose |
| 225 |
|
| 226 |
cpu-features-regression-tests: |
| 227 |
name: Test building adler32.c and crc32.c with various flags |
| 228 |
runs-on: ubuntu-latest |
| 229 |
steps: |
| 230 |
- uses: actions/checkout@v4 |
| 231 |
- name: Install dependencies |
| 232 |
run: | |
| 233 |
sudo apt-get update |
| 234 |
sudo apt-get install -y gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu |
| 235 |
- name: Compile tests |
| 236 |
run: | |
| 237 |
cflags="-O0 -Wall -Werror" |
| 238 |
for file in lib/adler32.c lib/crc32.c; do |
| 239 |
echo "arm32, default options, file=$file" |
| 240 |
arm-linux-gnueabihf-gcc -c $cflags $file |
| 241 |
for arch in armv4 armv4t armv5t armv5te armv5tej armv6 armv6j armv6k \ |
| 242 |
armv6z armv6kz armv6zk armv6t2; do |
| 243 |
echo "arm32, -march=$arch, file=$file" |
| 244 |
arm-linux-gnueabihf-gcc -c -march=$arch -mfpu=vfp -marm $cflags $file |
| 245 |
done |
| 246 |
for arch in armv7 armv7-a armv7ve armv7-r armv7-m armv7e-m; do |
| 247 |
echo "arm32, -march=$arch, file=$file" |
| 248 |
arm-linux-gnueabihf-gcc -c -march=$arch -mfpu=vfp $cflags $file |
| 249 |
done |
| 250 |
echo "arm64, -mcpu=emag" |
| 251 |
aarch64-linux-gnu-gcc -c -mcpu=emag $cflags $file |
| 252 |
done |
| 253 |
|
| 254 |
fuzz-with-libFuzzer: |
| 255 |
name: Fuzz with libFuzzer (${{matrix.target}} ${{matrix.sanitizer}}) |
| 256 |
strategy: |
| 257 |
matrix: |
| 258 |
include: |
| 259 |
- target: deflate_compress |
| 260 |
sanitizer: |
| 261 |
- target: deflate_compress |
| 262 |
sanitizer: --asan |
| 263 |
- target: deflate_compress |
| 264 |
sanitizer: --msan |
| 265 |
- target: deflate_compress |
| 266 |
sanitizer: --ubsan |
| 267 |
- target: deflate_decompress |
| 268 |
sanitizer: |
| 269 |
- target: deflate_decompress |
| 270 |
sanitizer: --asan |
| 271 |
- target: deflate_decompress |
| 272 |
sanitizer: --msan |
| 273 |
- target: deflate_decompress |
| 274 |
sanitizer: --ubsan |
| 275 |
- target: zlib_decompress |
| 276 |
sanitizer: |
| 277 |
- target: gzip_decompress |
| 278 |
sanitizer: |
| 279 |
runs-on: ubuntu-latest |
| 280 |
steps: |
| 281 |
- uses: actions/checkout@v4 |
| 282 |
- name: Install dependencies |
| 283 |
run: | |
| 284 |
sudo apt-get update |
| 285 |
sudo apt-get install -y clang llvm |
| 286 |
- name: Fuzz |
| 287 |
run: | |
| 288 |
scripts/libFuzzer/fuzz.sh --time=120 ${{matrix.sanitizer}} \ |
| 289 |
${{matrix.target}} |