Skip to content

Commit d49d0e8

Browse files
authored
Add OpenCV.js build and test to CI #231 (#238)
* change limit ccache size * change limit ccache size and dir * OCV-PR-4.x-docs.yaml and Build js test * Update OCV-PR-4.x-docs.yaml * Update OCV-PR-4.x-docs.yaml * Update OCV-PR-5.x-docs.yaml * Create Dockerfile-22-js * Delete .github/workflows/OCV-Nightly-docs-js.yaml
1 parent 11316ec commit d49d0e8

File tree

4 files changed

+130
-86
lines changed

4 files changed

+130
-86
lines changed

.github/workflows/OCV-Nightly-docs-js.yaml

Lines changed: 0 additions & 82 deletions
This file was deleted.

.github/workflows/OCV-PR-4.x-docs.yaml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ concurrency:
1313
cancel-in-progress: true
1414

1515
env:
16-
EXTRA_CMAKE_OPTIONS: '-DOPENCV_ENABLE_NONFREE=ON -DBUILD_SHARED_LIBS=ON -DBUILD_DOCS=ON -DOPENCV_DOCS_HAVE_DOT=YES -DBUILD_TESTS=ON -DWITH_OPENNI2=ON -DWITH_GDCM=ON -DPYTHON_DEFAULT_EXECUTABLE=/usr/bin/python3 -DOPENCV_EXTRA_MODULES_PATH=/home/ci/opencv_contrib/modules -DWITH_GDAL=ON -DBUILD_EXAMPLES=ON -DBUILD_PERF_TESTS=ON -DWITH_IPP=OFF'
16+
EXTRA_CMAKE_OPTIONS: '-DOPENCV_ENABLE_NONFREE=ON -DBUILD_SHARED_LIBS=ON -DBUILD_DOCS=ON -DOPENCV_DOCS_HAVE_DOT=YES -DBUILD_TESTS=ON -DWITH_OPENNI2=ON -DWITH_GDCM=ON -DPYTHON_DEFAULT_EXECUTABLE=/usr/bin/python3 -DOPENCV_EXTRA_MODULES_PATH=/home/ci/opencv_contrib/modules -DWITH_GDAL=ON -DBUILD_EXAMPLES=ON -DBUILD_PERF_TESTS=ON -DWITH_IPP=OFF -DOPENCV_JS_LOCATION=/home/ci/build/js/bin/opencv.js'
1717
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
1818
PR_AUTHOR_FORK: ${{ github.event.pull_request.head.repo.full_name }}
1919
SOURCE_BRANCH_NAME: ${{ github.head_ref }}
@@ -29,7 +29,7 @@ jobs:
2929
run:
3030
shell: bash
3131
container:
32-
image: quay.io/opencv-ci/opencv-docs-22.04:20241202
32+
image: quay.io/opencv-ci/opencv-docs-22.04:20250404
3333
options: --user ci
3434
steps:
3535
- uses: actions/checkout@v4
@@ -130,30 +130,51 @@ jobs:
130130
cd ${{ env.OPENCV_CONTRIB_DOCKER_WORKDIR }}
131131
git bundle create test.bundle ${{ env.LATEST_COMMIT_OPENCV_CONTRIB }}..HEAD || true
132132
python3 $HOME/scripts/patch_size.py
133+
134+
- name: Build js
135+
if: ${{ always() && steps.last-repo-step.outcome == 'success' }}
136+
timeout-minutes: 60
137+
run: |
138+
cd $HOME/build
139+
emcmake python ../opencv/platforms/js/build_js.py js --build_test
140+
141+
- name: Run js tests
142+
if: ${{ always() && steps.last-repo-step.outcome == 'success' }}
143+
timeout-minutes: 60
144+
run: |
145+
cd $HOME/build/js/bin
146+
npm install
147+
node tests.js
148+
133149
- name: Configure OpenCV doxygen
134150
if: ${{ always() && steps.last-repo-step.outcome == 'success' }}
135151
id: opencv-doxygen
136152
timeout-minutes: 60
137153
run: |
138154
cd $HOME/build
139155
cmake ${{ env.EXTRA_CMAKE_OPTIONS }} ${{ env.OPENCV_DOCKER_WORKDIR }}
156+
140157
- name: Build OpenCV doxygen
141158
if: ${{ always() && steps.opencv-doxygen.outcome == 'success' }}
142159
timeout-minutes: 60
143160
id: build-opencv
144161
working-directory: ${{ env.HOME }}/build
145162
run: cmake --build . --config release --target doxygen -- -j$(nproc) 2>&1 | tee log.txt
163+
146164
- name: Warnings check
147165
run: python3 scripts/warnings-handling.py ${{ env.HOME }}/build/log.txt
166+
148167
- name: Pylint
149168
timeout-minutes: 60
150169
if: ${{ always() && steps.build-opencv.outcome == 'success' }}
151170
run: |
152171
cd $HOME/build
153172
cmake --build . --config release --target check_pylint -- -j$(nproc)
173+
154174
- name: Flake8
155175
timeout-minutes: 60
156176
if: ${{ always() && steps.build-opencv.outcome == 'success' }}
157177
run: |
158178
cd $HOME/build
159179
cmake --build . --config release --target check_flake8 -- -j$(nproc)
180+

.github/workflows/OCV-PR-5.x-docs.yaml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ concurrency:
1313
cancel-in-progress: true
1414

1515
env:
16-
EXTRA_CMAKE_OPTIONS: '-DOPENCV_ENABLE_NONFREE=ON -DBUILD_SHARED_LIBS=ON -DBUILD_DOCS=ON -DOPENCV_DOCS_HAVE_DOT=YES -DBUILD_TESTS=ON -DWITH_OPENNI2=ON -DWITH_GDCM=ON -DPYTHON_DEFAULT_EXECUTABLE=/usr/bin/python3 -DOPENCV_EXTRA_MODULES_PATH=/home/ci/opencv_contrib/modules -DWITH_GDAL=ON -DBUILD_EXAMPLES=ON -DBUILD_PERF_TESTS=ON -DWITH_IPP=OFF'
16+
EXTRA_CMAKE_OPTIONS: '-DOPENCV_JS_LOCATION=/home/ci/build/js/bin/opencv.js -DOPENCV_ENABLE_NONFREE=ON -DBUILD_SHARED_LIBS=ON -DBUILD_DOCS=ON -DOPENCV_DOCS_HAVE_DOT=YES -DBUILD_TESTS=ON -DWITH_OPENNI2=ON -DWITH_GDCM=ON -DPYTHON_DEFAULT_EXECUTABLE=/usr/bin/python3 -DOPENCV_EXTRA_MODULES_PATH=/home/ci/opencv_contrib/modules -DWITH_GDAL=ON -DBUILD_EXAMPLES=ON -DBUILD_PERF_TESTS=ON -DWITH_IPP=OFF'
1717
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
1818
PR_AUTHOR_FORK: ${{ github.event.pull_request.head.repo.full_name }}
1919
SOURCE_BRANCH_NAME: ${{ github.head_ref }}
@@ -29,7 +29,7 @@ jobs:
2929
run:
3030
shell: bash
3131
container:
32-
image: quay.io/opencv-ci/opencv-docs-22.04:20241202
32+
image: quay.io/opencv-ci/opencv-docs-22.04:20250404
3333
options: --user ci
3434
steps:
3535
- uses: actions/checkout@v4
@@ -130,6 +130,21 @@ jobs:
130130
cd ${{ env.OPENCV_CONTRIB_DOCKER_WORKDIR }}
131131
git bundle create test.bundle ${{ env.LATEST_COMMIT_OPENCV_CONTRIB }}..HEAD || true
132132
python3 $HOME/scripts/patch_size.py
133+
- name: Build js
134+
if: ${{ always() && steps.last-repo-step.outcome == 'success' }}
135+
timeout-minutes: 60
136+
run: |
137+
cd $HOME/build
138+
emcmake python ../opencv/platforms/js/build_js.py js --build_test
139+
140+
- name: Run js tests
141+
if: ${{ always() && steps.last-repo-step.outcome == 'success' }}
142+
timeout-minutes: 60
143+
run: |
144+
cd $HOME/build/js/bin
145+
npm install
146+
node tests.js
147+
133148
- name: Configure OpenCV doxygen
134149
if: ${{ always() && steps.last-repo-step.outcome == 'success' }}
135150
id: opencv-doxygen

docker/docs/Dockerfile-22-js

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Version: 20250404
2+
# Image name: quay.io/opencv-ci/opencv-docs-22.04
3+
4+
FROM ubuntu:22.04
5+
6+
RUN \
7+
apt-get update && \
8+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
9+
software-properties-common \
10+
gpg-agent curl git htop man zip unzip vim wget ncdu mc nano time \
11+
file \
12+
&& \
13+
add-apt-repository ppa:git-core/ppa && \
14+
apt-get install -y --no-install-recommends git && \
15+
rm -rf /var/lib/apt/lists/*
16+
17+
RUN \
18+
apt-get update && \
19+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
20+
cmake build-essential \
21+
doxygen-latex graphviz \
22+
p7zip-full \
23+
pylint flake8 \
24+
python3-bs4 \
25+
&& \
26+
rm -rf /var/lib/apt/lists/*
27+
28+
ENV EMSDK_VERSION=1.39.0-upstream
29+
ENV EMSDK_DIR=/opt/emsdk-portable
30+
ENV EMSDK_CACHE_DIR=/opt/build-worker/emsdk-${EMSDK_VERSION}
31+
32+
RUN \
33+
/bin/bash -c "mkdir -p ${EMSDK_DIR} && \
34+
cd ${EMSDK_DIR} && \
35+
git rev-parse HEAD || (rm -rf ./.git && git clone https://github.com/juj/emsdk.git .) && \
36+
git reset --hard || true && \
37+
git clean -f -d || true && \
38+
git fetch origin && \
39+
git checkout -B main origin/main && \
40+
git rev-parse HEAD && \
41+
./emsdk list && \
42+
./emsdk install ${EMSDK_VERSION} && \
43+
./emsdk activate ${EMSDK_VERSION} && \
44+
source ./emsdk_env.sh && \
45+
mkdir -p ./.home && \
46+
cp -rp ./.em* ./.home/ && \
47+
# python script (opencv/platforms/js/build_js.py) has shebang and required hardly python
48+
ln -s /usr/bin/python3 /usr/bin/python"
49+
50+
51+
# Install fresh Doxygen
52+
ARG doxygen_version=doxygen-1.12.0
53+
ARG doxygen_urlbase=https://github.com/doxygen/doxygen/releases/download/Release_1_12_0
54+
ARG doxygen_archive=${doxygen_version}.linux.bin.tar.gz
55+
ARG doxygen_sha1sum=c50fc71ba9b5e431f0f0f21c5dc8559f47f06007
56+
ADD ${doxygen_urlbase}/${doxygen_archive} /opt/
57+
RUN \
58+
cd /opt \
59+
&& echo "${doxygen_sha1sum} ${doxygen_archive}" | sha1sum -c \
60+
&& tar -xvf ${doxygen_archive} \
61+
&& rm -rf ${doxygen_archive}
62+
ENV PATH=/opt/${doxygen_version}/bin:${PATH}
63+
64+
65+
# GitHub Actions user's UID is 1001
66+
RUN \
67+
useradd ci -m -s /bin/bash -G users --uid=1001 && \
68+
chown -R ci:ci ${EMSDK_DIR}
69+
70+
USER ci
71+
72+
RUN \
73+
cd $HOME && \
74+
mkdir opencv opencv_contrib build && \
75+
git config --global --add safe.directory "*" && \
76+
git config --global user.email "opencv.ci" && \
77+
git config --global user.name "opencv.ci" && \
78+
git config --global pull.rebase false
79+
80+
# Run docker build from the root directory of the repository
81+
COPY scripts/patch_size.py /home/ci/scripts/patch_size.py
82+
COPY scripts/pack_docs.py /home/ci/scripts/
83+
84+
ENV PATH=${EMSDK_DIR}:${EMSDK_DIR}/upstream/emscripten:${EMSDK_DIR}/node/20.18.0_64bit/bin:${PATH}
85+
ENV EMSDK=${EMSDK_DIR}
86+
ENV EM_CONFIG=${EMSDK_DIR}/.emscripten
87+
ENV EM_CACHE=${EMSDK_DIR}/upstream/emscripten/cache
88+
ENV EMSDK_NODE=${EMSDK_DIR}/node/20.18.0_64bit/bin/node
89+
ENV EMSCRIPTEN ${EMSDK_DIR}/upstream/emscripten
90+
ENTRYPOINT bash

0 commit comments

Comments
 (0)