From 0cd2bef45ea9198353aec825d4e194aa1aee1439 Mon Sep 17 00:00:00 2001 From: huafengchun Date: Tue, 7 Nov 2023 17:04:33 +0800 Subject: [PATCH 1/4] Added CI pipeline with OpenEuler22.03.SP2 and Ascend310 --- .../OCV-Contrib-PR-4.x-O22-CANN.yaml | 121 ++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 .github/workflows/OCV-Contrib-PR-4.x-O22-CANN.yaml 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..a08172cd --- /dev/null +++ b/.github/workflows/OCV-Contrib-PR-4.x-O22-CANN.yaml @@ -0,0 +1,121 @@ +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: + if: contains(github.event.pull_request.labels.*.name, 'category:cann') + runs-on: opencv-cn-openeuler-ascend310-x86-64 + defaults: + run: + shell: bash + container: + image: quay.io/opencv-ci/opencv-openeuler-22.03.sp2-ascend310 + 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 + ninja -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 }} From c8a1c0d9bcc1c59ba00f3683602840a112afb14c Mon Sep 17 00:00:00 2001 From: huafengchun Date: Thu, 9 Nov 2023 15:48:08 +0800 Subject: [PATCH 2/4] Update docker image name --- .github/workflows/OCV-Contrib-PR-4.x-O22-CANN.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/OCV-Contrib-PR-4.x-O22-CANN.yaml b/.github/workflows/OCV-Contrib-PR-4.x-O22-CANN.yaml index a08172cd..61f711e5 100644 --- a/.github/workflows/OCV-Contrib-PR-4.x-O22-CANN.yaml +++ b/.github/workflows/OCV-Contrib-PR-4.x-O22-CANN.yaml @@ -31,7 +31,7 @@ jobs: run: shell: bash container: - image: quay.io/opencv-ci/opencv-openeuler-22.03.sp2-ascend310 + 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 From 1b3a9fc1a4fee6145a402fd457958fa5e1a9aa44 Mon Sep 17 00:00:00 2001 From: huafengchun Date: Thu, 9 Nov 2023 16:08:07 +0800 Subject: [PATCH 3/4] Remove if conditions Conditions will add in main repo's workflow. --- .github/workflows/OCV-Contrib-PR-4.x-O22-CANN.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/OCV-Contrib-PR-4.x-O22-CANN.yaml b/.github/workflows/OCV-Contrib-PR-4.x-O22-CANN.yaml index 61f711e5..52cd302e 100644 --- a/.github/workflows/OCV-Contrib-PR-4.x-O22-CANN.yaml +++ b/.github/workflows/OCV-Contrib-PR-4.x-O22-CANN.yaml @@ -25,7 +25,6 @@ env: jobs: BuildAndTest: - if: contains(github.event.pull_request.labels.*.name, 'category:cann') runs-on: opencv-cn-openeuler-ascend310-x86-64 defaults: run: From 5c8fec83bcba79985ee6f0587d5fd7939855019b Mon Sep 17 00:00:00 2001 From: huafengchun Date: Mon, 13 Nov 2023 18:22:52 +0800 Subject: [PATCH 4/4] Build cannops module only This workflow is only used to test cannops module. Skip other modules to increase execution speed. --- .github/workflows/OCV-Contrib-PR-4.x-O22-CANN.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/OCV-Contrib-PR-4.x-O22-CANN.yaml b/.github/workflows/OCV-Contrib-PR-4.x-O22-CANN.yaml index 52cd302e..baec6a18 100644 --- a/.github/workflows/OCV-Contrib-PR-4.x-O22-CANN.yaml +++ b/.github/workflows/OCV-Contrib-PR-4.x-O22-CANN.yaml @@ -113,7 +113,7 @@ jobs: id: build-opencv-contrib run: | cd $HOME/build - ninja -j ${{ env.PARALLEL_JOBS }} | tee $HOME/build/build-log.txt + 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' }}