Skip to content
Public template

About

Rust Project Template

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

15 Commits

Folders and files

Repository files navigation

Rust Template

Template gitleaks Copier just prek Dependabot zizmor

Rust project template for Copier.

Usage

  • Create a new project - copier copy gh:ahcodedev/rust-template path/to/new-project
  • Pull in template updates from inside a generated project - just update-template (runs copier update)
  • New projects and updates use the latest template release (vX.Y.Z tag); changes merged to main reach projects only after a release

Development

  • Install just - brew install just
  • Install Copier, rustup, tombi, actionlint, zizmor, prek and gitleaks with Homebrew, then cargo-binstall and the pinned Rust tools (cargo-deny, cargo-nextest, cargo-shear, cargo-llvm-cov, typos) with cargo - just setup
    • Change tool versions in cargo_tools at the top of the justfile; reinstall with just install-tools
    • Bump them all to the latest releases and install them - just update-cargo-tools
  • Enable the Git hooks in prek.toml - prek install
    • Before each commit they run just lint and scan the staged changes for secrets with gitleaks

Commands are defined in the justfile and run with just.

  • List available commands - just
  • Format TOML files with tombi - just fmt
  • Check spelling with typos, TOML formatting with tombi, and GitHub Actions workflows with actionlint and zizmor - just lint
  • Render the template into a temp directory, then lint, test, check coverage and check dependencies of the generated project - just test-template
  • Scan the Git history for committed secrets - just gitleaks

CI runs just lint and just test-template, scans the Git history for secrets with gitleaks, and audits the workflows with zizmor-action.

  • zizmor-action reports findings as code scanning alerts in the repository's Security tab rather than failing CI
    • Code scanning needs a public repo, or GitHub Advanced Security on a private one

Releases

Releases are managed with Release Drafter, which reads the release labels on merged pull requests. Commit messages and PR titles aren't parsed.

Release label Version bump Release notes section
breaking major Breaking Changes
feature, enhancement minor Features
bug, fix patch Bug Fixes
chore, ci, dependencies, documentation, refactor patch Maintenance
skip-changelog none Excluded
  • Every PR needs at least one release label, or the Release Drafter / require-label check fails
    • Labels are added automatically from the branch name prefix (feat/, fix/, chore/, ci/, docs/, refactor/, dependabot/) and from the files a PR changes
  • Merging to main updates a draft GitHub Release with the next version and notes
  • To release, run the Release workflow from the Actions tab. It publishes the draft and tags the commit vX.Y.Z, which Copier uses as the template version

Dependency Updates

  • Dependabot (.github/dependabot.yml) opens weekly PRs for GitHub Actions in this repo's workflows and in template/
    • Updates wait 7 days after a release before a PR is opened
  • Patch and minor updates are auto-merged once CI passes (.github/workflows/dependabot-auto-merge.yml); major updates wait for review
    • Auto-merge needs "Allow auto-merge" turned on in the repository settings and a branch protection rule or ruleset on main that requires the CI checks
    • On GitHub Free, branch protection and auto-merge are only available for public repos
  • Dependabot doesn't update the actionlint version in the workflows and dev container, the gitleaks version and image in the dev container, or anything in .jinja files

Layout

  • copier.yml - template questions and settings
  • template/ - files rendered into new projects; files ending in .jinja are templated
  • prek.toml - Git hooks for this repo
  • .github/pull_request_template.md - checklist filled into new PR descriptions
  • .github/release-drafter.yml - release label to version bump and release notes section mapping

About

Rust Project Template

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages