- Building and Running the Project
- Testing the Project
- Running the Runtime on Docker
- Nix
- Formatting
- Pre-commit Hook
- Recommended Development Flow
- Conventional Commits
- Non-Rust Dependencies
-
Building
homestar
:For the fastest compile-times and prettiest logs while developing
homestar
, build with:cargo build --no-default-features --features dev
This removes underlying
wasmtime
zstd
compression while also turning on ANSI color-coded logs. If you build with default features,zstd
compression and otherwasmtime
defaults will be included in the build. -
Running the
homestar
server/runtime:cargo run --no-default-features --features dev -- start
-
Running with
tokio-console
for diagnosis and debugging:RUSTFLAGS="--cfg tokio_unstable" cargo run --no-default-features --features dev,console -- start
Then, in another window:
tokio-console --retain-for 60sec
-
Running the tests:
We recommend using cargo nextest, which is installed by default in our Nix flake or can be installed separately.
cargo nextest run --all-features --no-capture
This command translates to the default
cargo test
command:cargo test --all-features -- --nocapture
We recommend setting your Docker Engine configuration
with experimental
and buildkit
set to true
, for example:
{
"builder": {
"gc": {
"defaultKeepStorage": "20GB",
"enabled": true
}
},
"experimental": true,
"features": {
"buildkit": true
}
}
-
Build a multi-plaform Docker image via buildx:
docker buildx build --build-arg git_sha=$(git rev-parse HEAD) \ --build-arg git_timestamp=$(git log -1 --pretty=format:'%cI') \ --file docker/Dockerfile --platform=linux/amd64,linux/arm64 -t homestar --progress=plain .
-
Run a Docker image (depending on your platform):
docker run -it --rm --platform=linux/arm64 -p 3030:3030 -p 1337:1337 -t homestar
This repository contains a Nix flake that initiates both the Rust toolchain set in rust-toolchain.toml and a pre-commit hook. It also installs external dependencies, as well as helpful cargo binaries for development. Please install nix and direnv to get started.
Run nix develop
or direnv allow
to load the devShell
flake output,
according to your preference.
For formatting Rust in particular, we automatically format on nightly
, as it
uses specific nightly features we recommend by default.
This project recommends using pre-commit for running pre-commit hooks. Please run this before every commit and/or push.
- If you are doing interim commits locally, and you want to skip the pre-commit checks
you can run
git commit -a -m "Your message here" --no-verify
.
- We recommend leveraging cargo-watch, cargo-expand and irust for Rust development.
- We also recommend using cargo-udeps for removing unused dependencies before commits and pull-requests.
- If using our Nix flake, there are a number of handy
command shortcuts available for working with
cargo-watch
,diesel
, and other items, including:ci
, which runs a sequence of commands to check formatting, lints, release builds, and testsdb
anddb-reset
for runningdiesel
setup and migrationsdoc
for generating cargo docs with private-items documenteddocker-<amd64,arm64>
for running docker buildsnx-test
, which translates tocargo nextest run --workspace && cargo test --workspace --doc
x-test
for testing continuously as files change, translating tocargo watch -c -s "cargo nextest run --workspace --no-capture && cargo test --doc"
x-<build,check,run,clippy>
for running a variety ofcargo watch
execution stagesnx-test-<all,0>
, which is just likenx-test
, but addsall
or0
for running tests either with theall-features
flag orno-default-features
flag, respectivelyx-<build,check,run,clippy,test>-<core,wasm,runtime>
for package-specific builds, tests, etc.
This project lightly follows the Conventional Commits convention
to help explain commit history and tie in with our release process. The full specification
can be found here. We recommend prefixing your commits with
a type of fix
, feat
, docs
, ci
, refactor
, etc..., structured like so:
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
We are using wit-deps to track WIT dependencies/interfaces,
which is installed by default in our Nix flake or can be
installed separately with cargo install wit-deps-cli
.
To see an example of wit-deps
in action, view our
host helpers, where we import
the wasi-logging interface. We track this dependency in our
deps.toml
file:
logging = "https://github.com/WebAssembly/wasi-logging/archive/main.tar.gz"
To update packages, we can run wit-deps
within the homestar-wasm
directory.