Skip to content

Commit 9475512

Browse files
authored
Merge pull request intel#115 from elbeno/docs-config
🐛 📚 Fix mermaid diagram generation on Ubuntu
2 parents 53a3a03 + ff13ef0 commit 9475512

File tree

11 files changed

+47
-17
lines changed

11 files changed

+47
-17
lines changed

.github/workflows/asciidoctor-ghpages.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ jobs:
4040
node-version: 20
4141
- name: Install Mermaid
4242
run: |
43-
sudo npm install -g @mermaid-js/[email protected]
43+
sudo npm install -g @mermaid-js/[email protected]
44+
npx puppeteer browsers install chrome-headless-shell
4445
- name: Install asciidoctor
4546
run: |
4647
sudo apt update

.github/workflows/test.yml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ jobs:
4141

4242
- name: Install Mermaid
4343
run: |
44-
sudo npm install -g @mermaid-js/[email protected]
44+
sudo npm install -g @mermaid-js/[email protected]
45+
npx puppeteer browsers install chrome-headless-shell
4546
4647
- name: Install asciidoctor
4748
run: |
@@ -75,32 +76,32 @@ jobs:
7576
run: |
7677
pip install mypy black
7778
78-
- name: Restore CPM cache
79-
env:
80-
cache-name: cpm-cache-0
81-
id: cpm-cache-restore
82-
uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
83-
with:
84-
path: ~/cpm-cache
85-
key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
86-
restore-keys: |
87-
${{runner.os}}-${{env.cache-name}}-
88-
8979
- name: Configure cmake for lib
9080
env:
9181
CC: "/usr/lib/llvm-${{env.TARGET_LLVM_VERSION}}/bin/clang"
9282
CXX: "/usr/lib/llvm-${{env.TARGET_LLVM_VERSION}}/bin/clang++"
9383
PR_TARGET_BRANCH: ${{ steps.target_branch.outputs.branch }}
9484
working-directory: ${{github.workspace}}/test/library
95-
run: cmake -Bbuild -DCPM_SOURCE_CACHE=~/cpm-cache
85+
run: cmake -Bbuild
9686

9787
- name: Check lib quality
9888
working-directory: ${{github.workspace}}/test/library
9989
run: cmake --build build -t ci-quality
10090

10191
- name: Build lib docs
10292
working-directory: ${{github.workspace}}/test/library
103-
run: cmake --build build -t docs
93+
run: test $(cmake --build build -v -t docs | grep -c ERROR) == 0
94+
95+
- name: Restore CPM cache
96+
env:
97+
cache-name: cpm-cache-0
98+
id: cpm-cache-restore
99+
uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
100+
with:
101+
path: ~/cpm-cache
102+
key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
103+
restore-keys: |
104+
${{runner.os}}-${{env.cache-name}}-
104105
105106
- name: Configure cmake for app
106107
env:

ci/.github/workflows/asciidoctor-ghpages.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ jobs:
4040
node-version: 20
4141
- name: Install Mermaid
4242
run: |
43-
sudo npm install -g @mermaid-js/[email protected]
43+
sudo npm install -g @mermaid-js/[email protected]
44+
npx puppeteer browsers install chrome-headless-shell
4445
- name: Install asciidoctor
4546
run: |
4647
sudo apt update

cmake/main.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ option(INFRA_PROVIDE_PRESETS "Provide cmake presets and toolchains" ON)
2828
option(INFRA_PROVIDE_MULL "Provide mull.yml file" ON)
2929
option(INFRA_PROVIDE_PYTEST_REQS
3030
"Provide pip requirements.txt for python tests" ON)
31+
option(
32+
INFRA_PROVIDE_PUPPETEER_CONFIG
33+
"Provide puppeteer_config.json for generating mermaid diagrams in documentation"
34+
ON)
3135
option(INFRA_PROVIDE_GITIGNORE "Add provided things to .gitignore" ON)
3236
option(INFRA_USE_SYMLINKS "Use symlinks to provide common files" ON)
3337

@@ -38,6 +42,8 @@ if(${PROJECT_SOURCE_DIR}/cmake STREQUAL CMAKE_CURRENT_LIST_DIR)
3842
set(INFRA_PROVIDE_CMAKE_FORMAT OFF)
3943
set(INFRA_PROVIDE_PRESETS OFF)
4044
set(INFRA_PROVIDE_MULL OFF)
45+
set(INFRA_PROVIDE_PYTEST_REQS OFF)
46+
set(INFRA_PROVIDE_PUPPETEER_CONFIG OFF)
4147
set(INFRA_PROVIDE_GITIGNORE OFF)
4248
endif()
4349

cmake/setup.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ function(make_gitignore)
4646
list(APPEND GITIGNORE_CONTENTS "requirements.txt")
4747
endif()
4848
endif()
49+
if(INFRA_PROVIDE_PUPPETEER_CONFIG)
50+
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/docs/puppeteer_config.json")
51+
list(APPEND GITIGNORE_CONTENTS "docs/puppeteer_config.json")
52+
endif()
53+
endif()
4954
endif()
5055

5156
string(REPLACE ";" "\n" GITIGNORE_CONTENTS "${GITIGNORE_CONTENTS}")
@@ -61,6 +66,10 @@ function(make_gitignore)
6166
endfunction()
6267

6368
function(put_in_project_dir FILENAME)
69+
get_filename_component(DIRNAME ${FILENAME} DIRECTORY)
70+
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory
71+
"${CMAKE_SOURCE_DIR}/${DIRNAME}")
72+
6473
if(INFRA_USE_SYMLINKS)
6574
set(put_command "create_symlink")
6675
else()
@@ -120,6 +129,9 @@ if(PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
120129
if(INFRA_PROVIDE_PYTEST_REQS)
121130
put_in_project_dir("requirements.txt")
122131
endif()
132+
if(INFRA_PROVIDE_PUPPETEER_CONFIG)
133+
put_in_project_dir("docs/puppeteer_config.json")
134+
endif()
123135

124136
if(INFRA_PROVIDE_GITHUB_WORKFLOWS)
125137
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory

docs/index.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
:rouge-style: base16.solarized
66
:source-language: c++
77
:toc: left
8+
:mermaid-puppeteer-config: puppeteer_config.json
89

910
include::intro.adoc[]
1011
include::options.adoc[]

docs/puppeteer_config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"args": ["--no-sandbox"]
3+
}

test/application/clean.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ rm -f mull.yml
99
rm -f .gitignore
1010
rm -f CMakePresets.json
1111
rm -f toolchains
12+
rm -f requirements.txt
1213

14+
rm -rf docs
1315
rm -rf build
1416
rm -rf .github

test/library/clean.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ rm -f mull.yml
99
rm -f .gitignore
1010
rm -f CMakePresets.json
1111
rm -f toolchains
12+
rm -f requirements.txt
13+
rm -f docs/puppeteer_config.json
1214

1315
rm -rf build
1416
rm -rf .github

test/library/docs/index.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Ben Deane <[email protected]>
66
:rouge-style: base16.solarized
77
:source-language: c++
88
:toc: left
9+
:mermaid-puppeteer-config: puppeteer_config.json
910

1011
== Introduction
1112

0 commit comments

Comments
 (0)