Add custom action and unified Linux build #149
This file contains 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: OCV PR Linux | |
on: | |
pull_request: | |
branches: | |
- main | |
paths: | |
- '.github/workflows/OCV-PR-Linux.yaml' | |
workflow_call: | |
inputs: | |
workflow_branch: | |
description: "Branch for ci-gha-workflow repository" | |
default: "main" | |
required: false | |
type: string | |
concurrency: | |
group: OCV-PR-Linux-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
# branch_eval: | |
# runs-on: ubuntu-latest | |
# outputs: | |
# branches: ${{ steps.determine-branches.outputs.branches }} | |
# steps: | |
# - id: determine-branches | |
# shell: bash | |
# run: | | |
# if [ "${{ github.event.repository.name == 'ci-gha-workflow' }}" = "true" ] ; then | |
# echo "branches=[ '4.x', '5.x' ]" >> "$GITHUB_OUTPUT" | |
# else | |
# echo "branches=[ '${{ github.base_ref }}' ]" >> "$GITHUB_OUTPUT" | |
# fi | |
Ubuntu: | |
# runs-on: opencv-ru-lin-riscv | |
runs-on: opencv-cn-lin-x86-64 | |
# needs: | |
# - branch_eval | |
strategy: | |
# Debugging | |
# fail-fast: true | |
# max-parallel: 3 | |
fail-fast: false | |
max-parallel: 3 | |
matrix: | |
version: | |
- '24.04' | |
- '22.04' | |
- '20.04' | |
# branch: ${{ fromJSON(needs.branch_eval.outputs.branches )}} | |
branch: ${{ github.event.repository.name == 'ci-gha-workflow' && fromJSON('["4.x", "5.x"]') || fromJSON(format('[ "{0}" ]', github.base_ref)) }} | |
include: | |
- version: '24.04' | |
image: '24.04:20241031' | |
jpegxl: true | |
avx2: true | |
- version: '22.04' | |
image: '22.04:20230602' | |
plugins: true | |
- version: '20.04' | |
image: '20.04:20230413' | |
limited_api: true | |
defaults: | |
run: | |
shell: bash | |
container: | |
image: 'quay.io/opencv-ci/opencv-ubuntu-${{ matrix.image }}' | |
volumes: | |
# - /mnt/cache/git_cache:/opt/git_cache | |
# - /mnt/cache/ci_cache/opencv:/opt/.ccache | |
# - /mnt/cache/binaries_cache:/opt/binaries_cache | |
# - vol_dnn_models:/opt/dnn-models | |
- /home/opencv-cn/git_cache:/opt/git_cache | |
- /home/opencv-cn/ci_cache/opencv:/opt/.ccache | |
- /home/opencv-cn/binaries_cache:/opt/binaries_cache | |
- /home/opencv-cn/dnn-models:/opt/dnn-models | |
# options: '--user root:root' | |
env: | |
ANT_HOME: '/usr/share/ant' | |
DNN_MODELS: '/opt/dnn-models' | |
CCACHE_DIR: '/opt/.ccache' | |
OPENCV_DOWNLOAD_PATH: '/opt/binaries_cache' | |
CMAKE_OPT: >- | |
-DBUILD_DOCS=ON | |
-DBUILD_EXAMPLES=ON | |
-DOPENCV_ENABLE_NONFREE=ON | |
${{ matrix.jpegxl && '-DWITH_JPEGXL=ON' }} | |
${{ matrix.avx2 && '-DCPU_BASELINE=AVX2'}} | |
${{ matrix.plugins && '-DVIDEOIO_PLUGIN_LIST=all -DHIGHGUI_PLUGIN_LIST=all' }} | |
${{ matrix.limited_api && '-DPYTHON3_LIMITED_API=ON' }} | |
HOME: ${{ contains(matrix.image, '24.04') && '/home/ubuntu' || '/home/ci' }} | |
OPENCV_FOR_THREADS_NUM: 8 | |
CMAKE_BUILD_PARALLEL_LEVEL: 8 | |
# ========== | |
steps: | |
- name: Checkout workflow repository | |
uses: actions/checkout@v4 | |
with: | |
repository: opencv/ci-gha-workflow | |
ref: "${{ github.repository == 'opencv/ci-gha-workflow' && github.ref || inputs.workflow_branch }}" | |
- name: Checkout and merge OpenCV | |
uses: ./checkout-and-merge | |
with: | |
target_branch: "${{ matrix.branch }}" | |
author: "${{ github.event.pull_request.user.login }}" | |
source_branch: "${{ github.event.repository.name == 'ci-gha-workflow' && '' || github.head_ref }}" | |
gitcache: '/opt/git_cache' | |
home: '${{ env.HOME }}' | |
workdir: '${{ env.HOME }}' | |
- name: Update extra dnn models | |
timeout-minutes: 60 | |
working-directory: '${{ env.HOME }}' | |
run: | | |
python3 opencv_extra/testdata/dnn/download_models.py \ | |
--cleanup \ | |
--dst '${{ env.DNN_MODELS }}/dnn' | |
echo "OPENCV_DNN_TEST_DATA_PATH=${{ env.DNN_MODELS }}" >> $GITHUB_ENV | |
- name: Configure and build OpenCV | |
uses: ./configure-and-build | |
with: | |
workdir: '${{ env.HOME }}' | |
builddir: 'build' | |
generator: 'Ninja' | |
options: '${{ env.CMAKE_OPT }}' | |
- name: Configure and build OpenCV with contrib | |
uses: ./configure-and-build | |
with: | |
workdir: '${{ env.HOME }}' | |
builddir: 'build-contrib' | |
generator: 'Ninja' | |
options: '-DOPENCV_EXTRA_MODULES_PATH=opencv_contrib/modules ${{ env.CMAKE_OPT }}' | |
- name: Run OpenCV tests | |
uses: ./run-tests | |
env: | |
OPENCV_TEST_DATA_PATH: '${{ env.HOME }}/opencv_extra/testdata' | |
OPENCV_TEST_REQUIRE_DATA: 1 | |
OPENCV_TEST_CHECK_OPTIONAL_DATA: 1 | |
PYTHONPATH: '${{ env.HOME }}/build/python_loader:$PYTHONPATH' | |
with: | |
workdir: '${{ env.HOME }}' | |
builddir: 'build' | |
suite: "[ 'linux-${{ matrix.branch }}', ${{ (github.event.repository.name == 'opencv_contrib') && format('''linux-contrib-{0}''', matrix.branch) || '' }} ]" | |
filter: "[ 'ubuntu-common', ${{ matrix.avx2 && '''ubuntu-avx2''' }} ]" | |
enable_python: "true" | |
enable_java: "true" | |
suffix: '${{ matrix.version }}_${{ matrix.branch }}' |