Added msrv 1.85.1 #48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Rust test | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| permissions: | |
| contents: read | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest] | |
| linkage: | |
| - dynamic | |
| rust: [stable] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: ${{ matrix.rust }} | |
| components: clippy | |
| - name: Install OpenCV build dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| build-essential cmake git pkg-config \ | |
| libgtk-3-dev \ | |
| libavcodec-dev libavformat-dev libswscale-dev \ | |
| libtbb-dev \ | |
| clang libclang-dev | |
| # Clone OpenCV repositories with error handling | |
| - name: Clone OpenCV repositories | |
| run: | | |
| set -e # Exit immediately on error | |
| OPENCV_VERSION=4.11.0 | |
| git clone --depth 1 --branch $OPENCV_VERSION https://github.com/opencv/opencv.git | |
| git clone --depth 1 --branch $OPENCV_VERSION https://github.com/opencv/opencv_contrib.git | |
| mkdir -p opencv/build | |
| ls -l opencv/CMakeLists.txt | |
| # Create opencv_install directory (even if empty) | |
| - name: Prepare OpenCV install directory | |
| run: mkdir -p "${{ github.workspace }}/opencv_install" | |
| # Cache OpenCV build (now using workspace paths) | |
| - name: Cache OpenCV build | |
| id: opencv-cache | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| opencv/build | |
| ${{ github.workspace }}/opencv_install | |
| key: opencv-${{ runner.os }}-${{ hashFiles('opencv/CMakeLists.txt') }}-4.11.0 | |
| # Build OpenCV if cache miss | |
| - name: Build OpenCV from source | |
| if: steps.opencv-cache.outputs.cache-hit != 'true' | |
| run: | | |
| set -e # Exit immediately on error | |
| mkdir -p "${{ github.workspace }}/opencv_install" | |
| cd "${{ github.workspace }}/opencv/build" | |
| cmake \ | |
| -DCMAKE_BUILD_TYPE=RELEASE \ | |
| -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/opencv_install" \ | |
| -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ | |
| -DBUILD_opencv_world=ON \ | |
| -DBUILD_TESTS=OFF \ | |
| -DBUILD_EXAMPLES=OFF \ | |
| "${{ github.workspace }}/opencv" | |
| make -j$(nproc) | |
| make install | |
| - name: Set OpenCV env vars | |
| run: | | |
| echo "PKG_CONFIG_PATH=${{ github.workspace }}/opencv_install/lib/pkgconfig" >> $GITHUB_ENV | |
| echo "OPENCV_INCLUDE_PATHS=${{ github.workspace }}/opencv_install/include/opencv4" >> $GITHUB_ENV | |
| echo "OPENCV_LINK_LIBS=opencv_world" >> $GITHUB_ENV | |
| echo "OPENCV_LINK_PATHS=${{ github.workspace }}/opencv_install/lib" >> $GITHUB_ENV | |
| # Add LD_LIBRARY_PATH for runtime linking | |
| echo "LD_LIBRARY_PATH=${{ github.workspace }}/opencv_install/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV | |
| - name: Clippy | |
| run: cargo clippy --all --all-targets --features "clang-runtime" | |
| - name: Build | |
| run: cargo build --verbose --all --all-targets --features "clang-runtime" | |
| - name: Run tests | |
| run: cargo test --verbose --features "clang-runtime" |