Currently, to run the tests that are located in the `tests` directory
(the js tests), one has to navigate to the directory and run `npm test`
or `npm start`. We now have a way of automating such task execution
using the binary in the `xtask` directory. This pr makes use of this by
introducing a new command `cargo xtask web-tests` that can be run from
anywhere in the repo to run the tests in the `tests` directory.
---------
Co-authored-by: Eric Githinji <egithinji@google.com>
This fixes#2708 by creating a CARGO_WORKSPACE_DIR env variable to act
as an anchor path, allowing the installation of mdbook-exerciser and
mdbook-course to succeed from any directory within the repository. Based
on the approach mentioned here:
https://github.com/rust-lang/cargo/issues/3946#issuecomment-973132993
---------
Co-authored-by: Eric Githinji <egithinji@google.com>
Some minor improvements to an already-merged PR (#2688) on the task
automation via xtask. Main ones being:
- Adding more explanatory comments about what the xtask package is and
what it does
- Using Clap for CLI arg parsing
- Using Anyhow for error handling
---------
Co-authored-by: Eric Githinji <egithinji@google.com>
### Background
Comprehensive Rust requires a number of tools to be installed (e.g.
mdbook and mdbook-course). As mentioned in #2509 (and discussed in
#2469) it would be nice to have a cross platform command for installing
these dependencies. Currently these are installed using a shell script
(`install-mdbook.sh`) but this isn't truly cross platform e.g. for
Windows users.
### Xtask
[xtask](https://github.com/matklad/cargo-xtask) outlines an approach for
automating tasks in a Rust project. It involves using cargo's aliasing
feature to allow us to run commands like `cargo xtask <some task>` to
perform adhoc tasks via a Rust binary that we might otherwise need a
shell script for.
In this PR we add support for a `cargo xtask install-tools` command that
will replace the `install-mdbook.sh` script and install the dependent
tools. We can potentially extend it to support for other tasks e.g.
`cargo xtask fmt`.
---------
Co-authored-by: Eric Githinji <egithinji@google.com>