Skip to content

Start rust project on the right foot with less than minute with cargo-generate and this template!

Notifications You must be signed in to change notification settings

xoac/opinionated-rust-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Opinionated rust template

This is opinionated template to kick off new rust project with less than minute with best practices that I have found useful.

Usage

Requirements

Since this is opinionated template some tools are required to be installed for

cargo install just cargo-deny cargo-generate cargo-readme

Generate project

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

Improvements

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

What this template contains?

Useful commands can be fund with just --list in project dictionary.

Here are some example commands:

  1. just tag-version will:
    • check if your code can compile
    • run lints checks
    • check if README.md is in sync with src/lib.rs or src/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
  2. just tag-and-publish will:
    • run just tag-version
    • run cargo publish

Continuous Integration/Delivery

Once a day:

  1. audit

On Push/PR:

  1. cargo clippy (more powerful cargo checks)
  2. cargo test
  3. cargo checkfmt
  4. cargo hack (check if features works alone and combined)
  5. cargo check dependencies (for updates)
  6. cargo check licenses (with cargo deny). By default it deny know licenses that are considered viral.
  7. dry run of cargo publish
  8. check if test pass on MSRV rust version

Release tag:

  1. build for linux/windows/macOS

There is no cargo publish in CD. If you want one here is an example.

Know Issues:

  1. Double question for project name -- issue in cargo-generate

TODO

Pull requests are welcome.

  1. Support Gitlab.com Continuous Integration similar to github action.
  2. Automatically run git remote add <GIT_URI> in created directory
  3. Generate init README.md with just readme-generate
  4. Check somehow if crate is using sem-ver correctly. (Detecting if Cargo.toml use version correctly).

License

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.

Credits:

  1. https://github.com/rust-github/template
  2. Rust for Rustaceans

About

Start rust project on the right foot with less than minute with cargo-generate and this template!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages