diff --git a/.github/workflows/OCV-Contrib-PR-4.x-O22-CANN.yaml b/.github/workflows/OCV-Contrib-PR-4.x-O22-CANN.yaml new file mode 100644 index 00000000..baec6a18 --- /dev/null +++ b/.github/workflows/OCV-Contrib-PR-4.x-O22-CANN.yaml @@ -0,0 +1,120 @@ +name: OCV Contrib PR:4.x O22 CANN + +on: + pull_request: + branches: + - main + paths: + - '.github/workflows/OCV-Contrib-PR-4.x-O22-CANN.yaml' + workflow_call: + +concurrency: + group: OCV-Contrib-PR-4.x-O22-CANN-${{ github.ref }} + cancel-in-progress: true + +env: + EXTRA_CMAKE_OPTIONS: '-DBUILD_DOCS=ON -DPYTHON_DEFAULT_EXECUTABLE=/usr/bin/python3 -DOPENCV_DOWNLOAD_PATH=/home/ci/binaries_cache -DBUILD_EXAMPLES=ON -DOPENCV_ENABLE_NONFREE=ON -DWITH_CANN=ON' + PR_AUTHOR: ${{ github.event.pull_request.user.login }} + PR_AUTHOR_FORK: ${{ github.event.pull_request.head.repo.full_name }} + SOURCE_BRANCH_NAME: ${{ github.head_ref }} + TARGET_BRANCH_NAME: ${{ github.base_ref }} + GIT_CACHE_DOCKER: '/home/ci/git_cache' + OPENCV_TEST_DATA_PATH: '/home/ci/opencv_extra/testdata' + OPENCV_CONTRIB_DOCKER_WORKDIR: '/home/ci/opencv_contrib' + PARALLEL_JOBS: 8 + +jobs: + BuildAndTest: + runs-on: opencv-cn-openeuler-ascend310-x86-64 + defaults: + run: + shell: bash + container: + image: quay.io/opencv-ci/opencv-openeuler-22.03.sp2-ascend310:20231107 + options: --device /dev/davinci0 --device /dev/davinci_manager --device /dev/devmm_svm --device /dev/hisi_hdc --env-file /home/opencv-cn/git_cache/proxy + volumes: + - /home/opencv-cn/git_cache:/home/ci/git_cache + - /home/opencv-cn/ci_cache/opencv:/home/ci/.ccache + - /home/opencv-cn/binaries_cache:/home/ci/binaries_cache + - /usr/local/dcmi:/usr/local/dcmi + - /usr/local/bin/npu-smi:/usr/local/bin/npu-smi + - /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/ + + steps: + - name: Brief system information + timeout-minutes: 60 + run: bash ${{ env.GIT_CACHE_DOCKER }}/print_system_information.sh + - name: Define proper HOME path + timeout-minutes: 60 + run: echo "HOME=/home/ci" >> $GITHUB_ENV + - name: Setup infra environment + timeout-minutes: 60 + if: ${{ github.event.repository.name == 'ci-gha-workflow' }} + run: echo "TARGET_BRANCH_NAME=4.x" >> $GITHUB_ENV + - name: Setup test environment + if: ${{ github.event.repository.name != 'ci-gha-workflow' }} + run: echo "EXTRA_GTEST_OPTIONS=--skip_unstable=1" >> $GITHUB_ENV + - name: PR info + timeout-minutes: 60 + run: | + echo "PR Author: ${{ env.PR_AUTHOR }}" + echo "PR Author fork: ${{ env.PR_AUTHOR_FORK }}" + echo "Source branch name: ${{ env.SOURCE_BRANCH_NAME }}" + echo "Target branch name: ${{ env.TARGET_BRANCH_NAME }}" + - name: Clean + timeout-minutes: 60 + run: find ${{ env.OPENCV_CONTRIB_DOCKER_WORKDIR }} -mindepth 1 -delete + - name: Fetch opencv_contrib + timeout-minutes: 60 + run: git clone --branch ${{ env.TARGET_BRANCH_NAME }} --reference ${{ env.GIT_CACHE_DOCKER }}/opencv_contrib.git https://github.com/opencv/opencv_contrib.git ${{ env.OPENCV_CONTRIB_DOCKER_WORKDIR }} + - name: Merge opencv_contrib with ${{ env.SOURCE_BRANCH_NAME }} branch + timeout-minutes: 60 + if: ${{ github.event.repository.name != 'ci-gha-workflow' }} + run: | + cd ${{ env.OPENCV_CONTRIB_DOCKER_WORKDIR }} + git pull -v "https://github.com/${{ env.PR_AUTHOR_FORK }}" "${{ env.SOURCE_BRANCH_NAME }}" + - name: Clone opencv + timeout-minutes: 60 + run: git clone --single-branch --branch ${{ env.TARGET_BRANCH_NAME }} --reference ${{ env.GIT_CACHE_DOCKER }}/opencv.git https://github.com/opencv/opencv.git $HOME/opencv + - name: Merge opencv with ${{ env.SOURCE_BRANCH_NAME }} branch + timeout-minutes: 60 + if: ${{ github.event.repository.name != 'ci-gha-workflow' }} + run: | + OPENCV_FORK=$(git ls-remote --heads "https://github.com/${{ env.PR_AUTHOR }}/opencv" "${{ env.SOURCE_BRANCH_NAME }}") || true + if [[ ! -z "$OPENCV_FORK" ]]; then + echo "Merge opencv with ${{ env.SOURCE_BRANCH_NAME }} branch" + cd $HOME/opencv + git pull -v "https://github.com/${{ env.PR_AUTHOR }}/opencv" "${{ env.SOURCE_BRANCH_NAME }}" + else + echo "No merge since ${{ env.PR_AUTHOR }}/opencv does not have branch ${{ env.SOURCE_BRANCH_NAME }}" + fi + - name: Clone opencv_extra + timeout-minutes: 60 + run: git clone --single-branch --branch ${{ env.TARGET_BRANCH_NAME }} --reference ${{ env.GIT_CACHE_DOCKER }}/opencv_extra.git https://github.com/opencv/opencv_extra.git $HOME/opencv_extra + - name: Merge opencv_extra with ${{ env.SOURCE_BRANCH_NAME }} branch + timeout-minutes: 60 + if: ${{ github.event.repository.name != 'ci-gha-workflow' }} + run: | + OPENCV_EXTRA_FORK=$(git ls-remote --heads "https://github.com/${{ env.PR_AUTHOR }}/opencv_extra" "${{ env.SOURCE_BRANCH_NAME }}") || true + if [[ ! -z "$OPENCV_EXTRA_FORK" ]]; then + echo "Merge opencv_extra with ${{ env.SOURCE_BRANCH_NAME }} branch" + cd $HOME/opencv_extra + git pull -v "https://github.com/${{ env.PR_AUTHOR }}/opencv_extra" "${{ env.SOURCE_BRANCH_NAME }}" + else + echo "No merge since ${{ env.PR_AUTHOR }}/opencv_extra does not have branch ${{ env.SOURCE_BRANCH_NAME }}" + fi + - name: Configure OpenCV + timeout-minutes: 60 + run: | + cd $HOME/build + cmake -G Ninja ${{ env.EXTRA_CMAKE_OPTIONS }} -DOPENCV_EXTRA_MODULES_PATH=${{ env.OPENCV_CONTRIB_DOCKER_WORKDIR }}/modules $HOME/opencv + - name: Build OpenCV + timeout-minutes: 60 + id: build-opencv-contrib + run: | + cd $HOME/build + cmake --build . --target opencv_test_cannops -j ${{ env.PARALLEL_JOBS }} | tee $HOME/build/build-log.txt + - name: Accuracy:cannops + timeout-minutes: 60 + if: ${{ always() && steps.build-opencv-contrib.outcome == 'success' }} + run: cd $HOME/build && xvfb-run -a bin/opencv_test_cannops --test_threads=${{ env.PARALLEL_JOBS }} ${{ env.EXTRA_GTEST_OPTIONS }}