Boring introduction
Expectations on open source projects are becoming higher and higher everyday. If a project is not well documented or it doesn't have a test suite and a continuous integration environment, it is very unlikely that it will be taken seriously by the community.
Luckily for us, the tools to create high quality projects are becoming better and better at the same time, too.
For example, rust provides:
- the cargo build system which includes built-in support for tests and documentation
- clippy static code analyzer
- rustfmt auto formatting tool
These tools are well established and they are used by all the relevant rust projects. The rust ecosystem, in fact, is really homogeneous, in the sense that the way you build, test, run and deploy a certain application/library is very standard.
Therefore, when you are creating a new project, it's really likely that you can recycle documentation and CI steps from your older projects or other bigger rust projects out there..which is great, but as my java professor taught me:
if you are copying and pasting several times, you are almost surely doing it wrong!
And that's exactly what I was doing. π
In fact, every time I was creating a new GitHub project, I was using the good old copying and pasting technique on:
- the set of markdown
files that GitHub asks you to fill, such as
CONTRIBUTING.md
,CHANGELOG.md
,CODE_OF_CONDUCT.md
, issue and pull request templates, and most importantly theREADME.md
with all the fancy badges. - the files needed to setup the CI environment, most of the time GitHub actions, specifically.
We can do better than this. π
Cargo generate
In order to avoid copying and pasting, there is the cargo generate tool, which is described as:
A developer tool to help you get up and running quickly with a new Rust project by leveraging a pre-existing git repository as a template.
This means that you can setup a template repository, with all the files you
need and you ask cargo generate
to create a project starting from this
template, by replacing your project name and authors (and git username soon?).
After using this tool to create some rust embedded projects with really little effort, I immediately appreciated its power. Therefore, during these days I decided to use it to create a new template which makes me skip the copying and pasting phase when creating a new rust project hosted on GitHub.
Rust GitHub Template
You can find more info about Rust GitHub Template on its own website, where I described its features and instructions on how to use it to create a new rust project.
In short, it allows you to create a new rust project which already includes documentation and GitHub actions such as automatic security checks, Continuous Integration and Continuous Deployment already set up by only specifying project name and GitHub username. You can see an example project generated by this template here.
You can think of it as a bloated version of cargo new
π€
As the Rust GitHub Template website states:
Stop copy pasting tons of markdown and yaml files each time you start a new rust project. Letβs write them only once, together!
Thanks, and I hope you enjoy using Rust GitHub Template! π