Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 33 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
submodules: true
- name: Update rustup
run: rustup self update
- name: Install Rust
Expand All @@ -32,16 +34,18 @@ jobs:
# sure all the crates can be resolved when running the tests.
- name: Build `trpl` crate
run: |
cd packages/trpl
cd mdbook-check/packages/trpl
cargo build
- name: Run tests
run:
mdbook test --library-path packages/trpl/target/debug/deps
mdbook test --library-path mdbook-check/packages/trpl/target/debug/deps
package_tests:
name: Run package tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
submodules: true
- name: Update rustup
run: rustup self update
- name: Install Rust
Expand All @@ -53,14 +57,21 @@ jobs:
run: |
cargo test
- name: Run `mdbook-trpl` package tests
working-directory: packages/mdbook-trpl
working-directory: mdbook-check/packages/mdbook-trpl
run: |
cargo test
lint:
name: Run lints
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
submodules: recursive
fetch-depth: 0
- name: Force fetch submodules
run: |
git submodule update --init
git submodule foreach --recursive git submodule update --init
- name: Update rustup
run: rustup self update
- name: Install Rust
Expand All @@ -74,7 +85,7 @@ jobs:
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.45/mdbook-v0.4.45-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
echo "$(pwd)/bin" >> "${GITHUB_PATH}"
- name: Install mdbook-trpl binaries
run: cargo install --path packages/mdbook-trpl
run: cargo install --path mdbook-check/packages/mdbook-trpl
- name: Install aspell
run: sudo apt-get install aspell
- name: Install shellcheck
Expand All @@ -87,18 +98,33 @@ jobs:
aspell --version
shellcheck --version
- name: Shellcheck
run: find . -name '*.sh' -print0 | xargs -0 shellcheck
run: |
exclude_dirs=(
"*/packages/autocorrect/**"
"*/src/fuzz/books/codes/.venv/**"
"*/book/**"
)

find_args=()

for pattern in "${exclude_dirs[@]}"; do
find_args+=(-not -path "$pattern")
done

find . -name "*.sh" -type f "${find_args[@]}" -exec shellcheck {} +
- name: Spellcheck
run: bash ci/spellcheck.sh list
run: bash mdbook-check/ci/spellcheck.sh list
- name: Lint for local file paths
run: |
mdbook build
cargo run --bin lfp src
- name: Validate references
run: bash ci/validate.sh
run: bash mdbook-check/ci/validate.sh
- name: Check for broken links
run: |
curl -sSLo linkcheck.sh \
https://raw.githubusercontent.com/rust-lang/rust/HEAD/src/tools/linkchecker/linkcheck.sh
# Cannot use --all here because of the generated redirect pages aren't available.
sh linkcheck.sh book
- name: Check Markdown Lint
run: make check-lint
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "mdbook-check"]
path = mdbook-check
url = [email protected]:ChenMiaoi/mdbook-check.git
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
members = ["packages/tools"]
default-members = ["packages/tools"]
members = ["mdbook-check/packages/tools"]
default-members = ["mdbook-check/packages/tools"]
resolver = "2"
exclude = [
"linkchecker", # linkchecker is part of the CI workflow
Expand Down
19 changes: 14 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
# Makefile for building and testing the book and Rust packages
# =============================================

MDBOOK_CHECK_ROOT := mdbook-check

PACKAGES := \
packages/mdbook-trpl \
packages/trpl
$(MDBOOK_CHECK_ROOT)/packages/mdbook-trpl \
$(MDBOOK_CHECK_ROOT)/packages/trpl \
$(MDBOOK_CHECK_ROOT)/packages/autocorrect

# Declare all targets as .PHONY (they do not produce files with matching names)
.PHONY: build run watch check-ci clean help
.PHONY: build run watch check-ci check-lint clean help

# ---------------------------------------------
# Build the mdBook documentation
Expand All @@ -34,9 +37,15 @@ watch: build
# - mdbook test: tests all code blocks in the book
# - custom script: additional CI validations
# ---------------------------------------------
check-ci:
check-ci: check-lint
mdbook test
bash scripts/check_ci.sh
bash $(MDBOOK_CHECK_ROOT)/scripts/check_ci.sh

# ---------------------------------------------
# Run Lint checks
# ---------------------------------------------
check-lint:
bash $(MDBOOK_CHECK_ROOT)/scripts/check_lint.sh

# ---------------------------------------------
# Clean build artifacts and cargo targets
Expand Down
Loading