Skip to content

Commit

Permalink
Setup mdbook checks and GitHub pages (#19)
Browse files Browse the repository at this point in the history
* feat(ci): test book code snippets

* feat(ci): deploy design document to github pages

* feat(ci): also run `mdbook build` in normal checks
  • Loading branch information
BD103 authored Sep 19, 2024
1 parent f767f09 commit fdcd0a0
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/book.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build and publish book

on:
push:
branches: [main]
workflow_dispatch:

env:
# This can be any valid Cargo version requirement, but should start with a caret `^` to opt-in to
# SemVer-compatible changes. Please keep this in sync with `ci.yaml`.
MDBOOK_VERSION: ^0.4.40

permissions:
# Required to checkout repository.
contents: read
# Both are required to deploy to GitHub pages.
pages: write
id-token: write

# Only allow one deployment to run at a time.
concurrency:
group: pages
cancel-in-progress: false

jobs:
build:
name: Build and publish book
runs-on: ubuntu-latest
timeout-minutes: 30
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Install mdbook
run: cargo install mdbook --version ${{ env.MDBOOK_VERSION }}

- name: Build book
working-directory: design-book
run: mdbook build

- name: Upload pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: design-book/book

- name: Deploy to GitHub pages
id: deployment
uses: actions/deploy-pages@v4
26 changes: 26 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ env:
CARGO_TERM_COLOR: always
RUSTFLAGS: --deny warnings
RUSTDOCFLAGS: --deny warnings
# This can be any valid Cargo version requirement, but should start with a caret `^` to opt-in to
# SemVer-compatible changes. Please keep this in sync with `book.yaml`.
MDBOOK_VERSION: ^0.4.40

jobs:
# Run tests.
Expand Down Expand Up @@ -104,3 +107,26 @@ jobs:

- name: Check documentation
run: cargo doc --locked --workspace --all-features --document-private-items --no-deps

# Check design book.
book:
name: Book
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Install mdbook
run: cargo install mdbook --version ${{ env.MDBOOK_VERSION }}

- name: Build book
working-directory: design-book
run: mdbook build

- name: Test code samples
working-directory: design-book
run: mdbook test

0 comments on commit fdcd0a0

Please sign in to comment.