Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve testing support and the CI #708

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/autotools-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: autotools-macos

# autotools build and unit tests of Leptonica on macOS Homebrew.

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
pull_request:
branches: [ master ]
Expand Down Expand Up @@ -51,9 +55,9 @@ jobs:

- name: Make and install Leptonica
run: |
make
make -j
sudo make install

- name: Make and run unit tests
run: |
make check
make -j check
6 changes: 6 additions & 0 deletions .github/workflows/cifuzz.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
name: CIFuzz

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on: [pull_request]

jobs:
Fuzzing:
runs-on: ubuntu-latest
Expand Down
199 changes: 128 additions & 71 deletions .github/workflows/cmake-win64.yml
Original file line number Diff line number Diff line change
@@ -1,148 +1,205 @@
name: cmake-win64

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on: [push, pull_request, workflow_dispatch]

defaults:
run:
shell: bash --noprofile --norc -xeo pipefail {0}

env:
ILOC: d:/a/local

# Note: retry on all errors to avoid transient SEC_E_ILLEGAL_MESSAGE issues…
CURL: curl --location --retry 5 --retry-all-errors --silent --show-error

jobs:
build:
name: cmake-win64
runs-on: windows-latest
steps:
- uses: ilammy/setup-nasm@v1

- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v3
with:
submodules: recursive
- run: git fetch --prune --unshallow --tags
- name: Get the version
id: get_version
run: |
$git_info=$(git describe --tags HEAD)
echo "version=${git_info}" >> $env:GITHUB_OUTPUT
- name: Setup Installation Location

- name: Fetch tags
run: git fetch --prune --unshallow --tags

- name: Setup environment
run: |
mkdir ${{env.ILOC}}
- name: Uninstall Perl
git_info="$(git describe --tags HEAD)"
echo "version=${git_info}" >>$GITHUB_OUTPUT
echo d:/a/gnuplot/bin >>$GITHUB_PATH
echo ${{env.ILOC}}/bin >>$GITHUB_PATH

# Nuke Strawberry Perl's installation as it contains various
# MinGW headers, libraries and binaries that can get picked up
# by configure/CMake and don't necessarily behave correctly when
# not using a MinGW environment.
- name: Nuke Strawberry Perl
run: rm -rf C:/Strawberry

- name: Install nasm
uses: ilammy/setup-nasm@v1

- name: Install gnuplot
run: |
choco uninstall strawberryperl
${{env.CURL}} https://sourceforge.net/projects/gnuplot/files/gnuplot/5.4.8/gp548-win64-mingw.zip/download -o gp548-win64-mingw.zip
unzip -d d:/a -qq gp548-win64-mingw.zip
gnuplot --version

- name: Build and Install zlib-ng
shell: cmd
run: |
git clone --depth 1 https://github.com/zlib-ng/zlib-ng.git
cd zlib-ng
cmake -Bbuild -DCMAKE_PREFIX_PATH=${{env.ILOC}} -DCMAKE_INSTALL_PREFIX=${{env.ILOC}} -DBUILD_SHARED_LIBS=OFF -DZLIB_COMPAT=ON -DZLIB_ENABLE_TESTS=OFF -DINSTALL_UTILS=OFF
cmake -B build -DCMAKE_PREFIX_PATH=${{env.ILOC}} -DCMAKE_INSTALL_PREFIX=${{env.ILOC}} -DBUILD_SHARED_LIBS=OFF -DZLIB_COMPAT=ON -DZLIB_ENABLE_TESTS=OFF -DINSTALL_UTILS=OFF
cmake --build build --config Release --target install
cd ..

- name: Build and Install libpng
shell: cmd
run: |
curl -sSL https://download.sourceforge.net/libpng/lpng1639.zip -o lpng1639.zip
unzip.exe -qq lpng1639.zip
${{env.CURL}} https://download.sourceforge.net/libpng/lpng1639.zip -o lpng1639.zip
unzip -qq lpng1639.zip
cd lpng1639
cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${{env.ILOC}} -DCMAKE_INSTALL_PREFIX=${{env.ILOC}} -DPNG_TESTS=OFF -DPNG_SHARED=OFF
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${{env.ILOC}} -DCMAKE_INSTALL_PREFIX=${{env.ILOC}} -DPNG_TESTS=OFF -DPNG_SHARED=OFF
cmake --build build --config Release --target install
cd ..

- name: Build and Install giflib
shell: cmd
run: |
git clone --depth 1 https://github.com/xbmc/giflib.git
cd giflib
${{env.CURL}} https://sourceforge.net/projects/giflib/files/giflib-5.2.1.tar.gz/download -o giflib-5.2.1.tar.gz
tar xaf giflib-5.2.1.tar.gz
cd giflib-5.2.1
patch -p1 <<\EOF
diff --git c/CMakeLists.txt i/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ i/CMakeLists.txt
@@ -0,0 +1,32 @@
+cmake_minimum_required(VERSION 3.5)
+
+project(giflib VERSION 5.2.1 LANGUAGES C)
+
+if(MSVC)
+ set(CMAKE_DEBUG_POSTFIX "d")
+endif()
+
+add_library(giflib
+ dgif_lib.c
+ egif_lib.c
+ gif_err.c
+ gif_font.c
+ gif_hash.c
+ gif_hash.h
+ gif_lib.h
+ gif_lib_private.h
+ gifalloc.c
+ openbsd-reallocarray.c
+ quantize.c
+)
+
+install(TARGETS giflib EXPORT giflib
+ RUNTIME DESTINATION bin
+ ARCHIVE DESTINATION lib
+ LIBRARY DESTINATION lib
+)
+
+install(FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/gif_lib.h
+ DESTINATION include
+)
diff --git c/gif_hash.h i/gif_hash.h
--- c/gif_hash.h
+++ i/gif_hash.h
@@ -9,7 +9,9 @@ SPDX-License-Identifier: MIT
#ifndef _GIF_HASH_H_
#define _GIF_HASH_H_

+#if !defined(_MSC_VER)
#include <unistd.h>
+#endif
#include <stdint.h>

#define HT_SIZE 8192 /* 12bits = 4096 or twice as big! */
EOF
cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${{env.ILOC}} -DCMAKE_INSTALL_PREFIX=${{env.ILOC}}
cmake --build build --config Release --target install
cd ..


- name: Build and Install libjpeg
shell: cmd
run: |
git clone --depth 1 https://github.com/libjpeg-turbo/libjpeg-turbo.git
cd libjpeg-turbo
cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${{env.ILOC}} -DCMAKE_INSTALL_PREFIX=${{env.ILOC}} -DWITH_TURBOJPEG=OFF
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${{env.ILOC}} -DCMAKE_INSTALL_PREFIX=${{env.ILOC}} -DWITH_TURBOJPEG=OFF
cmake --build build --config Release --target install
cd ..

- name: Build and Install openjpeg
shell: cmd
run: |
git clone --depth 1 https://github.com/uclouvain/openjpeg.git
cd openjpeg
cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${{env.ILOC}} -DCMAKE_INSTALL_PREFIX=${{env.ILOC}}
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${{env.ILOC}} -DCMAKE_INSTALL_PREFIX=${{env.ILOC}}
cmake --build build --config Release --target install
cd ..

- name: Build and Install webp
shell: cmd
run: |
git clone --depth 1 https://chromium.googlesource.com/webm/libwebp
cd libwebp
cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${{env.ILOC}} -DCMAKE_INSTALL_PREFIX=${{env.ILOC}} -DWEBP_BUILD_WEBP_JS=OFF -DWEBP_BUILD_ANIM_UTILS=OFF -DWEBP_BUILD_CWEBP=OFF -DWEBP_BUILD_DWEBP=OFF -DWEBP_BUILD_GIF2WEBP=OFF -DWEBP_BUILD_IMG2WEBP=OFF -DWEBP_BUILD_VWEBP=OFF -DWEBP_BUILD_WEBPMUX=OFF -DWEBP_BUILD_EXTRAS=OFF -DWEBP_BUILD_WEBP_JS=OFF
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${{env.ILOC}} -DCMAKE_INSTALL_PREFIX=${{env.ILOC}} -DWEBP_BUILD_WEBP_JS=OFF -DWEBP_BUILD_ANIM_UTILS=OFF -DWEBP_BUILD_CWEBP=OFF -DWEBP_BUILD_DWEBP=OFF -DWEBP_BUILD_GIF2WEBP=OFF -DWEBP_BUILD_IMG2WEBP=OFF -DWEBP_BUILD_VWEBP=OFF -DWEBP_BUILD_WEBPMUX=OFF -DWEBP_BUILD_EXTRAS=OFF -DWEBP_BUILD_WEBP_JS=OFF
cmake --build build --config Release --target install
cd ..

- name: Build and Install jbigkit
shell: cmd
run: |
git clone --depth 1 https://github.com/zdenop/jbigkit.git
cd jbigkit
cmake -Bbuild -DCMAKE_PREFIX_PATH=${{env.ILOC}} -DCMAKE_INSTALL_PREFIX=${{env.ILOC}} -DBUILD_PROGRAMS=OFF -DBUILD_TOOLS=OFF -DCMAKE_WARN_DEPRECATED=OFF
cmake -B build -DCMAKE_PREFIX_PATH=${{env.ILOC}} -DCMAKE_INSTALL_PREFIX=${{env.ILOC}} -DBUILD_PROGRAMS=OFF -DBUILD_TOOLS=OFF -DCMAKE_WARN_DEPRECATED=OFF
cmake --build build --config Release --target install
cd ..


- name: Build and Install zstd
shell: cmd
run: |
git clone --depth 1 https://github.com/facebook/zstd.git
cd zstd\build\cmake
cmake -Bbuild -DCMAKE_PREFIX_PATH=${{env.ILOC}} -DCMAKE_INSTALL_PREFIX=${{env.ILOC}}
cd zstd/build/cmake
cmake -B build -DCMAKE_PREFIX_PATH=${{env.ILOC}} -DCMAKE_INSTALL_PREFIX=${{env.ILOC}}
cmake --build build --config Release --target install
cd ..

# FIXME: skip lzma build (libtiff lzma build failure)
- name: Build and Install lzma
shell: cmd
if: false
run: |
curl -sSL https://sourceforge.net/projects/lzmautils/files/xz-5.4.3.tar.zst/download -o xz-5.4.3.tar.zst
zstd -d xz-5.4.3.tar.zst
tar xf xz-5.4.3.tar
${{env.CURL}} https://sourceforge.net/projects/lzmautils/files/xz-5.4.3.tar.zst/download -o xz-5.4.3.tar.zst
tar xaf xz-5.4.3.tar.zst
cd xz-5.4.3
cmake -Bbuild -DCMAKE_PREFIX_PATH=${{env.ILOC}} -DCMAKE_INSTALL_PREFIX=${{env.ILOC}} -DBUILD_TESTING=OFF
cmake -B build -DCMAKE_PREFIX_PATH=${{env.ILOC}} -DCMAKE_INSTALL_PREFIX=${{env.ILOC}} -DBUILD_TESTING=OFF
cmake --build build --config Release --target install
cd ..

# FIXME: disable lzma support (build failure)
- name: Build and Install libtiff
shell: cmd
run: |
git clone --depth 1 https://gitlab.com/libtiff/libtiff.git
cd libtiff
cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${{env.ILOC}} -DCMAKE_INSTALL_PREFIX=${{env.ILOC}} -Dtiff-tools=OFF -Dtiff-tests=OFF -Dtiff-contrib=OFF -Dtiff-docs=OFF
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${{env.ILOC}} -DCMAKE_INSTALL_PREFIX=${{env.ILOC}} -Dlzma=OFF -Dtiff-tools=OFF -Dtiff-tests=OFF -Dtiff-contrib=OFF -Dtiff-docs=OFF
cmake --build build --config Release --target install
cd ..

- name: Build and Install leptonica
shell: cmd
run: |
cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${{env.ILOC}} -DCMAKE_INSTALL_PREFIX=${{env.ILOC}} -DSW_BUILD=OFF -DBUILD_PROG=OFF -DBUILD_SHARED_LIBS=ON -DBUILD_PROG=ON
cmake --build build --config Release --target install
- name: Configure
run: cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${{env.ILOC}} -DCMAKE_INSTALL_PREFIX=${{env.ILOC}} -DSW_BUILD=OFF -DBUILD_PROG=ON -DBUILD_SHARED_LIBS=ON -DBUILD_TEST=ON

- name: Test leptonica
shell: cmd
run: |
echo "Testing leptonica..."
${{env.ILOC}}/bin/fileinfo prog/test-rgb.png
- name: Build
run: cmake --build build --config Release

# FIXME: skip `string_reg` test (libtiff lzma build failure)
- name: Test
run: ctest --test-dir build --build-config Release --output-on-failure --parallel 3 --exclude-regex '^string_reg$'

- name: Install
run: cmake --build build --config Release --target install

- name: Test install
run: fileinfo prog/test-rgb.png

- name: Remove not needed tools
shell: cmd
run: >
rm -Rf ${{env.ILOC}}/bin/*.exe

run: rm -f ${{env.ILOC}}/bin/*.exe

- name: Upload Build Results
uses: actions/[email protected]
with:
Expand Down
55 changes: 39 additions & 16 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
name: CMake

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on: [push, pull_request, workflow_dispatch]

defaults:
run:
shell: bash --noprofile --norc -xeo pipefail {0}

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
Expand All @@ -16,36 +24,51 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-12]

steps:
- uses: actions/checkout@v3

- name: Install dependencies on Linux
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y ninja-build
sudo apt-get install -y libwebpdemux2 libwebp-dev
sudo apt-get install -y libopenjp2-7 libopenjp2-7-dev libopenjp2-tools
sudo apt-get install -y libgif-dev
packages=(
gnuplot
libgif-dev
libopenjp2-7-dev
libwebp-dev
ninja-build
)
sudo apt -q update
sudo apt -qy install --no-install-recommends "${packages[@]}"
cmake --version

- name: Install dependencies on macOS
if: runner.os == 'macOS'
run: |
brew install ninja
brew install giflib
brew install openjpeg
brew install webp
packages=(
giflib
gnuplot
ninja
openjpeg
webp
)
brew install "${packages[@]}"
cmake --version


- name: Configure CMake
- name: Configure
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -G Ninja -DSW_BUILD=OFF -DBUILD_PROG=OFF -DBUILD_SHARED_LIBS=ON
# Note: `-DCMAKE_FIND_FRAMEWORK=LAST` is used to avoid a mismatch on macOS between
# the version of the PNG library linked with / used at runtime (provided by brew)
# and the version of the header used at compile time (provided by the system):
# libpng warning: Application built with libpng-1.4.12 but running with 1.6.40
run: cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -G Ninja -DCMAKE_FIND_FRAMEWORK=LAST -DSW_BUILD=OFF -DBUILD_PROG=ON -DBUILD_SHARED_LIBS=ON -DBUILD_TEST=ON

- name: Build
# Build your program with the given configuration
run: sudo cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target install

run: cmake --build build --config ${{env.BUILD_TYPE}}

- name: Test
run: ctest --test-dir build --build-config ${{env.BUILD_TYPE}} --output-on-failure --parallel 3

- name: Install
run: sudo cmake --build build --config ${{env.BUILD_TYPE}} --target install
Loading
Loading