Skip to content

feat: add filter skip label processing ability #35

feat: add filter skip label processing ability

feat: add filter skip label processing ability #35

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: build
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "**" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
# Generates binaries for different platforms, which will be uploaded to the Actions page.
# We then manually uplaod them into the Release's assets.
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# Builds for linux
ubuntu-build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
# Install rust
- name: Install rust
run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
# Install opencv
#- name: Install opencv
# run: sudo apt install libopencv-dev clang libclang-dev
- name: Cache OpenCV build
uses: actions/cache@v4
with:
path: |
/opt/opencv
key: ${{ runner.os }}-opencv-linux-${{ hashFiles('**/CMakeLists.txt') }} # 使用 CMakeLists.txt 的哈希作为缓存键
restore-keys: |
${{ runner.os }}-opencv-linux
# Pull opencv source, unzip, configure cmake, build, and install
# Disable image formats like jpeg, png, tiff, as we use rust image crate instead. See https://docs.opencv.org/4.x/db/d05/tutorial_config_reference.html
# Inspired from https://github.com/twistedfall/opencv-rust/issues/364
- name: Install OpenCV static lib
run: |
wget -O opencv.zip https://github.com/opencv/opencv/archive/refs/tags/4.8.1.zip
wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/refs/tags/4.8.1.zip
unzip opencv.zip && rm opencv.zip
unzip opencv_contrib.zip && rm opencv_contrib.zip
mkdir -p build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=NO -DCMAKE_INSTALL_PREFIX=/opt/opencv -DBUILD_DOCS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DWITH_WEBP=OFF -DWITH_JASPER=OFF -DWITH_OPENEXR=OFF -DWITH_V4L=OFF -DBUILD_opencv_java=OFF -DBUILD_opencv_python=OFF -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.8.1/modules ../opencv-4.8.1
cmake --build . --target install --config Release --parallel 8
cmake --install . --prefix /opt/opencv
cd ..
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
# Note: OPENCV_LINK_LIBS ordering matters for linux. Put lower level deps after higher level. See https://answers.opencv.org/question/186124/undefined-reference-to-cvsoftdoubleoperator/
# libclang files are in /usr/lib/llvm-##/lib. We symlink it to one of the opencv_link_paths
# OpenCV-rust looks for "opencv2/core/version.hpp" for the OpenCV version: https://github.com/twistedfall/opencv-rust/issues/368
# which is under /<install-prefix>/include/opencv4 for linux
# Build
- name: Build
run: |
export OPENCV_LINK_LIBS="opencv_videoio,opencv_imgcodecs,opencv_imgproc,opencv_ximgproc,opencv_core"
export OPENCV_LINK_PATHS=/opt/opencv/lib,/opt/opencv/lib/opencv4/3rdparty,/usr/lib/x86_64-linux-gnu
export OPENCV_INCLUDE_PATHS=/opt/opencv/include,/opt/opencv/include/opencv4
sudo ln -s /usr/lib/llvm-15/lib/libclang.so.1 /usr/lib/x86_64-linux-gnu/libclang.so
ls -R /opt/opencv
ls -R /usr/lib
cargo build --release --target x86_64-unknown-linux-musl
# Upload artifact: https://github.com/actions/upload-artifact
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: imagetools
path: target/release/imagetools
retention-days: 14
windows-build:
# The type of runner that the job will run on
runs-on: windows-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
# Install rust
- name: Install rust
run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
- name: Chocolatey Action
# You may pin to the exact commit or the version.
# uses: crazy-max/ghaction-chocolatey@0e015857dd851f84fcb7fb53380eb5c4c8202333
uses: crazy-max/[email protected]
with:
# Arguments to pass to Chocolatey
# don't install opencv here as we build the staticlib below
args: install llvm wget strawberryperl
# Docker image to use
#image: # optional, default is ghcr.io/crazy-max/ghaction-chocolatey
- name: Cache OpenCV build
uses: actions/cache@v4
with:
path: |
D:/opt/opencv
key: ${{ runner.os }}-opencv-windows-${{ hashFiles('**/CMakeLists.txt') }} # 使用 CMakeLists.txt 的哈希作为缓存键
restore-keys: |
${{ runner.os }}-opencv-windows
# Note: in order to set config profile to Release and use a prefix path, we have to separate cmake steps for building/installing. CMake nuances...
# See https://stackoverflow.com/questions/19024259/how-to-change-the-build-type-to-release-mode-in-cmake, https://stackoverflow.com/questions/50028570/is-it-possible-to-build-cmake-projects-directly-using-msbuildtools, https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX.html
# Pull opencv source, unzip, configure cmake, build, and install
# Disable image formats like jpeg, png, tiff, as we use rust image crate instead. See https://docs.opencv.org/4.x/db/d05/tutorial_config_reference.html
# Inspired from https://github.com/twistedfall/opencv-rust/issues/364
- name: Install OpenCV static lib
run: |
if (-Not (Test-Path "D:/opt/opencv")) {
wget -O opencv.zip https://github.com/opencv/opencv/archive/refs/tags/4.8.1.zip
wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/refs/tags/4.8.1.zip
unzip opencv.zip
rm opencv.zip
unzip opencv_contrib.zip
rm opencv_contrib.zip
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=NO -DCMAKE_INSTALL_PREFIX="D:/opt/opencv" -DOPENCV_BUILD_3RDPARTY_LIBS=ON -DBUILD_DOCS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_opencv_java=OFF -DBUILD_opencv_python=OFF -DOPENCV_EXTRA_MODULES_PATH="../opencv_contrib-4.8.1/modules" ../opencv-4.8.1
cmake --build . --target install --config Release --parallel 8
cmake --install . --prefix D:/opt/opencv
cd ..
} else {
Write-Host "Using cached OpenCV build"
}
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
- uses: Swatinem/rust-cache@v2
with:
cache-directories: |
"D:/opt/opencv"
# OPENCV_LINK_LIBS includes both opencv modules and 3rdparty. Note: 3rdparty libs may be named differently on different platforms
# OPENCV_LINK_PATHS points to the installed staticlib folder after cmake install
# OPENCV_INCLUDE_PATHS points to installed include folder after cmake install
# OPENCV_MSVC_CRT is for CRT library to be static or dynamic using windows MSVC: https://github.com/twistedfall/opencv-rust/blob/master/README.md#troubleshooting
# Build
- name: Build
#run: $env:OPENCV_LINK_LIBS=$(Get-ChildItem -Path C:\tools -Recurse -Filter 'opencv_world*.lib' | Select-Object -first 1 | Select-Object -ExpandProperty Name); $env:OPENCV_LINK_PATHS=$(Get-ChildItem -Path C:\tools -Recurse -Filter 'opencv_world*.lib' | Select-Object -first 1 | Select-Object -ExpandProperty FullName | Split-Path -parent); $env:OPENCV_INCLUDE_PATHS="C:\tools\opencv\build\include"; cargo build --release
run: |
$env:OPENCV_LINK_LIBS="opencv_core481,opencv_videoio481,opencv_imgcodecs481,opencv_imgproc481,ippiw,ittnotify,ippicvmt,zlib,IlmImf,libjpeg-turbo,libopenjp2,libpng,libtiff,libwebp"
$env:OPENCV_LINK_PATHS="D:/opt/opencv/staticlib"
$env:OPENCV_INCLUDE_PATHS="D:/opt/opencv/include"
$env:OPENCV_MSVC_CRT="static"
cargo build --release
# Upload artifact: https://github.com/actions/upload-artifact
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: imagetools
path: |
target/release/imagetools.exe
target/release/imagetools.pdb
retention-days: 14