/rust-starter

Rust starter project for building CLI and libraries, with great CI

Primary LanguageRustApache License 2.0Apache-2.0

Rust CI Starter

A Rust template project that gets you:

  • A CLI skeletons for a CLI with subcommands or flat, or a library
  • CI and CD (releases) with lint, testing, and coverage with Codecov
  • Developer workflow based on xtask
  • A good base linting configuration, popular libraries (which you can remove), and insta for tests.

Getting started

Clone the project or use a tool like backpack to kickstart a new project:

$ brew tap rusty-ferris-club/tap && brew install backpack
$ bp new rusty-ferris-club/rust-starter my-project

Then take an approach of removing what you don't need:

`starter_project/` - a CLI with subcommands, based on clap
`starter_project_simpler/` - a CLI with a simple flat structure, based on clap
`starter_project_lib/` - a library-only starter project, with minimal dependencies

Once that's done you can update cargo.toml and remove crates from the workspace.

Run build to see that you're ready to start:

cargo build

Personalising

Find where starter_project is and replace it with the name of your project. $ rg starter_project, find . | grep starter_project. Find which variables you need to swap. $ rg __V_, $ rg __v_.

Update all snapshots:

$ cargo insta test

And then

$ cargo insta review

README.md

If you like, you can replace this file with a README from the sub-crates:

Workflow

Workflow for your future project is based on xtask.

Install the helper cargo tools with:

$ cargo xtask install

Build

$ cargo build

or, for full build suite with tests:

$ cargo xtask ci

Coverage

$ cargo xtask coverage [--dev]

Docs

$ cargo xtask docs

Release

Set up your release.yml, replace the project names and repo locations.

Then to release new versions:

  • Update cargo.toml version.
  • git tag v[your-new-version]
  • push the new tag

Your Github Action CI workflow should release a new version.