Skip to content

Commit 4a443ac

Browse files
committed
Add custom action and unified Linux build
1 parent 0dbdce0 commit 4a443ac

File tree

8 files changed

+740
-3
lines changed

8 files changed

+740
-3
lines changed

.editorconfig

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# https://editorconfig.org/
2+
3+
root = true
4+
5+
[*]
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
indent_style = space
11+
indent_size = 4
12+
13+
[*.json]
14+
indent_size = 4
15+
16+
[*.{yml,yaml}]
17+
indent_size = 2
18+
19+
[*.{bat,cmd,cmd.*}]
20+
end_of_line = crlf
21+
indent_style = space
22+
indent_size = 2
23+
24+
[*.{ps1,ps1.*}]
25+
end_of_line = crlf
26+
indent_style = space
27+
indent_size = 4
28+
29+
[*.{md,markdown}]
30+
indent_size = 2

.github/workflows/OCV-PR-Linux.yaml

+156
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
name: OCV PR Linux
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
paths:
8+
- '.github/workflows/OCV-PR-Linux.yaml'
9+
workflow_call:
10+
inputs:
11+
workflow_branch:
12+
description: "Branch for ci-gha-workflow repository"
13+
default: "main"
14+
required: false
15+
type: string
16+
17+
concurrency:
18+
group: OCV-PR-Linux-${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
branch_eval:
23+
runs-on: ubuntu-latest
24+
outputs:
25+
branches: ${{ steps.determine-branches.outputs.branches }}
26+
steps:
27+
- id: determine-branches
28+
shell: bash
29+
run: |
30+
if [ "${{ github.event.repository.name == 'ci-gha-workflow' }}" = "true" ] ; then
31+
echo "branches=[ '4.x', '5.x' ]" >> "$GITHUB_OUTPUT"
32+
else
33+
echo "branches=[ '${{ github.base_ref }}' ]" >> "$GITHUB_OUTPUT"
34+
fi
35+
36+
Ubuntu:
37+
# runs-on: opencv-ru-lin-riscv
38+
runs-on: opencv-cn-lin-x86-64
39+
needs:
40+
- branch_eval
41+
strategy:
42+
# Debugging
43+
# fail-fast: true
44+
# max-parallel: 3
45+
fail-fast: false
46+
max-parallel: 3
47+
matrix:
48+
version:
49+
- '24.04'
50+
- '22.04'
51+
- '20.04'
52+
branch: ${{ fromJSON(needs.branch_eval.outputs.branches )}}
53+
include:
54+
- version: '24.04'
55+
image: '24.04:20241031'
56+
jpegxl: true
57+
avx2: true
58+
- version: '22.04'
59+
image: '22.04:20230602'
60+
plugins: true
61+
- version: '20.04'
62+
image: '20.04:20230413'
63+
limited_api: true
64+
65+
defaults:
66+
run:
67+
shell: bash
68+
container:
69+
image: 'quay.io/opencv-ci/opencv-ubuntu-${{ matrix.image }}'
70+
volumes:
71+
# - /mnt/cache/git_cache:/opt/git_cache
72+
# - /mnt/cache/ci_cache/opencv:/opt/.ccache
73+
# - /mnt/cache/binaries_cache:/opt/binaries_cache
74+
# - vol_dnn_models:/opt/dnn-models
75+
- /home/opencv-cn/git_cache:/opt/git_cache
76+
- /home/opencv-cn/ci_cache/opencv:/opt/.ccache
77+
- /home/opencv-cn/binaries_cache:/opt/binaries_cache
78+
- /home/opencv-cn/dnn-models:/opt/dnn-models
79+
options: '--user root:root'
80+
env:
81+
ANT_HOME: '/usr/share/ant'
82+
DNN_MODELS: '/opt/dnn-models'
83+
CCACHE_DIR: '/opt/.ccache'
84+
OPENCV_DOWNLOAD_PATH: '/opt/binaries_cache'
85+
CMAKE_OPT: >-
86+
-DBUILD_DOCS=ON
87+
-DBUILD_EXAMPLES=ON
88+
-DOPENCV_ENABLE_NONFREE=ON
89+
${{ matrix.jpegxl && '-DWITH_JPEGXL=ON' }}
90+
${{ matrix.avx2 && '-DCPU_BASELINE=AVX2'}}
91+
${{ matrix.plugins && '-DVIDEOIO_PLUGIN_LIST=all -DHIGHGUI_PLUGIN_LIST=all' }}
92+
${{ matrix.limited_api && '-DPYTHON3_LIMITED_API=ON' }}
93+
HOME: ${{ contains(matrix.image, '24.04') && '/home/ubuntu' || '/home/ci' }}
94+
OPENCV_FOR_THREADS_NUM: 8
95+
CMAKE_BUILD_PARALLEL_LEVEL: 8
96+
97+
# ==========
98+
99+
steps:
100+
101+
- name: Checkout workflow repository
102+
uses: actions/checkout@v4
103+
with:
104+
repository: opencv/ci-gha-workflow
105+
ref: ${{ github.repository == 'opencv/ci-gha-workflow' && github.ref || inputs.workflow_branch }}
106+
107+
- name: Checkout and merge OpenCV
108+
uses: ./checkout-and-merge
109+
with:
110+
target_branch: ${{ matrix.branch }}
111+
author: ${{ github.event.pull_request.user.login }}
112+
source_branch: ${{ github.event.repository.name == 'ci-gha-workflow' && '' || github.head_ref }}
113+
gitcache: '/opt/git_cache'
114+
home: '${{ env.HOME }}'
115+
workdir: '${{ env.HOME }}'
116+
117+
- name: Update extra dnn models
118+
timeout-minutes: 60
119+
working-directory: '${{ env.HOME }}'
120+
run: |
121+
python3 opencv_extra/testdata/dnn/download_models.py \
122+
--cleanup \
123+
--dst '${{ env.DNN_MODELS }}/dnn'
124+
echo "OPENCV_DNN_TEST_DATA_PATH=${{ env.DNN_MODELS }}" >> $GITHUB_ENV
125+
126+
- name: Configure and build OpenCV
127+
uses: ./configure-and-build
128+
with:
129+
workdir: '${{ env.HOME }}'
130+
builddir: 'build'
131+
generator: 'Ninja'
132+
options: '${{ env.CMAKE_OPT }}'
133+
134+
- name: Configure and build OpenCV with contrib
135+
uses: ./configure-and-build
136+
with:
137+
workdir: '${{ env.HOME }}'
138+
builddir: 'build-contrib'
139+
generator: 'Ninja'
140+
options: '-DOPENCV_EXTRA_MODULES_PATH=opencv_contrib/modules ${{ env.CMAKE_OPT }}'
141+
142+
- name: Run OpenCV tests
143+
uses: ./run-tests
144+
env:
145+
OPENCV_TEST_DATA_PATH: '${{ env.HOME }}/opencv_extra/testdata'
146+
OPENCV_TEST_REQUIRE_DATA: 1
147+
OPENCV_TEST_CHECK_OPTIONAL_DATA: 1
148+
PYTHONPATH: '${{ env.HOME }}/build/python_loader:$PYTHONPATH'
149+
with:
150+
workdir: '${{ env.HOME }}'
151+
builddir: 'build'
152+
suite: "linux-${{ matrix.branch }}"
153+
filter: "[ 'ubuntu-common', ${{ matrix.avx2 && '''ubuntu-avx2''' }} ]"
154+
enable_python: "true"
155+
enable_java: "true"
156+
suffix: '${{ matrix.version }}_${{ matrix.branch }}'

checkout-and-merge/action.yaml

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: checkout-and-merge
2+
description: "Checkout OpenCV repositories and merge if needed"
3+
4+
inputs:
5+
repos:
6+
description: "Repository list to clone, can contain 'main', 'contrib' and 'extra'"
7+
default: 'main,contrib,extra'
8+
target_branch:
9+
description: "Target PR branch in OpenCV repository (4.x, 5.x)"
10+
default: "4.x"
11+
author:
12+
description: "PR author"
13+
source_branch:
14+
description: "Source PR branch"
15+
gitcache:
16+
description: "Root folder with git cache (can contain opencv.git/, opencv_contrib.git/, opencv_extra.git/)"
17+
home:
18+
description: "Home directory on executor (for git configuration)"
19+
default: "/home/ubuntu"
20+
workdir:
21+
description: "Work directory on executor, repositories will be cloned to opencv/opencv_contrib/opencv_extra"
22+
23+
runs:
24+
using: "composite"
25+
steps:
26+
27+
# opencv
28+
29+
- if: ${{ contains(inputs.repos, 'main') }}
30+
working-directory: ${{ inputs.workdir }}
31+
shell: bash
32+
run: |
33+
echo "::group::Clone opencv"
34+
rm -rf opencv
35+
HOME=${{ inputs.home }} \
36+
git clone \
37+
--reference-if-able ${{ inputs.gitcache }}/opencv.git \
38+
--single-branch \
39+
--branch ${{ inputs.target_branch }} \
40+
https://github.com/opencv/opencv.git
41+
echo "::endgroup::"
42+
43+
- if: ${{ github.event.repository.name != 'ci-gha-workflow' && contains(inputs.repos, 'main') && inputs.source_branch }}
44+
working-directory: ${{ inputs.workdir }}
45+
shell: bash
46+
run: |
47+
echo "OPENCV_MAIN_FORK=$(HOME=${{ inputs.home }} git ls-remote --heads https://github.com/${{ inputs.author }}/opencv ${{ inputs.source_branch }})" >> $GITHUB_ENV
48+
49+
- if: ${{ github.event.repository.name != 'ci-gha-workflow' && contains(inputs.repos, 'main') && inputs.source_branch && env.OPENCV_MAIN_FORK }}
50+
working-directory: ${{ inputs.workdir }}
51+
shell: bash
52+
run: |
53+
echo "::group::Merge opencv"
54+
HOME=${{ inputs.home }} \
55+
git -C opencv pull -v "https://github.com/${{ inputs.author }}/opencv" "${{ inputs.source_branch }}"
56+
echo "::endgroup::"
57+
58+
# opencv_contrib
59+
60+
- if: ${{ contains(inputs.repos, 'contrib') }}
61+
working-directory: ${{ inputs.workdir }}
62+
shell: bash
63+
run: |
64+
echo "::group::Clone opencv_contrib"
65+
rm -rf opencv_contrib
66+
HOME=${{ inputs.home }} \
67+
git clone \
68+
--reference-if-able ${{ inputs.gitcache }}/opencv_contrib.git \
69+
--single-branch \
70+
--branch ${{ inputs.target_branch }} \
71+
https://github.com/opencv/opencv_contrib.git
72+
echo "::endgroup::"
73+
74+
- if: ${{ github.event.repository.name != 'ci-gha-workflow' && contains(inputs.repos, 'contrib') && inputs.source_branch }}
75+
working-directory: ${{ inputs.workdir }}
76+
shell: bash
77+
run: |
78+
echo "OPENCV_CONTRIB_FORK=$(HOME=${{ inputs.home }} git ls-remote --heads https://github.com/${{ inputs.author }}/opencv_contrib ${{ inputs.source_branch }})" >> $GITHUB_ENV
79+
80+
- if: ${{ github.event.repository.name != 'ci-gha-workflow' && contains(inputs.repos, 'contrib') && inputs.source_branch && env.OPENCV_CONTRIB_FORK }}
81+
shell: bash
82+
run: |
83+
echo "::group::Merge opencv_contrib"
84+
HOME=${{ inputs.home }} \
85+
git -C opencv_contrib pull -v "https://github.com/${{ inputs.author }}/opencv_contrib" "${{ inputs.source_branch }}"
86+
echo "::endgroup::"
87+
88+
# opencv_extra
89+
90+
- if: ${{ contains(inputs.repos, 'extra') }}
91+
working-directory: ${{ inputs.workdir }}
92+
shell: bash
93+
run: |
94+
echo "::group::Clone opencv_extra"
95+
rm -rf opencv_extra
96+
HOME=${{ inputs.home }} \
97+
git clone \
98+
--reference-if-able ${{ inputs.gitcache }}/opencv_extra.git \
99+
--single-branch \
100+
--branch ${{ inputs.target_branch }} \
101+
https://github.com/opencv/opencv_extra.git
102+
echo "::endgroup::"
103+
104+
- if: ${{ github.event.repository.name != 'ci-gha-workflow' && contains(inputs.repos, 'extra') && inputs.source_branch }}
105+
working-directory: ${{ inputs.workdir }}
106+
shell: bash
107+
run: |
108+
echo "OPENCV_EXTRA_FORK=$(HOME=${{ inputs.home }} git ls-remote --heads https://github.com/${{ inputs.author }}/opencv_extra ${{ inputs.source_branch }})" >> $GITHUB_ENV
109+
110+
- if: ${{ github.event.repository.name != 'ci-gha-workflow' && contains(inputs.repos, 'extra') && inputs.source_branch && env.OPENCV_EXTRA_FORK }}
111+
shell: bash
112+
run: |
113+
echo "::group::Merge opencv_extra"
114+
HOME=${{ inputs.home }} \
115+
git -C opencv_extra pull -v "https://github.com/${{ inputs.author }}/opencv_extra" "${{ inputs.source_branch }}"
116+
echo "::endgroup::"

configure-and-build/action.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: configure-and-build
2+
description: "Build OpenCV using CMake"
3+
4+
inputs:
5+
workdir:
6+
description: "Work directory on executor, repositories will be cloned to opencv/opencv_contrib/opencv_extra"
7+
builddir:
8+
description: "Build directory"
9+
default: "build"
10+
generator:
11+
description: "CMake generator, e.g. Ninja"
12+
options:
13+
description: "Extra CMake options"
14+
15+
runs:
16+
using: "composite"
17+
steps:
18+
19+
- working-directory: ${{ inputs.workdir }}
20+
shell: bash
21+
run: |
22+
echo "::group::Configure"
23+
rm -rf ${{ inputs.builddir }}
24+
mkdir -p ${{ inputs.builddir }}
25+
cmake \
26+
-S opencv \
27+
-B ${{ inputs.builddir }} \
28+
-G ${{ inputs.generator }} \
29+
${{ inputs.options }}
30+
echo "::endgroup::"
31+
32+
- working-directory: ${{ inputs.workdir }}
33+
shell: bash
34+
run: |
35+
echo "::group::Build"
36+
cmake --build ${{ inputs.builddir }} 2>&1 | tee ${{ inputs.builddir }}/log.txt
37+
echo "::endgroup::"
38+
39+
- shell: bash
40+
run: |
41+
python3 ./scripts/warnings-handling.py \
42+
${{ inputs.workdir }}/${{ inputs.builddir }}/log.txt

0 commit comments

Comments
 (0)