Skip to content

Commit

Permalink
feat(just): Improve Justfile
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tingerrr committed Jul 24, 2024
1 parent 3b8b2ae commit b2ad82f
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 13 deletions.
40 changes: 27 additions & 13 deletions Justfile
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
29 changes: 29 additions & 0 deletions just/check.just
Original file line number Diff line number Diff line change
@@ -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 }}
25 changes: 25 additions & 0 deletions just/doc.just
Original file line number Diff line number Diff line change
@@ -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 }}
22 changes: 22 additions & 0 deletions just/test.just
Original file line number Diff line number Diff line change
@@ -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 }}

0 comments on commit b2ad82f

Please sign in to comment.