4 Commits

Author SHA1 Message Date
b98fd1352a add rustfmt
Some checks failed
checks / format (push) Failing after 2s
checks / format (pull_request) Failing after 2s
2023-10-21 01:39:23 -07:00
a27214c8da Revert "test"
This reverts commit 81158ca818.
2023-10-21 01:39:23 -07:00
b53c875eac test 2023-10-21 01:39:23 -07:00
0e92eda123 add automated format check 2023-10-21 01:39:23 -07:00
3 changed files with 16 additions and 33 deletions

View File

@ -0,0 +1,16 @@
name: checks
on:
- push
- pull_request
jobs:
lint:
runs_on: "alpine_amd64"
container:
image: "rust:1.73-alpine3.18"
name: format
steps:
- name: TODO put in image base
run: rustup component add rustfmt
- name: rustfmt
run: cargo fmt --check

View File

@ -1,30 +0,0 @@
# Contribution Guidelines
## Code Formatting
We format all Rust code using edition 2021 rules. This edition is defined in our Cargo.toml and most methods below will pick this up automatically.
### Manual Method
The most editor agnostic way to format your Rust code is by manually running cargo's fmt sub command.
To check if your code is formatted without making changes, run `cargo fmt --check`. Then if you want to format your code you can run just `cargo fmt`.
### VScode
We recommend the meta extension [Rust Bundle](https://marketplace.visualstudio.com/items?itemName=1YiB.rust-bundle) , which includes rust-analyzer. ([More info](https://code.visualstudio.com/docs/languages/rust) on Rust with VScode) Then to set your editor to format on save:
* In Visual Studio Code, press Control + Shift + P or Command + Shift + P (Mac) to open the command palette and type setting and then select Preferences: Open User Settings option.
* Search for format on save setting and check the checkbox.
You can also set language specific settings as outlined [here](https://code.visualstudio.com/docs/getstarted/settings#_language-specific-editor-settings). You will again want to then search for format on save and check the checkbox.
### Other Editors
You will first need to [install rust-analyzer](https://rust-analyzer.github.io/manual.html#installation), then configure your editor and install any needed plugins or extensions as outlined on that page.
### Pre Commit Hook
If you want to think about formatting your code less and just have git yell at you whe you try to commit code that is not properly formatted, you can use a simple pre-commit hook.
After cloning the repo, move the file `pre-commit` to `.git/hooks/pre-commit`. That's it.

View File

@ -1,3 +0,0 @@
#!/bin/bash
cargo fmt --check