Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,24 @@ jobs:
- name: Generate and test project
run: just test-template

zizmor:
runs-on: ubuntu-latest
# Uploads findings to the repository's code scanning alerts instead of failing the job.
# contents and actions: read are only needed for private repos.
permissions:
contents: read
actions: read
security-events: write

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false

# Also runs zizmor's online audits (e.g. known-vulnerable actions), which `just lint` skips
- name: Audit workflows
uses: zizmorcore/zizmor-action@45d7276c9ca790aabd705e31ca99c6185c3e76dd # v0.8.1

gitleaks:
runs-on: ubuntu-latest
# Job-level permissions replace the workflow-level ones, so contents: read is repeated here.
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

[![Template](https://github.com/ahcodedev/rust-template/actions/workflows/template.yml/badge.svg?branch=main)](https://github.com/ahcodedev/rust-template/actions/workflows/template.yml)
[![gitleaks](https://img.shields.io/badge/protected%20by-gitleaks-blue)](https://github.com/gitleaks/gitleaks)
[![Copier](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-grayscale-inverted-border-orange.json)](https://github.com/copier-org/copier)
[![just](https://img.shields.io/badge/built%20with-just-blue)](https://github.com/casey/just)
[![prek](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/j178/prek/master/docs/assets/badge-v0.json)](https://github.com/j178/prek)
[![Dependabot](https://img.shields.io/badge/Dependabot-enabled-blue?logo=dependabot)](https://docs.github.com/code-security/dependabot)
[![zizmor](https://img.shields.io/badge/%F0%9F%8C%88-zizmor-white?labelColor=white)](https://zizmor.sh/)

Rust project template for [Copier](https://copier.readthedocs.io/).

## Usage

- Create a new project - `copier copy gh:<owner>/rust-template path/to/new-project`
- 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`)

## Development
Expand All @@ -27,7 +32,10 @@ Commands are defined in the `justfile` and run with [just](https://github.com/ca
- 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`, and scans the Git history for secrets with gitleaks.
CI runs `just lint` and `just test-template`, scans the Git history for secrets with gitleaks, and audits the workflows with [zizmor-action](https://github.com/zizmorcore/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

## Dependency Updates

Expand Down
1 change: 0 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ test-template:
# -r HEAD renders the current checkout, including uncommitted changes
copier copy --defaults -r HEAD \
-d project_name=test-project \
-d author_name=Test \
-d copyright_year={{ datetime("%Y") }} \
"{{ justfile_directory() }}" "$tmp/test-project"
cd "$tmp/test-project"
Expand Down
18 changes: 18 additions & 0 deletions template/.github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,24 @@ jobs:
- name: Check minimum supported Rust version
run: just msrv

zizmor:
runs-on: ubuntu-latest
# Uploads findings to the repository's code scanning alerts instead of failing the job.
# contents and actions: read are only needed for private repos.
permissions:
contents: read
actions: read
security-events: write

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false

# Also runs zizmor's online audits (e.g. known-vulnerable actions), which `just lint` skips
- name: Audit workflows
uses: zizmorcore/zizmor-action@45d7276c9ca790aabd705e31ca99c6185c3e76dd # v0.8.1

gitleaks:
runs-on: ubuntu-latest
# Job-level permissions replace the workflow-level ones, so contents: read is repeated here.
Expand Down
2 changes: 1 addition & 1 deletion template/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Run project tasks through `just` (see `justfile`) rather than calling `cargo` di
- `just deny` - check dependencies for security advisories, licenses, banned crates and sources (`deny.toml`)
- `just gitleaks` - scan the Git history for committed secrets

Run `just fmt` and `just lint` after making changes; CI runs `just lint`, `just test`, `just coverage`, `just deny` and `just msrv` and fails on any warning, and scans the Git history for secrets with gitleaks.
Run `just fmt` and `just lint` after making changes; CI runs `just lint`, `just test`, `just coverage`, `just deny` and `just msrv` and fails on any warning, scans the Git history for secrets with gitleaks, and audits the workflows with zizmor-action, which reports findings as code scanning alerts.

## Git hooks

Expand Down
9 changes: 8 additions & 1 deletion template/README.md.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

[![Rust](https://github.com/{{ github_owner }}/{{ github_repo }}/actions/workflows/rust.yml/badge.svg?branch=main)](https://github.com/{{ github_owner }}/{{ github_repo }}/actions/workflows/rust.yml)
[![gitleaks](https://img.shields.io/badge/protected%20by-gitleaks-blue)](https://github.com/gitleaks/gitleaks)
[![Copier](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-grayscale-inverted-border-orange.json)](https://github.com/copier-org/copier)
[![just](https://img.shields.io/badge/built%20with-just-blue)](https://github.com/casey/just)
[![prek](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/j178/prek/master/docs/assets/badge-v0.json)](https://github.com/j178/prek)
[![Dependabot](https://img.shields.io/badge/Dependabot-enabled-blue?logo=dependabot)](https://docs.github.com/code-security/dependabot)
[![zizmor](https://img.shields.io/badge/%F0%9F%8C%88-zizmor-white?labelColor=white)](https://zizmor.sh/)

{{ description }}

Expand Down Expand Up @@ -63,7 +68,9 @@ Optional: re-run the tests each time you save with [bacon](https://dystroy.org/b
- `just lint`
- [gitleaks](https://github.com/gitleaks/gitleaks) on the staged changes
- Install them manually with `prek install`
- CI runs `just lint`, `just test`, `just coverage`, `just deny` and `just msrv`, and scans the Git history for secrets with gitleaks
- CI runs `just lint`, `just test`, `just coverage`, `just deny` and `just msrv`, scans the Git history for secrets with gitleaks, and audits the workflows with [zizmor-action](https://github.com/zizmorcore/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; otherwise the zizmor job fails, so set `advanced-security: false` on the action to report findings as job failures instead
- Repos owned by a GitHub organization need a `GITLEAKS_LICENSE` secret for the gitleaks job; personal repos don't
- Dependabot PRs only get Dependabot secrets, so organization repos also need `GITLEAKS_LICENSE` added as a Dependabot secret

Expand Down
Loading