Skip to content

Commit b5fdf57

Browse files
authored
Add CI workflow to build guide books (#13)
* Add build book job to CI * Test book build breakage * `execute_process()`: treat errors as fatal * Revert deliberate breakage
1 parent 569d91f commit b5fdf57

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: ci-push
1+
name: ci
22
on:
33
push:
44
branches-ignore:

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: build book
2525
run: |
2626
cd guide
27-
cmake -P build.cmake
27+
cmake -P build.cmake || exit 1
2828
ls book
2929
- name: setup pages
3030
uses: actions/configure-pages@v4

.github/workflows/guide.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: ci-guide
2+
on:
3+
push:
4+
branches-ignore:
5+
- staging
6+
jobs:
7+
build-book:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
with:
12+
fetch-depth: 0
13+
- name: init
14+
run: |
15+
url="https://github.com/rust-lang/mdBook/releases/download/v0.4.47/mdbook-v0.4.47-x86_64-unknown-linux-gnu.tar.gz"
16+
mkdir mdbook
17+
curl -sSL $url | tar -xz --directory=./mdbook
18+
echo `pwd`/mdbook >> $GITHUB_PATH
19+
- name: build
20+
run: |
21+
cd guide
22+
cmake -P build.cmake || exit 1
23+
ls book

guide/build.cmake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function(BuildBook LANGUAGE SOURCE_DIR TARGET_DIR)
66
message(WARNING "Skipping '${LANGUAGE}' – SUMMARY.md not found at ${SOURCE_DIR}")
77
return()
88
endif()
9-
9+
1010
if(NOT EXISTS "${SOURCE_DIR}/book.toml")
1111
message(WARNING "Skipping '${LANGUAGE}' – book.toml not found at ${SOURCE_DIR}")
1212
return()
@@ -16,10 +16,11 @@ function(BuildBook LANGUAGE SOURCE_DIR TARGET_DIR)
1616
execute_process(
1717
COMMAND mdbook build -d ${TARGET_DIR}
1818
WORKING_DIRECTORY ${SOURCE_DIR}
19+
COMMAND_ERROR_IS_FATAL ANY
1920
)
2021
endfunction()
2122

22-
# Copy the theme folder
23+
# Copy the theme folder
2324
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/theme" DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/translations")
2425

2526
BuildBook("en" "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/book")

0 commit comments

Comments
 (0)