| # Copyright (c) 2020 Linaro Limited. |
| # SPDX-License-Identifier: Apache-2.0 |
| |
| name: Documentation Build |
| |
| on: |
| push: |
| branches: |
| - main |
| tags: |
| - v* |
| pull_request: |
| |
| permissions: |
| contents: read |
| |
| env: |
| DOXYGEN_VERSION: 1.14.0 |
| DOXYGEN_MD5SUM: e761a5097ae20ecccfd02041925f102a |
| JOB_COUNT: 8 |
| |
| jobs: |
| doc-file-check: |
| name: Check for doc changes |
| runs-on: ubuntu-24.04 |
| outputs: |
| file_check: ${{ steps.check-doc-files.outputs.any_modified }} |
| steps: |
| - name: checkout |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| with: |
| ref: ${{ github.event.pull_request.head.sha }} |
| fetch-depth: 0 |
| - name: Check if Documentation related files changed |
| uses: tj-actions/changed-files@24d32ffd492484c1d75e0c0b894501ddb9d30d62 # v47.0.0 |
| id: check-doc-files |
| with: |
| files: | |
| doc/ |
| boards/**/doc/ |
| **.rst |
| include/ |
| kernel/include/kernel_arch_interface.h |
| lib/libc/** |
| subsys/testsuite/ztest/include/** |
| **/Kconfig* |
| west.yml |
| scripts/dts/ |
| doc/requirements.txt |
| .github/workflows/doc-build.yml |
| scripts/pylib/pytest-twister-harness/src/twister_harness/device/device_adapter.py |
| scripts/pylib/pytest-twister-harness/src/twister_harness/helpers/shell.py |
| |
| doc-build-html: |
| name: "Documentation Build (HTML)" |
| needs: [doc-file-check] |
| if: > |
| needs.doc-file-check.outputs.file_check == 'true' || github.event_name != 'pull_request' |
| runs-on: |
| group: zephyr-runner-v2-linux-x64-4xlarge |
| container: |
| image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.28.6.20251003 |
| options: '--entrypoint /bin/bash' |
| timeout-minutes: 60 |
| concurrency: |
| group: doc-build-html-${{ github.ref }} |
| cancel-in-progress: true |
| env: |
| BASE_REF: ${{ github.base_ref }} |
| |
| |
| steps: |
| |
| - name: Print cloud service information |
| run: | |
| echo "ZEPHYR_RUNNER_CLOUD_PROVIDER = ${ZEPHYR_RUNNER_CLOUD_PROVIDER}" |
| echo "ZEPHYR_RUNNER_CLOUD_NODE = ${ZEPHYR_RUNNER_CLOUD_NODE}" |
| echo "ZEPHYR_RUNNER_CLOUD_POD = ${ZEPHYR_RUNNER_CLOUD_POD}" |
| |
| - name: Apply container owner mismatch workaround |
| run: | |
| # FIXME: The owner UID of the GITHUB_WORKSPACE directory may not |
| # match the container user UID because of the way GitHub |
| # Actions runner is implemented. Remove this workaround when |
| # GitHub comes up with a fundamental fix for this problem. |
| git config --global --add safe.directory ${GITHUB_WORKSPACE} |
| |
| - name: Clone cached Zephyr repository |
| continue-on-error: true |
| run: | |
| git clone --shared /repo-cache/zephyrproject/zephyr . |
| git remote set-url origin ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} |
| |
| - name: Checkout |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| with: |
| ref: ${{ github.event.pull_request.head.sha }} |
| fetch-depth: 0 |
| |
| - name: Environment Setup |
| run: | |
| if [ "${{github.event_name}}" = "pull_request" ]; then |
| git config --global user.email "bot@zephyrproject.org" |
| git config --global user.name "Zephyr Builder" |
| rm -fr ".git/rebase-apply" |
| rm -fr ".git/rebase-merge" |
| git rebase origin/${BASE_REF} |
| git clean -f -d |
| git log --pretty=oneline | head -n 10 |
| fi |
| echo "$HOME/.local/bin" >> $GITHUB_PATH |
| echo "$HOME/.cargo/bin" >> $GITHUB_PATH |
| |
| west init -l . || true |
| west config --global update.narrow true |
| west update --path-cache /repo-cache/zephyrproject 2>&1 1> west.update.log || west update --path-cache /repo-cache/zephyrproject 2>&1 1> west.update.log || ( rm -rf ../modules ../bootloader ../tools && west update --path-cache /repo-cache/zephyrproject) |
| west forall -c 'git reset --hard HEAD' |
| |
| echo "ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-$( cat SDK_VERSION )" >> $GITHUB_ENV |
| |
| - name: Install Python packages required for documentation build |
| run: | |
| pip install -r scripts/requirements-actions.txt --require-hashes |
| pip install -r doc/requirements.txt --require-hashes |
| |
| - name: Build HTML documentation |
| shell: bash |
| run: | |
| if [[ "$GITHUB_REF" =~ "refs/tags/v" ]]; then |
| DOC_TAG="release" |
| else |
| DOC_TAG="development" |
| fi |
| |
| if [[ "${{ github.event_name }}" == "pull_request" ]]; then |
| DOC_TARGET="html-fast" |
| else |
| DOC_TARGET="html" |
| fi |
| |
| DOC_TAG=${DOC_TAG} \ |
| SPHINXOPTS="-j ${JOB_COUNT} -W --keep-going -T" \ |
| SPHINXOPTS_EXTRA="-q -t publish" \ |
| make -C doc ${DOC_TARGET} |
| |
| # API documentation coverage |
| python3 -m coverxygen --xml-dir doc/_build/html/doxygen/xml/ --src-dir include/ --output doc-coverage.info |
| # deprecated page causing issues |
| lcov --remove doc-coverage.info \*/deprecated > new.info |
| genhtml --no-function-coverage --no-branch-coverage new.info -o coverage-report |
| |
| - name: Compress documentation build artifacts |
| run: | |
| tar --use-compress-program="xz -T0" -cf html-output.tar.xz --exclude html/_sources --exclude html/doxygen/xml --directory=doc/_build html |
| tar --use-compress-program="xz -T0" -cf api-output.tar.xz --directory=doc/_build html/doxygen/html |
| tar --use-compress-program="xz -T0" -cf api-coverage.tar.xz coverage-report |
| |
| - name: Upload HTML output |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| with: |
| name: html-output |
| path: html-output.tar.xz |
| |
| - name: Upload Doxygen coverage artifacts |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| with: |
| name: api-coverage |
| path: api-coverage.tar.xz |
| |
| |
| - name: Summarize PR documentation URLs |
| if: github.event_name == 'pull_request' |
| run: | |
| REPO_NAME="${{ github.event.repository.name }}" |
| PR_NUM="${{ github.event.pull_request.number }}" |
| DOC_URL="https://builds.zephyrproject.io/${REPO_NAME}/pr/${PR_NUM}/docs/" |
| API_DOC_URL="https://builds.zephyrproject.io/${REPO_NAME}/pr/${PR_NUM}/docs/doxygen/html/" |
| API_COVERAGE_URL="https://builds.zephyrproject.io/${REPO_NAME}/pr/${PR_NUM}/api-coverage/" |
| |
| echo "${PR_NUM}" > pr_num |
| echo "Documentation will be available shortly at: ${DOC_URL}" >> $GITHUB_STEP_SUMMARY |
| echo "API Documentation will be available shortly at: ${API_DOC_URL}" >> $GITHUB_STEP_SUMMARY |
| echo "API Coverage Report will be available shortly at: ${API_COVERAGE_URL}" >> $GITHUB_STEP_SUMMARY |
| |
| - name: Upload PR number |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| if: github.event_name == 'pull_request' |
| with: |
| name: pr_num |
| path: pr_num |
| |
| doc-build-pdf: |
| name: "Documentation Build (PDF)" |
| needs: [doc-file-check] |
| if: | |
| github.event_name != 'pull_request' |
| runs-on: ubuntu-24.04 |
| timeout-minutes: 120 |
| concurrency: |
| group: doc-build-pdf-${{ github.ref }} |
| cancel-in-progress: true |
| |
| steps: |
| - name: checkout |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| with: |
| path: zephyr |
| |
| - name: Set up Python |
| uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 |
| with: |
| python-version: 3.12 |
| cache: pip |
| cache-dependency-path: doc/requirements.txt |
| |
| - name: install-pkgs |
| run: | |
| sudo apt-get update |
| sudo apt-get install --no-install-recommends graphviz librsvg2-bin \ |
| texlive-latex-base texlive-latex-extra latexmk \ |
| texlive-fonts-recommended texlive-fonts-extra texlive-xetex \ |
| imagemagick fonts-noto xindy |
| wget --no-verbose "https://github.com/doxygen/doxygen/releases/download/Release_${DOXYGEN_VERSION//./_}/doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz" |
| echo "${DOXYGEN_MD5SUM} doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz" | md5sum -c |
| if [ $? -ne 0 ]; then |
| echo "Failed to verify doxygen tarball" |
| exit 1 |
| fi |
| sudo tar xf doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz -C /opt |
| echo "/opt/doxygen-${DOXYGEN_VERSION}/bin" >> $GITHUB_PATH |
| |
| - name: Setup Zephyr project |
| uses: zephyrproject-rtos/action-zephyr-setup@c125c5ebeeadbd727fa740b407f862734af1e52a # v1.0.9 |
| with: |
| app-path: zephyr |
| toolchains: 'arm-zephyr-eabi' |
| enable-ccache: false |
| |
| - name: install-pip-pkgs |
| working-directory: zephyr |
| run: | |
| pip install -r doc/requirements.txt --require-hashes |
| |
| - name: build-docs |
| shell: bash |
| working-directory: zephyr |
| continue-on-error: true |
| run: | |
| if [[ "$GITHUB_REF" =~ "refs/tags/v" ]]; then |
| DOC_TAG="release" |
| else |
| DOC_TAG="development" |
| fi |
| |
| DOC_TAG=${DOC_TAG} \ |
| SPHINXOPTS="-q -j ${JOB_COUNT}" \ |
| LATEXMKOPTS="-quiet -halt-on-error" \ |
| make -C doc pdf |
| |
| - name: upload-build |
| if: always() |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| with: |
| name: pdf-output |
| if-no-files-found: ignore |
| path: | |
| zephyr/doc/_build/latex/zephyr.pdf |
| zephyr/doc/_build/latex/zephyr.log |
| |
| doc-build-status-check: |
| if: always() |
| name: "Documentation Build Status" |
| needs: |
| - doc-build-pdf |
| - doc-file-check |
| - doc-build-html |
| uses: ./.github/workflows/ready-to-merge.yml |
| with: |
| needs_context: ${{ toJson(needs) }} |