Skip to content

Commit 6dc2024

Browse files
authored
Migrate nightly documentation build from BuildBot to Github actions #242 (#247)
* testing use default python for Mac os ARM * testing use default python for Mac os Intel * Create docks_upload.yaml * Update docks_upload.yaml * Update docks_upload.yaml * Create docks_upload2.yaml * Update docks_upload2.yaml * Update docks_upload.yaml * Update docks_upload2.yaml * Create build_docks.yaml * Update docks_upload.yaml * Update docks_upload2.yaml * Update build_docks.yaml * Create download_artifacts.sh * Delete .github/workflows/docks_upload2.yaml * Delete .github/workflows/docks_upload.yaml * Create build_javadocs.yaml * Update build_javadocs.yaml * Update build_docks.yaml * Delete .github/workflows/build_javadocs.yaml * Update build_docks.yaml * Update build_docks.yaml * Update build_docks.yaml * Update build_docks.yaml * Update build_docks.yaml * Update OCV-PR-4.x-macOS-ARM64.yaml * Update OCV-PR-4.x-macOS-x86_64.yaml * Update download_artifacts.sh * Update and rename build_docks.yaml to build_docs_schedule.yaml * Update build_docs_schedule.yaml * Create pencv-docs-22.04-jdk-js * Update OCV-PR-5.x-docs.yaml * Update OCV-PR-4.x-docs.yaml * Rename pencv-docs-22.04-jdk-js to Dockerfile-22-jdk-js
1 parent d414473 commit 6dc2024

File tree

5 files changed

+331
-2
lines changed

5 files changed

+331
-2
lines changed

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ env:
2121
OPENCV_DOCKER_WORKDIR: '/home/ci/opencv'
2222
OPENCV_EXTRA_DOCKER_WORKDIR: '/home/ci/opencv_extra'
2323
OPENCV_CONTRIB_DOCKER_WORKDIR: '/home/ci/opencv_contrib'
24+
OPENCV_BUILD: /home/ci/opencv-build
25+
JAVA_DOC: /home/ci/opencv-build/doc/doxygen/html/javadoc
2426

2527
jobs:
2628
BuildAndTest:
@@ -29,7 +31,7 @@ jobs:
2931
run:
3032
shell: bash
3133
container:
32-
image: quay.io/opencv-ci/opencv-docs-22.04:20250404
34+
image: quay.io/opencv-ci/opencv-docs-jdk-js-22.04:20250526
3335
options: --user ci
3436
steps:
3537
- uses: actions/checkout@v4
@@ -130,6 +132,20 @@ jobs:
130132
cd ${{ env.OPENCV_CONTRIB_DOCKER_WORKDIR }}
131133
git bundle create test.bundle ${{ env.LATEST_COMMIT_OPENCV_CONTRIB }}..HEAD || true
132134
python3 $HOME/scripts/patch_size.py
135+
136+
- name: Generate JavaDoc
137+
run: |
138+
mkdir -p ${{ env.OPENCV_BUILD }}
139+
cd ${{ env.OPENCV_BUILD }}
140+
cmake -DBUILD_SHARED_LIBS=OFF \
141+
-DBUILD_opencv_java=ON \
142+
-DCMAKE_BUILD_TYPE=Release \
143+
-DOPENCV_EXTRA_MODULES_PATH=${{ env.OPENCV_CONTRIB_DOCKER_WORKDIR }}/modules \
144+
-DANT_EXECUTABLE=/usr/bin/ant \
145+
${{ env.OPENCV_DOCKER_WORKDIR }}
146+
make -j2
147+
cd modules/java/jar/opencv
148+
ant javadoc
133149
134150
- name: Build js
135151
if: ${{ always() && steps.last-repo-step.outcome == 'success' }}

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ env:
2121
OPENCV_DOCKER_WORKDIR: '/home/ci/opencv'
2222
OPENCV_EXTRA_DOCKER_WORKDIR: '/home/ci/opencv_extra'
2323
OPENCV_CONTRIB_DOCKER_WORKDIR: '/home/ci/opencv_contrib'
24+
OPENCV_BUILD: /home/ci/opencv-build
25+
JAVA_DOC: /home/ci/opencv-build/doc/doxygen/html/javadoc
2426

2527
jobs:
2628
BuildAndTest:
@@ -29,7 +31,7 @@ jobs:
2931
run:
3032
shell: bash
3133
container:
32-
image: quay.io/opencv-ci/opencv-docs-22.04:20250404
34+
image: quay.io/opencv-ci/opencv-docs-jdk-js-22.04:20250526
3335
options: --user ci
3436
steps:
3537
- uses: actions/checkout@v4
@@ -130,6 +132,21 @@ jobs:
130132
cd ${{ env.OPENCV_CONTRIB_DOCKER_WORKDIR }}
131133
git bundle create test.bundle ${{ env.LATEST_COMMIT_OPENCV_CONTRIB }}..HEAD || true
132134
python3 $HOME/scripts/patch_size.py
135+
136+
- name: Generate JavaDoc
137+
run: |
138+
mkdir -p ${{ env.OPENCV_BUILD }}
139+
cd ${{ env.OPENCV_BUILD }}
140+
cmake -DBUILD_SHARED_LIBS=OFF \
141+
-DBUILD_opencv_java=ON \
142+
-DCMAKE_BUILD_TYPE=Release \
143+
-DOPENCV_EXTRA_MODULES_PATH=${{ env.OPENCV_CONTRIB_DOCKER_WORKDIR }}/modules \
144+
-DANT_EXECUTABLE=/usr/bin/ant \
145+
${{ env.OPENCV_DOCKER_WORKDIR }}
146+
make -j2
147+
cd modules/java/jar/opencv
148+
ant javadoc
149+
133150
- name: Build js
134151
if: ${{ always() && steps.last-repo-step.outcome == 'success' }}
135152
timeout-minutes: 60
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: build docs schedule
2+
3+
on:
4+
schedule:
5+
- cron: '0 3 * * *'
6+
workflow_dispatch:
7+
8+
env:
9+
EXTRA_CMAKE_OPTIONS: '-DOPENCV_JS_LOCATION=/home/ci/build/js/bin/opencv.js -DOPENCV_ENABLE_NONFREE=ON -DBUILD_DOCS_JS_BINDINGS=OFF -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'
10+
OPENCV_DOCKER_WORKDIR: '/home/ci/opencv'
11+
OPENCV_EXTRA_DOCKER_WORKDIR: '/home/ci/opencv_extra'
12+
OPENCV_CONTRIB_DOCKER_WORKDIR: '/home/ci/opencv_contrib'
13+
OPENCV_SRC: /home/ci/opencv
14+
OPENCV_BUILD: /home/ci/opencv-build
15+
JAVA_DOC: /home/ci/opencv-build/doc/doxygen/html/javadoc
16+
17+
jobs:
18+
19+
build-docs:
20+
name: Build Docs ${{ matrix.branch }}
21+
runs-on: ubuntu-22.04
22+
container:
23+
image: quay.io/opencv-ci/opencv-docs-jdk-js-22.04:20250526
24+
options: --user ci
25+
strategy:
26+
matrix:
27+
branch: [4.x, 5.x]
28+
env:
29+
SOURCE_BRANCH_NAME: ${{ github.head_ref || matrix.branch }}
30+
TARGET_BRANCH_NAME: ${{ github.base_ref || matrix.branch }}
31+
steps:
32+
- uses: actions/checkout@v4
33+
with:
34+
repository: opencv/ci-gha-workflow
35+
ref: ${{ github.repository == 'opencv/ci-gha-workflow' && github.ref || 'main' }}
36+
37+
- name: Define HOME
38+
run: echo "HOME=/home/ci" >> $GITHUB_ENV
39+
40+
- name: Force TARGET_BRANCH_NAME (if in ci-gha-workflow repo)
41+
if: ${{ github.event.repository.name == 'ci-gha-workflow' }}
42+
run: echo "TARGET_BRANCH_NAME=${{ matrix.branch }}" >> $GITHUB_ENV
43+
44+
- name: Info
45+
run: |
46+
echo "SOURCE_BRANCH_NAME=${{ env.SOURCE_BRANCH_NAME }}"
47+
echo "TARGET_BRANCH_NAME=${{ env.TARGET_BRANCH_NAME }}"
48+
49+
- name: Clean workspace
50+
run: find ${{ env.OPENCV_DOCKER_WORKDIR }} -mindepth 1 -delete
51+
52+
- name: Clone Repositories
53+
run: |
54+
git clone --branch ${{ env.TARGET_BRANCH_NAME }} https://github.com/opencv/opencv.git ${{ env.OPENCV_DOCKER_WORKDIR }}
55+
git clone --branch ${{ env.TARGET_BRANCH_NAME }} https://github.com/opencv/opencv_extra.git ${{ env.OPENCV_EXTRA_DOCKER_WORKDIR }}
56+
git clone --branch ${{ env.TARGET_BRANCH_NAME }} https://github.com/opencv/opencv_contrib.git ${{ env.OPENCV_CONTRIB_DOCKER_WORKDIR }}
57+
58+
- name: Generate JavaDoc
59+
run: |
60+
mkdir -p ${{ env.OPENCV_BUILD }}
61+
cd ${{ env.OPENCV_BUILD }}
62+
cmake -DBUILD_SHARED_LIBS=OFF \
63+
-DBUILD_opencv_java=ON \
64+
-DCMAKE_BUILD_TYPE=Release \
65+
-DOPENCV_EXTRA_MODULES_PATH=${{ env.OPENCV_CONTRIB_DOCKER_WORKDIR }}/modules \
66+
-DANT_EXECUTABLE=/usr/bin/ant \
67+
${{ env.OPENCV_DOCKER_WORKDIR }}
68+
make -j2
69+
cd modules/java/jar/opencv
70+
ant javadoc
71+
72+
- name: Build js
73+
timeout-minutes: 60
74+
run: |
75+
cd $HOME/build
76+
emcmake python ../opencv/platforms/js/build_js.py js --build_test
77+
78+
- name: Run js tests
79+
timeout-minutes: 60
80+
run: |
81+
cd $HOME/build/js/bin
82+
npm install
83+
node tests.js
84+
85+
- name: Configure Doxygen
86+
run: |
87+
mkdir -p $HOME/build
88+
cd $HOME/build
89+
cmake ${{ env.EXTRA_CMAKE_OPTIONS }} ${{ env.OPENCV_DOCKER_WORKDIR }}
90+
91+
- name: Build Doxygen
92+
working-directory: ${{ env.HOME }}/build
93+
run: cmake --build . --config release --target doxygen -- -j$(nproc) 2>&1 | tee log.txt
94+
95+
- name: Archive Doxygen Docs
96+
uses: actions/upload-artifact@v4
97+
with:
98+
name: opencv-docs-${{ matrix.branch }}
99+
path: |
100+
${{ env.HOME }}/build/doc/doxygen/html
101+
${{ env.HOME }}/build/js/bin/opencv.js

docker/docs/Dockerfile-22-jdk-js

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#Version: 20250526
2+
# Image name: quay.io/opencv-ci/opencv-docs-jdk-js-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+
openjdk-11-jdk \
26+
default-jdk-headless \
27+
ant \
28+
&& \
29+
rm -rf /var/lib/apt/lists/*
30+
31+
ENV EMSDK_VERSION=1.39.0-upstream
32+
ENV EMSDK_DIR=/opt/emsdk-portable
33+
ENV EMSDK_CACHE_DIR=/opt/build-worker/emsdk-${EMSDK_VERSION}
34+
35+
RUN \
36+
/bin/bash -c "mkdir -p ${EMSDK_DIR} && \
37+
cd ${EMSDK_DIR} && \
38+
git rev-parse HEAD || (rm -rf ./.git && git clone https://github.com/juj/emsdk.git .) && \
39+
git reset --hard || true && \
40+
git clean -f -d || true && \
41+
git fetch origin && \
42+
git checkout -B main origin/main && \
43+
git rev-parse HEAD && \
44+
./emsdk list && \
45+
./emsdk install ${EMSDK_VERSION} && \
46+
./emsdk activate ${EMSDK_VERSION} && \
47+
source ./emsdk_env.sh && \
48+
mkdir -p ./.home && \
49+
cp -rp ./.em* ./.home/ && \
50+
# python script (opencv/platforms/js/build_js.py) has shebang and required hardly python
51+
ln -s /usr/bin/python3 /usr/bin/python"
52+
53+
54+
# Install fresh Doxygen
55+
ARG doxygen_version=doxygen-1.12.0
56+
ARG doxygen_urlbase=https://github.com/doxygen/doxygen/releases/download/Release_1_12_0
57+
ARG doxygen_archive=${doxygen_version}.linux.bin.tar.gz
58+
ARG doxygen_sha1sum=c50fc71ba9b5e431f0f0f21c5dc8559f47f06007
59+
ADD ${doxygen_urlbase}/${doxygen_archive} /opt/
60+
RUN \
61+
cd /opt \
62+
&& echo "${doxygen_sha1sum} ${doxygen_archive}" | sha1sum -c \
63+
&& tar -xvf ${doxygen_archive} \
64+
&& rm -rf ${doxygen_archive}
65+
ENV PATH=/opt/${doxygen_version}/bin:${PATH}
66+
67+
68+
# GitHub Actions user's UID is 1001
69+
RUN \
70+
useradd ci -m -s /bin/bash -G users --uid=1001 && \
71+
chown -R ci:ci ${EMSDK_DIR}
72+
73+
USER ci
74+
75+
RUN \
76+
cd $HOME && \
77+
mkdir opencv opencv_contrib build && \
78+
git config --global --add safe.directory "*" && \
79+
git config --global user.email "opencv.ci" && \
80+
git config --global user.name "opencv.ci" && \
81+
git config --global pull.rebase false
82+
83+
# Run docker build from the root directory of the repository
84+
COPY scripts/patch_size.py /home/ci/scripts/patch_size.py
85+
COPY scripts/pack_docs.py /home/ci/scripts/
86+
87+
ENV PATH=${EMSDK_DIR}:${EMSDK_DIR}/upstream/emscripten:${EMSDK_DIR}/node/20.18.0_64bit/bin:${PATH}
88+
ENV EMSDK=${EMSDK_DIR}
89+
ENV EM_CONFIG=${EMSDK_DIR}/.emscripten
90+
ENV EM_CACHE=${EMSDK_DIR}/upstream/emscripten/cache
91+
ENV EMSDK_NODE=${EMSDK_DIR}/node/20.18.0_64bit/bin/node
92+
ENV EMSCRIPTEN=${EMSDK_DIR}/upstream/emscripten
93+
ENTRYPOINT ["bash"]

scripts/download_artifacts.sh

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
REPO="opencv/ci-gha-workflow"
6+
DEST_DIR="/home/www/site/webapps/docs/test"
7+
TMP_DIR="/tmp/artifacts"
8+
TOKEN="_insert_your_key"
9+
10+
mkdir -p "$TMP_DIR"
11+
12+
echo "[*] Fetching artifacts list..."
13+
ARTIFACTS=$(curl -s -H "Authorization: token $TOKEN" "https://api.github.com/repos/$REPO/actions/artifacts")
14+
15+
for BRANCH in 4.x 5.x; do
16+
ARTIFACT_NAME="opencv-docs-$BRANCH"
17+
echo "[*] Looking for latest artifact named $ARTIFACT_NAME..."
18+
19+
# Парсим id и дату создания вручную
20+
ARTIFACT_ID=$(echo "$ARTIFACTS" | awk -v name="$ARTIFACT_NAME" '
21+
BEGIN { RS="{"; FS=","; max_time=0; best_id="" }
22+
/"name": *"[^"]+"/ {
23+
this_id=""
24+
this_name=""
25+
this_expired="false"
26+
this_created=""
27+
for (i=1; i<=NF; i++) {
28+
if ($i ~ /"id":/) {
29+
gsub(/[^0-9]/, "", $i)
30+
this_id=$i
31+
}
32+
if ($i ~ /"name":/) {
33+
gsub(/.*"name": *"/, "", $i)
34+
gsub(/".*/, "", $i)
35+
this_name=$i
36+
}
37+
if ($i ~ /"expired":/) {
38+
if ($i ~ /true/) this_expired="true"
39+
}
40+
if ($i ~ /"created_at":/) {
41+
gsub(/.*"created_at": *"/, "", $i)
42+
gsub(/".*/, "", $i)
43+
this_created=$i
44+
}
45+
}
46+
47+
if (this_name == name && this_expired == "false") {
48+
cmd = "date -d \"" this_created "\" +%s"
49+
cmd | getline epoch
50+
close(cmd)
51+
if (epoch > max_time) {
52+
max_time = epoch
53+
best_id = this_id
54+
}
55+
}
56+
}
57+
END { print best_id }
58+
')
59+
60+
if [[ -z "$ARTIFACT_ID" ]]; then
61+
echo "[!] No valid artifact found for $ARTIFACT_NAME"
62+
continue
63+
fi
64+
65+
ZIP_PATH="$TMP_DIR/$ARTIFACT_NAME.zip"
66+
DEST_PATH="$DEST_DIR/$BRANCH"
67+
68+
echo "[*] Downloading $ARTIFACT_NAME (ID: $ARTIFACT_ID) -> $ZIP_PATH"
69+
curl -sL -H "Authorization: token $TOKEN" \
70+
-o "$ZIP_PATH" \
71+
"https://api.github.com/repos/$REPO/actions/artifacts/$ARTIFACT_ID/zip"
72+
73+
echo "[*] Extracting to $DEST_PATH"
74+
mkdir -p "$DEST_PATH"
75+
echo "[*] Cleaning old contents in $DEST_PATH"
76+
rm -rf "$DEST_PATH"/*
77+
TMP_EXTRACT="$TMP_DIR/extract_$BRANCH"
78+
rm -rf "$TMP_EXTRACT"
79+
mkdir -p "$TMP_EXTRACT"
80+
unzip -q -o "$ZIP_PATH" -d "$TMP_EXTRACT"
81+
echo "[*] Moving relevant files to $DEST_PATH"
82+
if [ -d "$TMP_EXTRACT/doc/doxygen/html" ]; then
83+
mv "$TMP_EXTRACT/doc/doxygen/html"/* "$DEST_PATH/"
84+
else
85+
echo "[!] Warning: doc/doxygen/html not found in artifact"
86+
fi
87+
88+
if [ -d "$TMP_EXTRACT/js/bin" ]; then
89+
mv "$TMP_EXTRACT/js/bin"/* "$DEST_PATH/"
90+
else
91+
echo "[!] Warning: js/bin not found in artifact"
92+
fi
93+
94+
done
95+
96+
#echo "[*] Reloading nginx..."
97+
#nginx -s reload
98+
99+
echo "[*] Cleaning old temp zip files..."
100+
find "$TMP_DIR" -type f -name "*.zip" -mtime +1 -delete
101+
102+
echo "[✔] Done."

0 commit comments

Comments
 (0)