Skip to content

OCV PR:5.x AndroidSDK #838

OCV PR:5.x AndroidSDK

OCV PR:5.x AndroidSDK #838

name: OCV PR:5.x AndroidSDK
on:
pull_request:
branches:
- main
paths:
- '.github/workflows/OCV-PR-5.x-Android.yaml'
workflow_call:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
concurrency:
group: OCV-PR-5.x-Android-${{ github.ref }}
cancel-in-progress: true
env:
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_DOCKER_WORKDIR: '/home/ci/opencv'
CCACHE_DIR: '/home/ci/.ccache'
OPENCV_DOWNLOAD_PATH: '/home/ci/binaries_cache'
OPENCV_GRADLE_VERBOSE_OPTIONS: '--offline -i'
jobs:
BuildAndTest:
runs-on: opencv-cn-lin-x86-64-android
defaults:
run:
shell: bash
container:
image: quay.io/opencv-ci/opencv-androidsdk-30:20240213
volumes:
- /home/opencv-cn/git_cache:/home/ci/git_cache
- /home/opencv-cn/ci_cache/opencv:/home/ci/.ccache
- /home/opencv-cn/gradle_cache:/home/ci/.gradle
- /home/opencv-cn/binaries_cache:/home/ci/binaries_cache
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 environment
timeout-minutes: 60
run: |
if [[ "${{ github.event.repository.name }}" == "ci-gha-workflow" || "${{ github.event_name }}" == "schedule" ]]; then
echo "TARGET_BRANCH_NAME=5.x" >> $GITHUB_ENV
else
echo "BUILD_PRECOMMIT=1" >> $GITHUB_ENV
fi
- 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: (test -d "${{ env.OPENCV_DOCKER_WORKDIR }}" && find "${{ env.OPENCV_DOCKER_WORKDIR }}" -mindepth 1 -delete) || /bin/true
- name: Fetch opencv
timeout-minutes: 60
run: git clone --branch ${{ env.TARGET_BRANCH_NAME }} --reference ${{ env.GIT_CACHE_DOCKER }}/opencv.git https://github.com/opencv/opencv.git ${{ env.OPENCV_DOCKER_WORKDIR }}
- name: Merge opencv with ${{ env.SOURCE_BRANCH_NAME }} branch
timeout-minutes: 60
if: ${{ startsWith(github.event.repository.name, 'opencv') && github.event_name == 'pull_request' }}
run: |
cd ${{ env.OPENCV_DOCKER_WORKDIR }}
git pull -v "https://github.com/${{ env.PR_AUTHOR_FORK }}" "${{ env.SOURCE_BRANCH_NAME }}"
- name: Build OpenCV for Android SDK
timeout-minutes: 180
run: |
mkdir -p /home/ci/build
cd /home/ci/build
sed -i 's+https\\://services.gradle.org/distributions/gradle-@[email protected]+file\\:/opt/gradle/gradle-@[email protected]+g' ${{ env.OPENCV_DOCKER_WORKDIR }}/platforms/android/gradle-wrapper/gradle/wrapper/gradle-wrapper.properties.in
python3 "${{ env.OPENCV_DOCKER_WORKDIR }}/platforms/android/build_sdk.py" --build_doc --config "${{ env.OPENCV_DOCKER_WORKDIR }}/platforms/android/ndk-18-api-level-21.config.py" --sdk_path "$ANDROID_HOME" --ndk_path "$ANDROID_NDK_HOME" /home/ci/build | tee /home/ci/build/build-log.txt
- name: Warning check
timeout-minutes: 60
run: cd /home/ci/build && python3 /home/ci/scripts/warnings-handling.py
- name: Build local repo from SDK
timeout-minutes: 60
run: cd /home/ci/build && "${{ env.OPENCV_DOCKER_WORKDIR }}/platforms/android/build_aar.sh" OpenCV-android-sdk
- name: Build AAR
timeout-minutes: 60
run: |
cd /home/ci/build
sed -i 's+https\\://services.gradle.org/distributions/gradle-7.6.3-bin.zip+file\\:/opt/gradle/gradle-7.6.3-bin.zip+g' ${{ env.OPENCV_DOCKER_WORKDIR }}/platforms/android/aar-template/gradle/wrapper/gradle-wrapper.properties
python3 "${{ env.OPENCV_DOCKER_WORKDIR }}/platforms/android/build_java_shared_aar.py" --ndk_location="$ANDROID_NDK_HOME" --cmake_location=$(dirname $(dirname $(which cmake))) /home/ci/build/OpenCV-android-sdk
- name: Build Static AAR
timeout-minutes: 60
run: |
cd /home/ci/build
sed -i 's+https\\://services.gradle.org/distributions/gradle-7.6.3-bin.zip+file\\:/opt/gradle/gradle-7.6.3-bin.zip+g' ${{ env.OPENCV_DOCKER_WORKDIR }}/platforms/android/aar-template/gradle/wrapper/gradle-wrapper.properties
python3 "${{ env.OPENCV_DOCKER_WORKDIR }}/platforms/android/build_static_aar.py" --ndk_location="$ANDROID_NDK_HOME" --cmake_location=$(dirname $(dirname $(which cmake))) /home/ci/build/OpenCV-android-sdk
- name: Test CMake
timeout-minutes: 60
run: cd /home/ci/build && python3 "${{ env.OPENCV_DOCKER_WORKDIR }}/platforms/android/build-tests/test_cmake_build.py" --sdk_path "$ANDROID_HOME" --ndk_path "$ANDROID_NDK_HOME" OpenCV-android-sdk/sdk/native/jni
- name: Test Gradle for Local SDK
timeout-minutes: 60
run: cd /home/ci/build && "${{ env.OPENCV_DOCKER_WORKDIR }}/platforms/android/build-tests/test_gradle.sh" OpenCV-android-sdk
- name: Test Gradle for AAR from Py Script
timeout-minutes: 60
run: |
cd /home/ci/build
"${{ env.OPENCV_DOCKER_WORKDIR }}/platforms/android/build-tests/test_gradle_aar.sh" OpenCV-android-sdk /home/ci/build/outputs/maven_repo
- name: Test Gradle for AAR from SDK
timeout-minutes: 60
run: |
cd /home/ci/build
"${{ env.OPENCV_DOCKER_WORKDIR }}/platforms/android/build-tests/test_gradle_aar.sh" OpenCV-android-sdk /home/ci/build/outputs/maven_repo
- name: Create Packages
timeout-minutes: 60
run: |
cd /home/ci/build
# revert hacked Gradle URL to the original one
sed -i 's+file\\:/opt/gradle/gradle-7.6.3-bin.zip+https\\://services.gradle.org/distributions/gradle-7.6.3-bin.zip+g' OpenCV-android-sdk/samples/gradle/wrapper/gradle-wrapper.properties
zip -r -9 -y OpenCV4Android.zip OpenCV-android-sdk
zip -r -9 -y sdk-maven-repo.zip maven_repo
cd /home/ci/build/outputs
zip -r -9 -y python-maven-repo.zip maven_repo
- name: Release Package
timeout-minutes: 60
uses: actions/upload-artifact@v3
if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || env.RUNNER_DEBUG == 1 }}
with:
name: OpenCV4AndroidSDK
path: |
/home/ci/build/OpenCV4Android.zip
/home/ci/build/sdk-maven-repo.zip
/home/ci/build/outputs/python-maven-repo.zip