Skip to content

Commit a4b1e20

Browse files
authored
Fix/redo API docs generation (#454)
Fixes and reworks how we generate the docs. Instead of docker files that build the documentation, it uses the containers provided by Github actions --------- Signed-off-by: Addisu Z. Taddese <[email protected]>
1 parent afd59a1 commit a4b1e20

File tree

4 files changed

+121
-13
lines changed

4 files changed

+121
-13
lines changed

.github/workflows/labeler.yml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44

55
jobs:
66
labeler:
7+
if: github.repository_owner == 'gazebosim'
78
runs-on: ubuntu-latest
89
steps:
910
- uses: actions/labeler@v2

.github/workflows/nightly-upload.yml

+63-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Upload docs to production
1+
name: Deploy API Docs
22

33
on:
44
schedule:
@@ -7,32 +7,82 @@ on:
77
workflow_dispatch:
88

99
jobs:
10+
build:
11+
name: 'Build API Docs (${{ matrix.gazebo_distribution }})'
12+
runs-on: ubuntu-latest
13+
container:
14+
image: ubuntu:${{ matrix.ubuntu_distribution }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
include:
19+
- ubuntu_distribution: focal
20+
gazebo_distribution: citadel
21+
22+
- ubuntu_distribution: focal
23+
gazebo_distribution: fortress
24+
25+
- ubuntu_distribution: focal
26+
gazebo_distribution: garden
27+
28+
- ubuntu_distribution: jammy
29+
gazebo_distribution: harmonic
30+
steps:
31+
- uses: ros-tooling/[email protected]
32+
- name: 'Set up Gazebo'
33+
uses: gazebo-tooling/setup-gazebo@1f55cec330de851fa373f1ade8ac6b7ddfe6f013
34+
with:
35+
required-gazebo-distributions: ${{ matrix.gazebo_distribution }}
36+
- name: 'Add Doxygen'
37+
run: sudo apt-get install -y doxygen graphviz
38+
- name: 'Add missing dependencies'
39+
run: sudo apt-get install -y libopengl-dev
40+
- name: 'Build Docs'
41+
run: |
42+
mkdir -p ws/src
43+
cd ws/src
44+
vcs import --input https://raw.githubusercontent.com/gazebo-tooling/gazebodistro/master/collection-${{ matrix.gazebo_distribution}}.yaml
45+
rm -rf sdformat
46+
rm -rf gz-tools
47+
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install $(sort -u $(find . -iname 'packages-'${{ matrix.ubuntu_distribution}}'.apt' -o -iname 'packages.apt' | grep -v '/\.git/') | tr '\n' ' ')
48+
cd ..
49+
colcon build --merge-install --event-handlers console_cohesion+ --cmake-args -DBUILD_DOCS=ON -DBUILD_TESTING=OFF --cmake-target doc
50+
- uses: actions/upload-artifact@v4
51+
if: always()
52+
with:
53+
name: api-docs-${{ matrix.gazebo_distribution }}
54+
path: ws/build/**/doxygen/html
55+
1056
upload:
1157
name: Upload docs to production
12-
runs-on: ubuntu-20.04
58+
needs: build
59+
runs-on: ubuntu-latest
1360
permissions:
1461
id-token: write
1562
contents: read
1663
steps:
1764
- name: Checkout
18-
uses: actions/checkout@v2
65+
uses: actions/checkout@v4
1966
- name: Configure AWS Credentials
2067
id: creds
2168
uses: aws-actions/configure-aws-credentials@v4
2269
with:
2370
aws-region: us-east-1
2471
role-to-assume: arn:aws:iam::200670743174:role/github-oidc-deployment-gz-web-app
25-
# Need to run ./build_docs.sh
26-
output-credentials: true
72+
- uses: actions/download-artifact@v4
73+
id: download
74+
with:
75+
path: .api-docs
76+
pattern: api-docs-*
77+
merge-multiple: true
78+
- name: 'Restructure API Docs'
79+
run: python3 tools/restructure_doxygen_artifacts.py ${{steps.download.outputs.download-path}} .api-out
80+
- uses: actions/upload-artifact@v4
81+
with:
82+
name: api-docs
83+
path: .api-out/*
2784
- name: Run nightly upload
28-
run: |
29-
cd tools && ./build_docs.sh all
30-
shell: bash
31-
env:
32-
GZ_VERSION_PASSWORD: ${{ secrets.GZ_VERSION_PASSWORD }}
33-
AWS_ACCESS_KEY_ID: ${{ steps.creds.outputs.aws-access-key-id }}
34-
AWS_SECRET_ACCESS_KEY: ${{ steps.creds.outputs.aws-secret-access-key }}
35-
AWS_SESSION_TOKEN: ${{ steps.creds.outputs.aws-session-token }}
85+
run: aws s3 sync .api-out/ s3://gazebosim.org/api/
3686
- name: Invalidate Cloudfront distribution
3787
run: |
3888
aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} --paths '/*' --region us-east-1

.github/workflows/triage.yml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
name: Ticket opened
77
jobs:
88
assign:
9+
if: github.repository_owner == 'gazebosim'
910
name: Add ticket to inbox
1011
runs-on: ubuntu-latest
1112
steps:
+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Usage
2+
# /restructure_doxygen_artifacts.py <path_to_artifacts> <output_directory>
3+
#
4+
# Given a directory containing merged doxygen build artifacts, this script reorganizes them so they
5+
# can be deployed to the website
6+
# This assumes the following directory structure:
7+
# ignition-utils1
8+
# doxygen
9+
# html
10+
# gz-utils2
11+
# doxygen
12+
# html
13+
# ignition-math6
14+
# doxygen
15+
# html
16+
# gz-math7
17+
# doxygen
18+
# html
19+
# ...
20+
#
21+
# The result should look like
22+
# utils
23+
# 1 (content of ignition-utils1/doxygen/html)
24+
# 2 (content of gz-utils2/doxygen/html)
25+
# math
26+
# 6 (content of ignition-math6/doxygen/html)
27+
# 7 (content of gz-math7/doxygen/html)
28+
29+
import re
30+
import sys
31+
import pathlib
32+
import shutil
33+
34+
input_dir = pathlib.Path(sys.argv[1])
35+
output_dir = pathlib.Path(sys.argv[2])
36+
output_dir.mkdir(exist_ok=True)
37+
38+
re_expr = R"(ignition|gz)-([a-z_]*)(\d*)"
39+
40+
41+
def copy_library(lib_html, lib_name, lib_version):
42+
output_lib_dir = output_dir / lib_name / lib_version
43+
output_lib_dir.mkdir(exist_ok=True, parents=True)
44+
print(f"{lib_html} -> {output_lib_dir}")
45+
shutil.copytree(lib_html, output_lib_dir, dirs_exist_ok=True)
46+
47+
48+
for lib in input_dir.iterdir():
49+
m = re.match(re_expr, lib.name)
50+
if m:
51+
_, lib_name, lib_version = m.groups()
52+
lib_html = lib/"doxygen"/"html"
53+
copy_library(lib_html, lib_name, lib_version)
54+
# Handle gazebo->sim rename by making a copy into the sim directory
55+
if lib_name == "gazebo":
56+
copy_library(lib_html, "sim", lib_version)

0 commit comments

Comments
 (0)