Skip to content

Commit bb73576

Browse files
committed
fix: error with embedify, add caching
1 parent 3a2ff56 commit bb73576

File tree

3 files changed

+76
-5
lines changed

3 files changed

+76
-5
lines changed

.github/workflows/mdbook-pr-preview.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,45 @@ jobs:
2525
steps:
2626
- uses: actions/checkout@v4
2727

28+
- name: Cache Cargo registry and git index
29+
uses: actions/cache@v4
30+
with:
31+
path: |
32+
${{ env.CARGO_HOME }}/registry
33+
${{ env.CARGO_HOME }}/git
34+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('scripts/install-mdbook.sh') }}
35+
restore-keys: |
36+
${{ runner.os }}-cargo-registry-
37+
38+
- name: Cache Rust toolchains
39+
uses: actions/cache@v4
40+
with:
41+
path: |
42+
${{ env.RUSTUP_HOME }}/toolchains
43+
${{ env.RUSTUP_HOME }}/update-hashes
44+
key: ${{ runner.os }}-rust-toolchain-${{ hashFiles('scripts/install-mdbook.sh') }}
45+
restore-keys: |
46+
${{ runner.os }}-rust-toolchain-
47+
48+
- name: Cache installed mdBook binaries
49+
id: mdbook-cache
50+
uses: actions/cache@v4
51+
with:
52+
path: |
53+
${{ env.CARGO_HOME }}/bin
54+
key: ${{ runner.os }}-mdbook-bin-${{ hashFiles('scripts/install-mdbook.sh') }}
55+
restore-keys: |
56+
${{ runner.os }}-mdbook-bin-
57+
2858
- name: Install mdBook
59+
if: steps.mdbook-cache.outputs.cache-hit != 'true'
2960
run: bash scripts/install-mdbook.sh
3061
env:
3162
REPO_ROOT: ${{ github.workspace }}
3263

64+
- name: Add Cargo bin to PATH
65+
run: echo "${CARGO_HOME}/bin" >> "$GITHUB_PATH"
66+
3367
- name: Build with mdBook
3468
run: ${{ env.CARGO_HOME }}/bin/mdbook build
3569

.github/workflows/mdbook.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,42 @@ jobs:
3333
RUSTUP_HOME: ${{ github.workspace }}/.rustup
3434
steps:
3535
- uses: actions/checkout@v4
36+
- name: Cache Cargo registry and git index
37+
uses: actions/cache@v4
38+
with:
39+
path: |
40+
${{ env.CARGO_HOME }}/registry
41+
${{ env.CARGO_HOME }}/git
42+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('scripts/install-mdbook.sh') }}
43+
restore-keys: |
44+
${{ runner.os }}-cargo-registry-
45+
46+
- name: Cache Rust toolchains
47+
uses: actions/cache@v4
48+
with:
49+
path: |
50+
${{ env.RUSTUP_HOME }}/toolchains
51+
${{ env.RUSTUP_HOME }}/update-hashes
52+
key: ${{ runner.os }}-rust-toolchain-${{ hashFiles('scripts/install-mdbook.sh') }}
53+
restore-keys: |
54+
${{ runner.os }}-rust-toolchain-
55+
56+
- name: Cache installed mdBook binaries
57+
id: mdbook-cache
58+
uses: actions/cache@v4
59+
with:
60+
path: |
61+
${{ env.CARGO_HOME }}/bin
62+
key: ${{ runner.os }}-mdbook-bin-${{ hashFiles('scripts/install-mdbook.sh') }}
63+
restore-keys: |
64+
${{ runner.os }}-mdbook-bin-
3665
- name: Install mdBook
66+
if: steps.mdbook-cache.outputs.cache-hit != 'true'
3767
run: bash scripts/install-mdbook.sh
3868
env:
3969
REPO_ROOT: ${{ github.workspace }}
70+
- name: Add Cargo bin to PATH
71+
run: echo "${CARGO_HOME}/bin" >> "$GITHUB_PATH"
4072
- name: Setup Pages
4173
if: ${{ !env.ACT }}
4274
id: pages

scripts/install-mdbook.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#!/usr/bin/env bash
22
# Install mdBook and plugins (same versions as CI). Safe to run locally.
33
# Usage: ./scripts/install-mdbook.sh (from repo root)
4-
set -e
4+
set -euo pipefail
55

66
MDBOOK_VERSION="${MDBOOK_VERSION:-0.5.2}"
77
MDBOOK_MERMAID_VERSION="${MDBOOK_MERMAID_VERSION:-0.17.0}"
88
MDBOOK_EMBEDIFY_VERSION="${MDBOOK_EMBEDIFY_VERSION:-0.3.2}"
9+
RUST_TOOLCHAIN_VERSION="${RUST_TOOLCHAIN_VERSION:-1.91.1}"
910

1011
# Install into repo so CI and local use the same layout (avoids cross-device issues in act)
1112
REPO_ROOT="${REPO_ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || echo "$PWD")}"
@@ -14,14 +15,18 @@ export CARGO_HOME="${REPO_ROOT}/.cargo"
1415

1516
echo "Installing Rust and mdBook into ${REPO_ROOT} (RUSTUP_HOME=$RUSTUP_HOME, CARGO_HOME=$CARGO_HOME)"
1617

17-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path
18-
source "${CARGO_HOME}/env"
19-
rustup update
18+
if ! command -v rustup >/dev/null 2>&1; then
19+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path
20+
source "${CARGO_HOME}/env"
21+
fi
22+
23+
rustup toolchain install "${RUST_TOOLCHAIN_VERSION}" --profile minimal
24+
rustup default "${RUST_TOOLCHAIN_VERSION}"
2025

2126
cargo install --version "${MDBOOK_VERSION}" mdbook
2227
cargo install --version "${MDBOOK_MERMAID_VERSION}" mdbook-mermaid
2328
cargo install --version "${MDBOOK_EMBEDIFY_VERSION}" mdbook-embedify
2429

2530
echo "Done. To build the book, use the project mdbook (do not use your global 'mdbook'):"
26-
echo " ./mdbook build"
31+
echo " ${CARGO_HOME}/bin/mdbook build"
2732
echo "Or: source \"${CARGO_HOME}/env\" && mdbook build"

0 commit comments

Comments
 (0)