This is opinionated template to kick off new rust project with less than minute with best practices that I have found useful.
Since this is opinionated template some tools are required to be installed for
cargo install just cargo-deny cargo-generate cargo-readme
Run and answer the questions:
cargo generate --lib --git https://github.com/xoac/opinionated-rust-template
Go to the project you created and list all available commands
cd <PROJECT-NAME>
just --list
just readme-generate # You probalbly want nice README.md file
To use completions for just
you need to generate them with just --completions <SHELL>
. Depending from shell you are using there will be stored in different places so you need to find where to store them.
For fish users on Linux system you can add completions by invoke this code:
just --completions fish > $HOME/.config/fish/completions/just.fish
Useful commands can be fund with just --list
in project dictionary.
Here are some example commands:
just tag-version
will:- check if your code can compile
- run lints checks
- check if
README.md
is in sync withsrc/lib.rs
orsrc/main.rs
- run tests
- check if all files were committed
- check if
CHANGLOG.md
contains information about this version - create git tag
- push tag to remote
just tag-and-publish
will:- run
just tag-version
- run cargo publish
- run
Once a day:
- audit
On Push/PR:
- cargo clippy (more powerful cargo checks)
- cargo test
- cargo checkfmt
- cargo hack (check if features works alone and combined)
- cargo check dependencies (for updates)
- cargo check licenses (with cargo deny). By default it deny know licenses that are considered viral.
- dry run of cargo publish
- check if test pass on MSRV rust version
Release tag:
- build for linux/windows/macOS
There is no cargo publish in CD. If you want one here is an example.
- Double question for project name -- issue in cargo-generate
Pull requests are welcome.
- Support Gitlab.com Continuous Integration similar to github action.
- Automatically run
git remote add <GIT_URI>
in created directory - Generate init
README.md
withjust readme-generate
- Check somehow if crate is using sem-ver correctly. (Detecting if Cargo.toml use version correctly).
This template generate project with BSL-1.0 license that is similar to MIT but require license and copyright notice only for source. This is great license for open-source project that can be widely used. If you want more information about why you should use this BSL-1.0 for FOSS projects see this blog post.