Reduce pull request cache churn #658
Workflow file for this run
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: Linux ARM64 | |
| on: | |
| pull_request: | |
| types: [synchronize, opened] | |
| push: | |
| branches: | |
| - main | |
| env: | |
| DEBIAN_FRONTEND: noninteractive | |
| OPENCV_VERSION: 5.0.0 | |
| CACHE_VERSION: "2" | |
| jobs: | |
| build: | |
| name: Linux (arm64) | |
| runs-on: ubuntu-24.04-arm | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| submodules: true | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update -y | |
| sudo apt-get install -y --no-install-recommends \ | |
| apt-transport-https \ | |
| software-properties-common \ | |
| ca-certificates \ | |
| g++ \ | |
| make \ | |
| cmake \ | |
| libtbb-dev \ | |
| libatlas-base-dev \ | |
| libgtk-3-dev \ | |
| libavcodec-dev \ | |
| libavformat-dev \ | |
| libswscale-dev \ | |
| libdc1394-dev \ | |
| libxine2-dev \ | |
| libv4l-dev \ | |
| libtheora-dev \ | |
| libvorbis-dev \ | |
| libxvidcore-dev \ | |
| libopencore-amrnb-dev \ | |
| libopencore-amrwb-dev \ | |
| libx264-dev \ | |
| libtesseract-dev \ | |
| ninja-build | |
| - name: Restore OpenCV cache | |
| id: opencv-cache | |
| uses: actions/cache/restore@v6 | |
| with: | |
| path: | | |
| ${{ github.workspace }}/opencv_artifacts/include | |
| ${{ github.workspace }}/opencv_artifacts/lib | |
| key: opencv-arm-v${{ env.CACHE_VERSION }}-${{ env.OPENCV_VERSION }}-${{ hashFiles('cmake/opencv_build_options.cmake', '.github/workflows/linux-arm64.yml') }} | |
| - name: Configure OpenCV | |
| if: steps.opencv-cache.outputs.cache-hit != 'true' | |
| run: | | |
| # Disable the generic ASM language so OpenCV 5's vendored MLAS skips its | |
| # ASM kernels and reports MLAS unavailable (DNN falls back to its | |
| # built-in SGEMM). On aarch64 the MLAS FP16/GQA path references | |
| # MlasHGemmSupported(), which OpenCV 5.0.0 declares and calls but never | |
| # defines, breaking the extern link with an undefined reference. | |
| # GCC 12+ builds libjpeg-turbo/libpng SIMD via NEON intrinsics (not GAS), | |
| # so dropping the ASM compiler does not affect the image codecs here. | |
| cmake \ | |
| -G Ninja \ | |
| -C cmake/opencv_build_options.cmake \ | |
| -S opencv \ | |
| -B opencv/build \ | |
| -D OPENCV_EXTRA_MODULES_PATH=${GITHUB_WORKSPACE}/opencv_contrib/modules \ | |
| -D CMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/opencv_artifacts \ | |
| -D CMAKE_ASM_COMPILER="" \ | |
| 2>&1 | tee /tmp/opencv-configure.log | |
| - name: Verify OpenCV cmake features | |
| if: steps.opencv-cache.outputs.cache-hit != 'true' | |
| run: | | |
| log=/tmp/opencv-configure.log | |
| fail=0 | |
| for feature in Tesseract FFMPEG JPEG PNG TIFF WEBP; do | |
| val=$(grep -E "^--\s+${feature}:\s+" "$log" | tail -1 | sed -E "s/^.*${feature}:[[:space:]]+//") | |
| if [[ -n "$val" ]] && [[ "$val" != NO* ]]; then | |
| echo "OK: $feature = $val" | |
| else | |
| echo "MISSING or DISABLED: $feature" | |
| grep -iE "${feature}" "$log" | tail -3 || true | |
| fail=1 | |
| fi | |
| done | |
| [ "$fail" -eq 0 ] | |
| - name: Build OpenCV | |
| if: steps.opencv-cache.outputs.cache-hit != 'true' | |
| run: | | |
| cmake --build opencv/build -j 3 | |
| cmake --install opencv/build | |
| sudo ldconfig | |
| ls | |
| - name: Save OpenCV cache | |
| if: steps.opencv-cache.outputs.cache-hit != 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| uses: actions/cache/save@v6 | |
| with: | |
| path: | | |
| ${{ github.workspace }}/opencv_artifacts/include | |
| ${{ github.workspace }}/opencv_artifacts/lib | |
| key: opencv-arm-v${{ env.CACHE_VERSION }}-${{ env.OPENCV_VERSION }}-${{ hashFiles('cmake/opencv_build_options.cmake', '.github/workflows/linux-arm64.yml') }} | |
| - name: Build OpenCvSharpExtern | |
| run: | | |
| cmake \ | |
| -G Ninja \ | |
| -S src \ | |
| -B src/build \ | |
| -D CMAKE_BUILD_TYPE=Release \ | |
| -D CMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/opencv_artifacts | |
| cmake --build src/build -j | |
| ls src/build/OpenCvSharpExtern | |
| cp src/build/OpenCvSharpExtern/libOpenCvSharpExtern.so ${GITHUB_WORKSPACE}/packaging/nuget/ | |
| - name: Check OpenCvSharpExtern | |
| run: | | |
| cd ${GITHUB_WORKSPACE}/packaging/nuget/ | |
| ldd libOpenCvSharpExtern.so | |
| nm libOpenCvSharpExtern.so | |
| echo -ne "#include <stdio.h> \n int core_Mat_sizeof(); int main(){ int i = core_Mat_sizeof(); printf(\"sizeof(Mat) = %d\", i); return 0; }" > test.c | |
| gcc -I./ -L./ test.c -o test -lOpenCvSharpExtern | |
| LD_LIBRARY_PATH=. ./test | |
| - name: Install .NET | |
| uses: actions/setup-dotnet@v6 | |
| with: | |
| dotnet-version: '10.0.x' | |
| - name: Create NuGet package | |
| env: | |
| BETA: "-beta" | |
| run: | | |
| yyyymmdd=`date '+%Y%m%d'` | |
| echo $yyyymmdd | |
| version="${OPENCV_VERSION}.${yyyymmdd}${BETA}" | |
| echo "Package version: $version" | |
| cd ${GITHUB_WORKSPACE} | |
| dotnet pack packaging/nuget/OpenCvSharp5.runtime.linux-arm64.csproj -o ${GITHUB_WORKSPACE}/artifacts_arm64 -p:Version=$version | |
| dotnet pack packaging/nuget/OpenCvSharp5.runtime.linux-arm.csproj -o ${GITHUB_WORKSPACE}/artifacts_arm64 -p:Version=$version --no-restore | |
| ls ${GITHUB_WORKSPACE}/artifacts_arm64 | |
| - uses: actions/upload-artifact@v7 | |
| with: | |
| name: artifacts_linux_arm64 | |
| path: artifacts_arm64 | |
| - name: Test | |
| run: | | |
| cd ${GITHUB_WORKSPACE}/test/OpenCvSharp.Tests | |
| dotnet build -c Release -f net10.0 | |
| cp ${GITHUB_WORKSPACE}/packaging/nuget/libOpenCvSharpExtern.so ${GITHUB_WORKSPACE}/test/OpenCvSharp.Tests/bin/Release/net10.0/ | |
| cp ${GITHUB_WORKSPACE}/packaging/nuget/libOpenCvSharpExtern.so ${GITHUB_WORKSPACE}/test/OpenCvSharp.Tests/ | |
| sudo cp ${GITHUB_WORKSPACE}/packaging/nuget/libOpenCvSharpExtern.so /usr/lib/ | |
| # Preserve the executed-test sequence and a native dump when the test host crashes, | |
| # including failures that happen during process teardown after all tests complete. | |
| LD_LIBRARY_PATH=. dotnet test --project OpenCvSharp.Tests.csproj -c Release -f net10.0 --runtime linux-arm64 \ | |
| --results-directory TestResults --report-xunit-trx --report-xunit-trx-filename test-results.trx \ | |
| --crashdump --crashdump-type Full < /dev/null | |
| - name: Upload crash dumps on failure | |
| if: failure() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: linux-arm64-crash-dumps | |
| path: test/OpenCvSharp.Tests/TestResults/ | |
| if-no-files-found: ignore | |
| - name: Test Avalonia extensions | |
| run: | | |
| cd ${GITHUB_WORKSPACE}/test/OpenCvSharp.Tests.Avalonia | |
| dotnet build -c Release -f net10.0 | |
| cp ${GITHUB_WORKSPACE}/packaging/nuget/libOpenCvSharpExtern.so ${GITHUB_WORKSPACE}/test/OpenCvSharp.Tests.Avalonia/bin/Release/net10.0/ | |
| LD_LIBRARY_PATH=. dotnet test --project OpenCvSharp.Tests.Avalonia.csproj -c Release -f net10.0 --runtime linux-arm64 < /dev/null |