Skip to content

Commit 788162f

Browse files
committed
Move docs workflow into Justfile + container
This drains nontrivial logic out GHA and into something isolated via containers and driven via `Justfile` and easily replicable locally too. Signed-off-by: Colin Walters <[email protected]>
1 parent 9a6df09 commit 788162f

File tree

5 files changed

+62
-69
lines changed

5 files changed

+62
-69
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -108,39 +108,15 @@ jobs:
108108
sudo find /ostree/repo/objects -name '*.file' -type f | while read f; do
109109
sudo fsverity measure $f >/dev/null
110110
done
111-
# Build documentation using mdBook (only for PRs with 'documentation' label)
112-
# TODO move into Justfile
111+
# Test that we can build documentation
113112
docs:
114-
if: ${{ contains(github.event.pull_request.labels.*.name, 'documentation') }}
115113
runs-on: ubuntu-24.04
116-
env:
117-
MDBOOK_VERSION: 0.4.37
118114
steps:
119115
- uses: actions/checkout@v4
120-
- name: Install mdBook
121-
run: |
122-
tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name')
123-
url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz"
124-
mkdir mdbook
125-
curl -sSL $url | tar -xz --directory=./mdbook
126-
echo `pwd`/mdbook >> $GITHUB_PATH
127-
- name: Install mdbook-mermaid
128-
run: |
129-
tag=$(curl 'https://api.github.com/repos/badboy/mdbook-mermaid/releases/latest' | jq -r '.tag_name')
130-
url="https://github.com/badboy/mdbook-mermaid/releases/download/${tag}/mdbook-mermaid-${tag}-x86_64-unknown-linux-gnu.tar.gz"
131-
mkdir mdbook-mermaid
132-
curl -sSL $url | tar -xz --directory=./mdbook-mermaid
133-
echo `pwd`/mdbook-mermaid >> $GITHUB_PATH
134-
- name: Install mdbook-linkcheck
135-
run: |
136-
tag=$(curl 'https://api.github.com/repos/Michael-F-Bryan/mdbook-linkcheck/releases/latest' | jq -r '.tag_name')
137-
archive="mdbook-linkcheck.x86_64-unknown-linux-gnu.zip"
138-
url="https://github.com/Michael-F-Bryan/mdbook-linkcheck/releases/download/${tag}/${archive}"
139-
mkdir mdbook-linkcheck
140-
curl -sSL -O $url && unzip ${archive} -d ./mdbook-linkcheck && chmod +x ./mdbook-linkcheck/mdbook-linkcheck
141-
echo `pwd`/mdbook-linkcheck >> $GITHUB_PATH
142-
- name: Build with mdBook
143-
run: cd docs && mdbook-mermaid install && mdbook build
116+
- name: Bootc Ubuntu Setup
117+
uses: ./.github/actions/bootc-ubuntu-setup
118+
- name: Build mdbook
119+
run: just build-mdbook
144120
# Build containers and disk images for integration testing across OS matrix
145121
build-integration:
146122
strategy:

.github/workflows/docs.yml

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,53 +14,22 @@ concurrency:
1414
group: "pages"
1515
cancel-in-progress: false
1616

17-
# To build the docs locally you can also do e.g.:
18-
# cargo install mdbook-mermaid
19-
# cd docs
20-
# mdbook-mermaid install
21-
# mdbook serve
22-
2317
jobs:
2418
build:
25-
runs-on: ubuntu-latest
26-
env:
27-
MDBOOK_VERSION: 0.4.37
19+
runs-on: ubuntu-24.04
2820
steps:
2921
- uses: actions/checkout@v4
30-
- name: Install mdBook
31-
run: |
32-
tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name')
33-
url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz"
34-
mkdir mdbook
35-
curl -sSL $url | tar -xz --directory=./mdbook
36-
echo `pwd`/mdbook >> $GITHUB_PATH
37-
- name: Install mdbook-mermaid
38-
run: |
39-
tag=$(curl 'https://api.github.com/repos/badboy/mdbook-mermaid/releases/latest' | jq -r '.tag_name')
40-
url="https://github.com/badboy/mdbook-mermaid/releases/download/${tag}/mdbook-mermaid-${tag}-x86_64-unknown-linux-gnu.tar.gz"
41-
mkdir mdbook-mermaid
42-
curl -sSL $url | tar -xz --directory=./mdbook-mermaid
43-
echo `pwd`/mdbook-mermaid >> $GITHUB_PATH
44-
- name: Install mdbook-linkcheck
45-
run: |
46-
tag=$(curl 'https://api.github.com/repos/Michael-F-Bryan/mdbook-linkcheck/releases/latest' | jq -r '.tag_name')
47-
archive="mdbook-linkcheck.x86_64-unknown-linux-gnu.zip"
48-
url="https://github.com/Michael-F-Bryan/mdbook-linkcheck/releases/download/${tag}/${archive}"
49-
mkdir mdbook-linkcheck
50-
curl -sSL -O $url && unzip ${archive} -d ./mdbook-linkcheck && chmod +x ./mdbook-linkcheck/mdbook-linkcheck
51-
echo `pwd`/mdbook-linkcheck >> $GITHUB_PATH
22+
- name: Bootc Ubuntu Setup
23+
uses: ./.github/actions/bootc-ubuntu-setup
24+
- name: Build mdbook
25+
run: mkdir target && just build-mdbook-to target/docs
5226
- name: Setup Pages
5327
id: pages
5428
uses: actions/configure-pages@v5
55-
- name: Install mdbook_header_footer
56-
run: |
57-
cargo install mdbook_header_footer
58-
- name: Build with mdBook
59-
run: cd docs && mdbook-mermaid install && mdbook build
6029
- name: Upload artifact
6130
uses: actions/upload-pages-artifact@v3
6231
with:
63-
path: ./docs/book/html
32+
path: ./target/docs
6433

6534
deploy:
6635
environment:

Justfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,24 @@ test-container: build-units build-integration-test-image
6565
podman run --rm --read-only localhost/bootc-units /usr/bin/bootc-units
6666
podman run --rm localhost/bootc-integration bootc-integration-tests container
6767

68+
build-mdbook:
69+
cd docs && podman build -t localhost/bootc-mdbook -f Dockerfile.mdbook
70+
71+
# Generate the rendered HTML to the target DIR directory
72+
build-mdbook-to DIR: build-mdbook
73+
#!/bin/bash
74+
set -xeuo pipefail
75+
# Create a temporary container to extract the built docs
76+
container_id=$(podman create localhost/bootc-mdbook)
77+
podman cp ${container_id}:/src/book {{DIR}}
78+
podman rm -f ${container_id}
79+
80+
mdbook-serve: build-mdbook
81+
#!/bin/bash
82+
set -xeuo pipefail
83+
podman run --init --replace -d --name bootc-mdbook --rm --publish 127.0.0.1::8000 localhost/bootc-mdbook
84+
echo http://$(podman port bootc-mdbook 8000/tcp)
85+
6886
# Update all generated files (man pages and JSON schemas)
6987
#
7088
# This is the unified command that:

docs/Dockerfile.mdbook

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
FROM registry.access.redhat.com/ubi10/ubi:latest
2+
# An intermediate layer which caches the RPMS
3+
RUN <<EORUN
4+
set -xeuo pipefail
5+
dnf -y install cargo rust jq unzip
6+
dnf clean all
7+
EORUN
8+
# See main Dockerfile for rust caching
9+
RUN --mount=type=cache,target=/src/target --mount=type=cache,target=/var/roothome <<EORUN
10+
set -xeuo pipefail
11+
12+
# Bootstrap cargo-binstall
13+
export PATH=$HOME/.cargo/bin:$PATH
14+
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
15+
16+
17+
18+
19+
20+
cargo binstall --no-confirm ${deps[@]}
21+
mv ~/.cargo/bin/* /usr/bin/
22+
23+
EORUN
24+
# And now actually build the docs
25+
WORKDIR /src
26+
COPY . /src
27+
RUN <<EORUN
28+
set -xeuo pipefail
29+
mdbook-mermaid install .
30+
mdbook build
31+
EORUN
32+
CMD ["mdbook", "serve", "-n", "0.0.0.0", "-p", "8000"]
33+
EXPOSE 8000

docs/book.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,3 @@ footers = [
1616

1717
[output.html]
1818
additional-js = ["mermaid.min.js", "mermaid-init.js"]
19-
20-
[output.linkcheck]
21-
optional = true

0 commit comments

Comments
 (0)