The easiest way to build and test Trow is by using the Dockerfiles and associated scripts. If you want a local binary, the Trow executable can be copied out of the final image. The only dependency for building Trow in this way is Docker.
Trow is written in Rust. At the moment, we use Rust nightly due to a dependency on the Rocket framework.
To compile Rust locally, first install rustup if you
haven't already. Set the compiler default to nightly with rustup default nightly
and run rustup component add rustfmt
. Then run rustup update
to make sure you're running a version of Rust with
rustfmt
component. Now you should be able to run cargo build
from the project root and the Trow
binary will be written to /target/debug/trow
.
To execute the binary, you can run cargo run
, which will first recompile Trow if anything has
changed.
Running the tests is a little more complicated as you need to set the domain trow.test
to point to
your local machine and set-up TLS certificates. Instead of doing this you might find it easier to
use the slower Docker mehod instead, by simply running the docker/test.sh
script.
If you still want to run the tests locally, you will first need to configure routing. On my Linux
laptop I do this by adding the line 127.0.0.1 trow.test
to /etc/hosts
. I believe this will also
work on MacOS and there is a similar solution for Windows (which uses a different directory). Rather
than do this manually you may want to try the hostctl tool.
After this, we need to create a TLS certificate for testing. The easiest way to generate this is to
use the quick-install/self-cert/make-certs.sh
script (change to the self-cert
directory before
executing the script). This will create domain.key
and domain.crt
. Create a certs
folder in
the project top level and copy both files there. You can also accomplish something similar using the
mkcert tool.
You should be now be able to run cargo test
to run the test suite.
Personally, I (Adrian Mouat) use Visual Studio Code with Rust extensions when developing, but other contributors have sucessfully used Vim and other tools.
Trow can also be developed with Nix. Nix will create
and manage a development environment that includes the correct Rust Nightly version and all other
tools used in development. This environment can be entered manually by running nix-shell
within
the root of the Trow project or automatically with direnv.
Any editor with direnv
integration will have access to the Nix development environment.
Users of Visual Studio Code should set the Rust extension option
rust-client.disableRustup
to true
within this workspace to ensure that vscode uses the Rust
tools provided by Nix.