Developer guide
This part is for working on doris itself. This page covers building and testing. Code layout maps the source tree, Adding tools and flows and Writing documentation say how to change each, and the API documentation is generated from the source. Read Architecture first for how the pieces fit.
doris is a Cargo workspace: the doris binary crate at the root, the plugin SDK in sdk/ and a crate for each tool plugin in plugins/, with this book next to it in docs/. The repo is a Nix flake that provides the toolchain, the formatters and the checks CI runs.
The dev shell
With direnv, the tools are on your path as soon as you enter the repo (run direnv allow once). Without it, run nix develop first. The shell has cargo, rustc, clippy, rustfmt, rust-analyzer, lld, mdbook, mdbook-mermaid, lychee and treefmt. lld links the plugins, which build.rs builds for wasm32-unknown-unknown.
Everyday commands
cargo build # a debug build, at target/debug/doris
cargo test --workspace # the unit tests, the plugins' and the SDK's included
cargo clippy # lints
cargo run -- -C ../mocha plan lint # run the working tree against another repo
nix fmt # format Rust, Nix, TOML and Markdown with treefmt
nix build # the release binary, at result/bin/doris
nix flake check # everything CI runs
-C DIR is the way to try a change against a real project without installing anything.
Tests
Tests are unit tests, in a tests module at the end of the file they cover. They need no EDA tools: they build repos and step graphs in temporary directories, and run small shell commands as steps. cargo test --workspace runs them all, and so does the Nix build of doris. A plain cargo test runs only the doris crate’s.
There are no tests that run a simulator or a linter. A change to a plugin is checked by hand against a project: doris plan -v to read the commands, then a run, then the checks on the step’s page.
After changing doris’s own part in a result, bump KEY_PROTOCOL in src/cache.rs. That is how it makes a key, how it reaches a verdict from a step’s rules, or what a flow does around a plugin’s results, such as lint’s writing of a linter’s messages to messages.json. Every key holds the protocol, not doris’s version, so without a bump a rebuilt doris takes old results from the cache. A changed plugin needs no bump: its hash is in the key of every step that uses its tool (see What is not in a key).
What CI checks
nix flake check runs the same checks as the Checks workflow:
| Check | What it does |
|---|---|
formatting | treefmt: rustfmt, nixfmt, taplo for TOML, prettier for Markdown and YAML |
doris | Builds the release binary and runs the tests |
docs | Builds this book and the API documentation |
docs-links | Checks every internal link of the built book |
The Documentation workflow builds the same book on every pull request and publishes it to GitHub Pages on a push to main.
Conventions
- Errors are
anyhowerrors with context that names the file or the job. A message says what is wrong and what would fix it. - Paths shown to people go through
ui, which makes them relative to the repo root. Files written for tools keep absolute paths. - No shell. A command is a program and an argument list, built by a plugin from typed values.
- Nothing tied to one machine goes in a cache key. See Cache keys.
- Document the behaviour, not the plan. When a change alters what a user sees, update the page that describes it in the same change. What is designed but not built belongs in the Roadmap.
Licence
doris is licensed under Apache-2.0.