Skip to content

Commit

Permalink
Improve CI
Browse files Browse the repository at this point in the history
  • Loading branch information
twistedfall committed Jul 4, 2024
1 parent 636ef9a commit b1c7e0f
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 34 deletions.
26 changes: 5 additions & 21 deletions .github/workflows/opencv-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:
- macos-13
opencv-version:
- 3.4.20
- 4.9.0
- 4.10.0
linkage:
- dynamic
include:
- os-image: ubuntu-22.04
opencv-version: 4.9.0
opencv-version: 4.10.0
linkage: static
runs-on: ${{ matrix.os-image }}
env:
Expand All @@ -47,14 +47,10 @@ jobs:
key: build-${{ matrix.opencv-version }}-${{ matrix.linkage }}-${{ matrix.os-image }}

- name: Install dependencies
env:
OS_FAMILY: ${{ runner.os }}
run: ci/install.sh
shell: bash

- name: Test project
env:
OS_FAMILY: ${{ runner.os }}
run: ci/script.sh
shell: bash

Expand All @@ -67,7 +63,7 @@ jobs:
- windows-2022
- macos-14
vcpkg-version:
- 2024.04.26
- 2024.07.12
runs-on: ${{ matrix.os-image }}
env:
VCPKG_VERSION: ${{ matrix.vcpkg-version }}
Expand All @@ -83,14 +79,10 @@ jobs:
key: vcpkg-${{ matrix.vcpkg-version }}-${{ matrix.os-image }}

- name: Install dependencies
env:
OS_FAMILY: ${{ runner.os }}
run: ci/install.sh
shell: bash

- name: Test project
env:
OS_FAMILY: ${{ runner.os }}
run: ci/script.sh
shell: bash

Expand All @@ -102,7 +94,7 @@ jobs:
- windows-2022
version:
- opencv: 3.4.16
- opencv: 4.9.0
- opencv: 4.10.0
include:
- os-image: ubuntu-22.04
version:
Expand All @@ -125,14 +117,10 @@ jobs:
- uses: mozilla-actions/[email protected]

- name: Install dependencies
env:
OS_FAMILY: ${{ runner.os }}
run: ci/install.sh
shell: bash

- name: Test project
env:
OS_FAMILY: ${{ runner.os }}
run: ci/script.sh
shell: bash

Expand All @@ -149,7 +137,7 @@ jobs:
msrv:
runs-on: ubuntu-20.04
env:
OPENCV_VERSION: 4.9.0
OPENCV_VERSION: 4.10.0
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
CMAKE_C_COMPILER_LAUNCHER: "sccache"
Expand Down Expand Up @@ -177,13 +165,9 @@ jobs:
toolchain: ${{ steps.metadata.outputs.msrv }}

- name: Install dependencies
env:
OS_FAMILY: ${{ runner.os }}
run: ci/install.sh
shell: bash

- name: Check project
env:
OS_FAMILY: ${{ runner.os }}
run: ci/msrv.sh
shell: bash
3 changes: 2 additions & 1 deletion ci/install-ubuntu-vcpkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ fi
sudo apt-get update
sudo apt-get install -y clang libharfbuzz0b git curl zip unzip tar bison gperf libx11-dev libxft-dev libxext-dev \
libgles2-mesa-dev autoconf libtool build-essential libxrandr-dev libxi-dev libxcursor-dev libxdamage-dev libxinerama-dev \
libdbus-1-dev libxtst-dev sudo
libdbus-1-dev libxtst-dev sudo python3-jinja2 cmake

# workaround to make clang_sys crate detect installed libclang
sudo ln -fs libclang.so.1 /usr/lib/llvm-14/lib/libclang.so

export VCPKG_ROOT="$HOME/build/vcpkg"
export VCPKG_DISABLE_METRICS=1
if [[ -e "$VCPKG_ROOT" && ! -e "$VCPKG_ROOT/.git" ]]; then
rm -rf "$VCPKG_ROOT"
fi
Expand Down
2 changes: 1 addition & 1 deletion ci/install-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ BUILD_FLAGS="
sudo apt-get -y install build-essential cmake

if [[ "${OPENCV_LINKAGE:-dynamic}" == "static" ]]; then # static build
# bring back -D BUILD_TBB=ON when updated to Ubuntu-24.04 (https://github.com/opencv/opencv/issues/25187)
BUILD_FLAGS="$BUILD_FLAGS
-D BUILD_JPEG=ON
-D BUILD_OPENJPEG=ON
-D BUILD_PNG=ON
-D BUILD_SHARED_LIBS=OFF
-D BUILD_TBB=ON
-D BUILD_TIFF=ON
-D BUILD_WEBP=ON
-D BUILD_ZLIB=ON
Expand Down
1 change: 1 addition & 0 deletions ci/install-windows-vcpkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ rm -rf "$VCPKG_INSTALLATION_ROOT"
choco install -y llvm --version "$CHOCO_LLVM_VERSION"

export VCPKG_ROOT="$HOME/build/vcpkg"
export VCPKG_DISABLE_METRICS=1
if [[ -e "$VCPKG_ROOT" && ! -e "$VCPKG_ROOT/.git" ]]; then
rm -rf "$VCPKG_ROOT"
fi
Expand Down
20 changes: 16 additions & 4 deletions ci/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,36 @@ set -xeu

ci_dir="$(dirname "$0")"

if [[ "$OS_FAMILY" == "Linux" ]]; then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
os_family="Linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
os_family="macOS"
elif [[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
os_family="Windows"
elif [[ "$OSTYPE" == "freebsd"* ]]; then
exit "FreeBSD is not supported"
else
exit "Unknown OS: $OSTYPE"
fi

if [[ "$os_family" == "Linux" ]]; then
# free up disk space in Github Actions image: https://github.com/actions/runner-images/issues/2840
sudo rm -rf /usr/share/dotnet /opt/ghc /usr/local/share/boost
if [[ "${VCPKG_VERSION:-}" != "" ]]; then # vcpkg build
"$ci_dir/install-ubuntu-vcpkg.sh"
else
"$ci_dir/install-ubuntu.sh"
fi
elif [[ "$OS_FAMILY" == "macOS" ]]; then
elif [[ "$os_family" == "macOS" ]]; then
if [[ "${BREW_OPENCV_VERSION:-}" != "" ]]; then # brew build
"$ci_dir/install-macos-brew.sh"
elif [[ "${VCPKG_VERSION:-}" != "" ]]; then # vcpkg build
"$ci_dir/install-macos-vcpkg.sh"
else
"$ci_dir/install-macos-framework.sh"
fi
elif [[ "$OS_FAMILY" == "Windows" ]]; then
export CHOCO_LLVM_VERSION=18.1.6
elif [[ "$os_family" == "Windows" ]]; then
export CHOCO_LLVM_VERSION=18.1.8
if [[ "${VCPKG_VERSION:-}" != "" ]]; then # vcpkg build
"$ci_dir/install-windows-vcpkg.sh"
else # chocolatey build
Expand Down
25 changes: 20 additions & 5 deletions ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@

set -xeu

if [[ "$OS_FAMILY" == "Windows" ]]; then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
os_family="Linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
os_family="macOS"
elif [[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
os_family="Windows"
elif [[ "$OSTYPE" == "freebsd"* ]]; then
exit "FreeBSD is not supported"
else
exit "Unknown OS: $OSTYPE"
fi

if [[ "$os_family" == "Windows" ]]; then
export PATH="/C/Program Files/LLVM/bin:$PATH"
export LIBCLANG_PATH="C:/Program Files/LLVM/bin"
if [[ "${VCPKG_VERSION:-}" != "" ]]; then # vcpkg build
Expand All @@ -18,12 +30,13 @@ if [[ "$OS_FAMILY" == "Windows" ]]; then
fi
echo "=== Installed chocolatey packages:"
choco list
elif [[ "$OS_FAMILY" == "macOS" ]]; then
elif [[ "$os_family" == "macOS" ]]; then
xcode_select="xcode-select" # IDEA code highlighting workaround
toolchain_path="$($xcode_select --print-path)/Toolchains/XcodeDefault.xctoolchain/"
export DYLD_FALLBACK_LIBRARY_PATH="$toolchain_path/usr/lib/"
if [[ "${VCPKG_VERSION:-}" != "" ]]; then # vcpkg build
export VCPKG_ROOT="$HOME/build/vcpkg"
export VCPKG_DISABLE_METRICS=1
echo "=== Installed vcpkg packages:"
"$VCPKG_ROOT/vcpkg" list
elif [[ "${BREW_OPENCV_VERSION:-}" != "" ]]; then # brew build
Expand All @@ -36,20 +49,22 @@ elif [[ "$OS_FAMILY" == "macOS" ]]; then
fi
echo "=== Installed brew packages:"
brew list --versions
elif [[ "$OS_FAMILY" == "Linux" ]]; then
elif [[ "$os_family" == "Linux" ]]; then
if [[ "${VCPKG_VERSION:-}" != "" ]]; then # vcpkg build
export VCPKG_ROOT="$HOME/build/vcpkg"
echo "=== Installed vcpkg packages:"
"$VCPKG_ROOT/vcpkg" list
# fixes linking issue that started happening since 2024-07-04
export OPENCV_LINK_LIBS="+freetype,bz2,brotlidec,brotlicommon"
else
if [[ "${OPENCV_LINKAGE:-dynamic}" == "static" ]]; then # static build
export OPENCV_LINK_LIBS=opencv_gapi,opencv_highgui,opencv_objdetect,opencv_dnn,opencv_videostab,opencv_calib3d,opencv_features2d,opencv_stitching,opencv_flann,opencv_videoio,opencv_rgbd,opencv_aruco,opencv_video,opencv_ml,opencv_imgcodecs,opencv_imgproc,opencv_core,ade,ittnotify,tbb,liblibwebp,liblibtiff,liblibjpeg-turbo,liblibpng,liblibopenjp2,ippiw,ippicv,liblibprotobuf,quirc,zlib
export OPENCV_LINK_LIBS=opencv_gapi,opencv_highgui,opencv_objdetect,opencv_dnn,opencv_videostab,opencv_calib3d,opencv_features2d,opencv_stitching,opencv_flann,opencv_videoio,opencv_rgbd,opencv_aruco,opencv_video,opencv_ml,opencv_imgcodecs,opencv_imgproc,opencv_core,ade,ittnotify,liblibwebp,liblibtiff,liblibjpeg-turbo,liblibpng,liblibopenjp2,ippiw,ippicv,liblibprotobuf,quirc,zlib
fi
fi
fi

# remove tests and examples that require the latest OpenCV version so that they don't fail due to missing modules
if [[ "${OPENCV_VERSION:-}" != "4.9.0" ]]; then
if [[ "${OPENCV_VERSION:-}" != "4.10.0" ]]; then
rm -vf tests/*_only_latest_opencv.rs
rm -vf examples/dnn_face_detect.rs examples/text_detection.rs
fi
Expand Down
2 changes: 0 additions & 2 deletions tools/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ set -eu
script_dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
cd "$script_dir/.."

export OS_FAMILY="linux"

(
. "$script_dir/env-34.sh"
ci/script.sh
Expand Down

0 comments on commit b1c7e0f

Please sign in to comment.