Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
# SPDX-FileCopyrightText: Copyright (c) 2021-2026 TiaC Systems
# SPDX-FileCopyrightText: Copyright (c) 2021 Li-Pro.Net
# SPDX-License-Identifier: Apache-2.0
name: Documentation Build
on:
workflow_dispatch: # And manually on button click
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
- 'v*-branch'
paths:
- 'VERSION'
- 'doc/**'
- '**.rst'
- 'include/**'
- '.known-issues/doc/**'
- '**/Kconfig*'
- 'zephyr/requirements-*'
- 'zephyr/requirements.txt'
- 'submanifests/*.yml'
- 'west.yml'
- '.github/workflows/doc-*.yml'
push:
tags:
- 'v*'
branches:
- main
- 'v*-branch'
paths:
- 'VERSION'
- 'doc/**'
- '**.rst'
- 'include/**'
- '.known-issues/doc/**'
- '**/Kconfig*'
- 'zephyr/requirements-*'
- 'zephyr/requirements.txt'
- 'submanifests/*.yml'
- 'west.yml'
- '.github/workflows/doc-*.yml'
jobs:
doc-build:
name: Build and upload documentation to artifacts
if: ${{ github.repository_owner == 'tiacsys' }}
runs-on: [self-hosted, ci-32g-x8, linux, x64, container, for-zephyr-doc]
container:
image: ghcr.io/zephyrproject-rtos/ci:v0.29.3
options: '--cpus 4 --memory 8g --entrypoint /bin/bash'
env:
ZEPHYR_SDK_INSTALL_DIR: /opt/toolchains/zephyr-sdk-1.0.1
defaults:
run:
shell: bash
steps:
- 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: Apply container HTTP/2 framing layer workaround
run: |
# FIXME: For unknown reasons, the local development host and CI is
# running in temporary "Error in the HTTP2 framing layer".
# Forcing the historical but still supported HTTP/1.1 layer
# seems to be a stable workaround - happened in Oct. 2023.
git config --global --add http.version HTTP/1.1
- name: Update GitHub PATH for west
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH
# It is important that this is run before any caching tasks as cleanups
# are run in reverse order (and you do not want to cleanup before the
# caching is saved).
- name: Clean working directory
uses: tiacsys/clean-after-action@v4
#
# Could also be implemented with the new pre- and post-job hook scripts:
#
# - https://stackoverflow.com/questions/70483902
# - https://devopsjournal.io/blog/2023/06/21/GitHub-container-based-Action-cleanup
# - https://docs.github.com/actions/hosting-your-own-runners/running-scripts-before-or-after-a-job
#
with:
keep-git: false
- name: Checkout the code
uses: actions/checkout@v7
with:
fetch-depth: 100
show-progress: true
path: workspace/bridle
ref: ${{ github.ref }}
- name: Install system packages
run: |
sudo add-apt-repository -y -u ppa:tiac-systems/doxygen
sudo apt-get install -y git ninja-build python3-pip wget
sudo apt-get install -y doxygen mscgen graphviz lcov
- name: Install uv
uses: astral-sh/setup-uv@v10.0.1
with:
working-directory: workspace
enable-cache: true
- name: Create and enter Python 3.12 virtual environment
working-directory: workspace
run: |
uv venv --python 3.12 --clear .venv
source .venv/bin/activate
echo "$PATH" > $GITHUB_PATH
- name: Setup Zephyr SDK
run: |
"${ZEPHYR_SDK_INSTALL_DIR}/setup.sh" -t all -l -h -c
- name: Install base dependencies
working-directory: workspace
run: |
which python3 && python3 --version
which uv && uv --version
uv pip install --upgrade --requirement bridle/zephyr/requirements-base.txt
uv pip show --files west
which west && west --version
- name: West init and update
working-directory: workspace
run: |
west init --local bridle
west update --fetch-opt=--depth=100 --fetch=always --narrow --stats
west zephyr-export
west bridle-export
- name: Install documentation dependencies
working-directory: workspace
run: |
# uv pip install --upgrade --requirement zephyr/scripts/requirements-actions.txt
# uv pip install --upgrade --requirement zephyr/doc/requirements.txt
# uv pip install --upgrade --requirement bridle/zephyr/requirements-doc.txt
# uv pip install coverxygen==1.8.1
west packages pip | xargs uv pip install --upgrade
uv pip install coverxygen==1.8.1
- name: Build documentation
working-directory: workspace
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
cmake -DDT_TURBO_MODE=1 -DHW_FEATURES_TURBO_MODE=1 \
-B build -GNinja bridle/doc
else
cmake -B build -GNinja bridle/doc
fi
ninja -C build build-all
- name: API documentation coverage
working-directory: workspace
run: |
for api in zephyr bridle; do
python3 -m coverxygen --scope all --kind all --src-dir ${api} \
--xml-dir build/html/${api}/doxygen/xml \
--output apidoc-coverage-${api}.info \
--format lcov
lcov --ignore-errors unused \
--remove apidoc-coverage-${api}.info \*/deprecated \
--remove apidoc-coverage-${api}.info \*/_doxygen\* \
--output-file apidoc-coverage-${api}-interim.info
genhtml --no-function-coverage --no-branch-coverage \
--output-directory build/apidoc-coverage-report/${api} \
apidoc-coverage-${api}-interim.info
rm -vf apidoc-coverage-${api}*.info
done
- name: Compress documentation
working-directory: workspace/build
run: |
# tar --use-compress-program="xz -T0" -cf html-output.tar.xz \
# --exclude html/*/_sources --exclude html/*/doxygen/xml \
# html
tar --use-compress-program="xz -T0" -cf api-output.tar.xz \
html/*/doxygen/html
tar --use-compress-program="xz -T0" -cf api-coverage.tar.xz \
apidoc-coverage-report
- name: Archive documentation
working-directory: workspace/build
run: |
# synopsys: publish2 <catalog> <version> <archive>
# <catalog> := {development|approved}
# <version> := {latest|<branch>}
# <archive> := doc_build_<GITHUB_RUN_ID_from_doc-build>.tgz
mkdir doc && cd doc
archive="doc_build_${GITHUB_RUN_ID}.tgz"
tar -C ../html -zcf ${archive} .
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
# basename will work for both branches and tags
branch=$(basename "${{ github.ref }}")
echo "publish2 preview REF-${branch} ${archive}" > "monitor_${GITHUB_RUN_ID}.txt"
else
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "publish2 development PR-${{ github.event.number }} ${archive}" > \
"monitor_${GITHUB_RUN_ID}.txt"
echo "${{ github.event.number }}" > pr.txt
else
# basename will work for both branches and tags
branch=$(basename "${{ github.ref }}")
if [[ "${branch}" == "main" ]]; then
echo "publish2 approved latest ${archive}" > "monitor_${GITHUB_RUN_ID}.txt"
else
echo "publish2 approved ${branch} ${archive}" > "monitor_${GITHUB_RUN_ID}.txt"
fi
fi
fi
- name: Clean documentation before uploads
working-directory: workspace/build
run: |
rm -rf html
echo "READY FOR UPLOAD from $(pwd)/doc"
ls -alh $(pwd)/doc $(pwd)/api-*.tar.xz
df -hT $(pwd)/doc
- name: Upload API coverage report
uses: actions/upload-artifact@v7
with:
name: api-coverage
path: workspace/build/api-coverage.tar.xz
- name: Upload API documentation
uses: actions/upload-artifact@v7
with:
name: api-output
path: workspace/build/api-output.tar.xz
# - name: Upload HTML documentation
# uses: actions/upload-artifact@v7
# with:
# name: html-output
# path: workspace/build/html-output.tar.xz
- name: Upload archived documentation
uses: actions/upload-artifact@v7
with:
name: doc
path: workspace/build/doc
55022eb50This file is pinned to the selected release. Download the original to open it in your design tool.