From b2ad82f558008e1b9c70c28c39e9ab6ecaf7a25e Mon Sep 17 00:00:00 2001 From: tinger Date: Wed, 24 Jul 2024 09:24:57 +0200 Subject: [PATCH] feat(just): Improve Justfile Added various new recipes and sub modules to separate common functionality and improve local iteration. - Added a doc module for generating and serving documentation such as the book and the rust library documentation - Added a test module for running various test harnesses and doc tests - Added a check module for various checks and lint configurations - Added ci recipe for replicating CI partially for local testing - Added run recipe - Added clean recipe to remove build artifacts --- Justfile | 40 +++++++++++++++++++++++++++------------- just/check.just | 29 +++++++++++++++++++++++++++++ just/doc.just | 25 +++++++++++++++++++++++++ just/test.just | 22 ++++++++++++++++++++++ 4 files changed, 103 insertions(+), 13 deletions(-) create mode 100644 just/check.just create mode 100644 just/doc.just create mode 100644 just/test.just diff --git a/Justfile b/Justfile index 563cfe3..f3df8f4 100644 --- a/Justfile +++ b/Justfile @@ -1,18 +1,32 @@ +book-src := justfile_directory() / 'docs' / 'book' + [private] default: - @just --list - -# run a full test harness -test *args: - cargo nextest run {{ args }} - # TODO: re-enable this once we know why this make my CPU skyrocket to 100% - # usage - # cargo test --doc - -# compile the documentation -docs: - cargo doc - typst compile docs/test-set-dsl.typ docs/test-set-dsl.pdf + @just --unsorted --list --list-submodules + +# documentation +mod doc 'just/doc.just' + +# testing +mod test 'just/test.just' + +# checks and lints +mod check 'just/check.just' + +# compile and run typst-test +run *args='--release': + cargo run {{ args }} + +# run tests and checks similar to CI +ci $RUSTFLAGS='-Dwarnings' $RUSTDOCFLAGS='-Dwarnings': + just check clippy + just check format + cargo doc --workspace --no-deps + +# clean all temporary directories and build artifacts +clean: + rm -r target + rm -r {{ book-src / 'book' }} # install typst-test using cargo install: diff --git a/just/check.just b/just/check.just new file mode 100644 index 0000000..cd13d84 --- /dev/null +++ b/just/check.just @@ -0,0 +1,29 @@ +book-src := justfile_directory() / 'docs' / 'book' + +# run all (doesn't include typos) +all: clippy format book + +# check the whole project for typos +typos *args: + typos {{ args }} + +# run various book checks and linters +book: book-test book-linkcheck + +# check book code examples +book-test: + mdbook test {{ book-src }} + +# check book links (disabled) +book-linkcheck: + # TODO: this is currently disabled as the book is in progress and contains dead + # links + # mdbook-linkcheck --standalone {{ book-src }} + +# run clippy lints +clippy *args='--all-targets --all-features': + cargo clippy --workspace {{ args }} + +# check rust formatting +format *args: + cargo fmt --all --check {{ args }} diff --git a/just/doc.just b/just/doc.just new file mode 100644 index 0000000..2077f56 --- /dev/null +++ b/just/doc.just @@ -0,0 +1,25 @@ +book-src := justfile_directory() / 'docs' / 'book' + +# build all documentation +all: build + +# build all documentation +build: book-build rust-build + +# build and open the book +book *args: (book-serve '--open' args) + +# build the book +book-build *args: + mdbook build {{ book-src }} {{ args }} + +# serve the book +book-serve *args='--open': + mdbook serve {{ book-src }} {{ args }} + +# compile and open the rust documentation +rust *args: (rust-build '--open' args) + +# compile the rust documentation +rust-build *args: + cargo doc --workspace {{ args }} diff --git a/just/test.just b/just/test.just new file mode 100644 index 0000000..d2ce9d3 --- /dev/null +++ b/just/test.just @@ -0,0 +1,22 @@ +book-src := justfile_directory() / 'docs' / 'book' + +# run a full test harness (doc tests disabled) +all: && book doc + cargo nextest run --workspace + +# run the lib tests +lib *args: + cargo nextest run --package typst-test-lib {{ args }} + +# run the cli tests +cli *args: + cargo nextest run --package typst-test {{ args }} + +# run the doc tests +doc *args: + # TODO: this currently deadlocks my pc at 100% CPU + # cargo test --workspace --doc {{ args }} + +# test the book +book *args: + mdbook test {{ book-src }} {{ args }}