Skip to content

Commit c6e0426

Browse files
authored
Merge pull request #4 from ChenMiaoi/main
feat(root): Using mdbook-check as checker
2 parents d54d412 + 1009050 commit c6e0426

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+71
-8437
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@master
10+
with:
11+
submodules: true
1012
- name: Update rustup
1113
run: rustup self update
1214
- name: Install Rust
@@ -32,16 +34,18 @@ jobs:
3234
# sure all the crates can be resolved when running the tests.
3335
- name: Build `trpl` crate
3436
run: |
35-
cd packages/trpl
37+
cd mdbook-check/packages/trpl
3638
cargo build
3739
- name: Run tests
3840
run:
39-
mdbook test --library-path packages/trpl/target/debug/deps
41+
mdbook test --library-path mdbook-check/packages/trpl/target/debug/deps
4042
package_tests:
4143
name: Run package tests
4244
runs-on: ubuntu-latest
4345
steps:
4446
- uses: actions/checkout@master
47+
with:
48+
submodules: true
4549
- name: Update rustup
4650
run: rustup self update
4751
- name: Install Rust
@@ -53,14 +57,21 @@ jobs:
5357
run: |
5458
cargo test
5559
- name: Run `mdbook-trpl` package tests
56-
working-directory: packages/mdbook-trpl
60+
working-directory: mdbook-check/packages/mdbook-trpl
5761
run: |
5862
cargo test
5963
lint:
6064
name: Run lints
6165
runs-on: ubuntu-latest
6266
steps:
6367
- uses: actions/checkout@master
68+
with:
69+
submodules: recursive
70+
fetch-depth: 0
71+
- name: Force fetch submodules
72+
run: |
73+
git submodule update --init
74+
git submodule foreach --recursive git submodule update --init
6475
- name: Update rustup
6576
run: rustup self update
6677
- name: Install Rust
@@ -74,7 +85,7 @@ jobs:
7485
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
7586
echo "$(pwd)/bin" >> "${GITHUB_PATH}"
7687
- name: Install mdbook-trpl binaries
77-
run: cargo install --path packages/mdbook-trpl
88+
run: cargo install --path mdbook-check/packages/mdbook-trpl
7889
- name: Install aspell
7990
run: sudo apt-get install aspell
8091
- name: Install shellcheck
@@ -87,18 +98,33 @@ jobs:
8798
aspell --version
8899
shellcheck --version
89100
- name: Shellcheck
90-
run: find . -name '*.sh' -print0 | xargs -0 shellcheck
101+
run: |
102+
exclude_dirs=(
103+
"*/packages/autocorrect/**"
104+
"*/src/fuzz/books/codes/.venv/**"
105+
"*/book/**"
106+
)
107+
108+
find_args=()
109+
110+
for pattern in "${exclude_dirs[@]}"; do
111+
find_args+=(-not -path "$pattern")
112+
done
113+
114+
find . -name "*.sh" -type f "${find_args[@]}" -exec shellcheck {} +
91115
- name: Spellcheck
92-
run: bash ci/spellcheck.sh list
116+
run: bash mdbook-check/ci/spellcheck.sh list
93117
- name: Lint for local file paths
94118
run: |
95119
mdbook build
96120
cargo run --bin lfp src
97121
- name: Validate references
98-
run: bash ci/validate.sh
122+
run: bash mdbook-check/ci/validate.sh
99123
- name: Check for broken links
100124
run: |
101125
curl -sSLo linkcheck.sh \
102126
https://raw.githubusercontent.com/rust-lang/rust/HEAD/src/tools/linkchecker/linkcheck.sh
103127
# Cannot use --all here because of the generated redirect pages aren't available.
104128
sh linkcheck.sh book
129+
- name: Check Markdown Lint
130+
run: make check-lint

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "mdbook-check"]
2+
path = mdbook-check
3+
url = [email protected]:ChenMiaoi/mdbook-check.git

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[workspace]
2-
members = ["packages/tools"]
3-
default-members = ["packages/tools"]
2+
members = ["mdbook-check/packages/tools"]
3+
default-members = ["mdbook-check/packages/tools"]
44
resolver = "2"
55
exclude = [
66
"linkchecker", # linkchecker is part of the CI workflow

Makefile

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
# Makefile for building and testing the book and Rust packages
33
# =============================================
44

5+
MDBOOK_CHECK_ROOT := mdbook-check
6+
57
PACKAGES := \
6-
packages/mdbook-trpl \
7-
packages/trpl
8+
$(MDBOOK_CHECK_ROOT)/packages/mdbook-trpl \
9+
$(MDBOOK_CHECK_ROOT)/packages/trpl \
10+
$(MDBOOK_CHECK_ROOT)/packages/autocorrect
811

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

1215
# ---------------------------------------------
1316
# Build the mdBook documentation
@@ -34,9 +37,15 @@ watch: build
3437
# - mdbook test: tests all code blocks in the book
3538
# - custom script: additional CI validations
3639
# ---------------------------------------------
37-
check-ci:
40+
check-ci: check-lint
3841
mdbook test
39-
bash scripts/check_ci.sh
42+
bash $(MDBOOK_CHECK_ROOT)/scripts/check_ci.sh
43+
44+
# ---------------------------------------------
45+
# Run Lint checks
46+
# ---------------------------------------------
47+
check-lint:
48+
bash $(MDBOOK_CHECK_ROOT)/scripts/check_lint.sh
4049

4150
# ---------------------------------------------
4251
# Clean build artifacts and cargo targets

0 commit comments

Comments
 (0)