Skip to content

Commit 4a58c29

Browse files
committed
Add doxygen check srcipt
1 parent 3658de8 commit 4a58c29

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

ci/doxygen_check.sh

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#!/bin/bash
2+
# SPDX-FileCopyrightText: Copyright (c) 2022-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# CI-specific doxygen script that downloads and uses doxygen 1.9.1
18+
19+
DOXYGEN_VERSION="1.9.1"
20+
CONDA_ENV_NAME="doxygen_ci_${DOXYGEN_VERSION}"
21+
CONDA_PREFIX="/tmp/miniconda3"
22+
23+
# Function to setup miniconda if not available
24+
setup_conda() {
25+
if [ ! -f "${CONDA_PREFIX}/bin/conda" ]; then
26+
echo "Setting up miniconda for CI..."
27+
curl -L "https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh" -o "/tmp/miniconda.sh"
28+
if [ $? -ne 0 ]; then
29+
echo "Error: Failed to download miniconda"
30+
exit 1
31+
fi
32+
33+
bash "/tmp/miniconda.sh" -b -p "${CONDA_PREFIX}"
34+
if [ $? -ne 0 ]; then
35+
echo "Error: Failed to install miniconda"
36+
exit 1
37+
fi
38+
39+
rm -f "/tmp/miniconda.sh"
40+
echo "Miniconda installed successfully"
41+
fi
42+
}
43+
44+
# Function to setup doxygen environment
45+
setup_doxygen_env() {
46+
source "${CONDA_PREFIX}/etc/profile.d/conda.sh"
47+
48+
# Check if environment already exists with correct doxygen version
49+
if conda env list | grep -q "${CONDA_ENV_NAME}"; then
50+
conda activate "${CONDA_ENV_NAME}"
51+
CURRENT_VERSION=$(doxygen --version 2>/dev/null || echo "none")
52+
if [ "${CURRENT_VERSION}" = "${DOXYGEN_VERSION}" ]; then
53+
echo "Using existing doxygen ${DOXYGEN_VERSION} CI environment"
54+
return 0
55+
else
56+
echo "Removing existing CI environment with incorrect version"
57+
conda deactivate 2>/dev/null || true
58+
conda env remove -n "${CONDA_ENV_NAME}" -y
59+
fi
60+
fi
61+
62+
echo "Creating new doxygen ${DOXYGEN_VERSION} CI environment..."
63+
# Accept conda ToS and use only conda-forge channel
64+
conda config --set solver libmamba
65+
conda config --remove channels defaults --force 2>/dev/null || true
66+
conda config --add channels conda-forge
67+
conda create -n "${CONDA_ENV_NAME}" --override-channels -c conda-forge "doxygen=${DOXYGEN_VERSION}" -y
68+
if [ $? -ne 0 ]; then
69+
echo "Error: Failed to create conda environment with doxygen ${DOXYGEN_VERSION}"
70+
exit 1
71+
fi
72+
73+
conda activate "${CONDA_ENV_NAME}"
74+
echo "Doxygen ${DOXYGEN_VERSION} CI environment created and activated"
75+
}
76+
77+
# Setup conda and doxygen environment
78+
setup_conda
79+
setup_doxygen_env
80+
81+
# Verify doxygen version
82+
ACTUAL_VERSION=$(doxygen --version)
83+
echo "Using doxygen version: ${ACTUAL_VERSION}"
84+
85+
# Extract just the version number (ignore git hash suffix)
86+
ACTUAL_VERSION_NUM=$(echo "${ACTUAL_VERSION}" | cut -d' ' -f1)
87+
if [ "${ACTUAL_VERSION_NUM}" != "${DOXYGEN_VERSION}" ]; then
88+
echo "Error: Expected doxygen version ${DOXYGEN_VERSION}, but got ${ACTUAL_VERSION_NUM}"
89+
exit 1
90+
fi
91+
92+
# Run doxygen, ignore missing tag files error
93+
TAG_ERROR1="error: Tag file '.*.tag' does not exist or is not a file. Skipping it..."
94+
TAG_ERROR2="error: cannot open tag file .*.tag for writing"
95+
DOXYGEN_STDERR=`cd doxygen && { cat Doxyfile ; echo QUIET = YES; echo GENERATE_HTML = NO; } | doxygen - 2>&1 | sed "/\($TAG_ERROR1\|$TAG_ERROR2\)/d"`
96+
RETVAL=$?
97+
98+
if [ "$RETVAL" != "0" ] || [ ! -z "$DOXYGEN_STDERR" ]; then
99+
echo -e "\n>>>> FAILED: doxygen check; begin output\n"
100+
echo -e "$DOXYGEN_STDERR"
101+
echo -e "\n>>>> FAILED: doxygen check; end output\n"
102+
RETVAL=1 #because return value is not generated by doxygen 1.8.17
103+
else
104+
echo -e "\n>>>> PASSED: doxygen check\n"
105+
fi
106+
107+
exit $RETVAL

0 commit comments

Comments
 (0)