This repository has been archived by the owner on Dec 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
165 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# EditorConfig helps developers define and maintain consistent | ||
# coding styles between different editors and IDEs | ||
# editorconfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
[*] | ||
end_of_line=lf | ||
charset=utf-8 | ||
indent_style=space | ||
indent_size=4 | ||
tab_width=4 | ||
trim_trailing_whitespace=true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
# double whitespace at end of line denotes a line break in Markdown | ||
trim_trailing_whitespace = false | ||
|
||
[*.yml] | ||
indent_size = 2 | ||
|
||
[*.{rs,toml}] | ||
indent_style=tab | ||
indent_size=tab | ||
max_line_length=100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
set -o errexit | ||
set -o pipefail | ||
|
||
cat "${1}" | "${HOME}/.cargo/bin/conventional_commits_linter" --from-stdin --allow-angular-type-only |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
|
||
echo "Pre Commit Hook" | ||
echo -e "\n# taplo format" | ||
|
||
taplo format | ||
|
||
echo -e "\n# cargo fmt" | ||
|
||
diff=$(cargo +nightly fmt -- --check) | ||
result=$? | ||
|
||
if [[ ${result} -ne 0 ]] ; then | ||
cat <<\EOF | ||
There are some code style issues, run `cargo fmt` first. | ||
EOF | ||
exit 1 | ||
fi | ||
|
||
echo -e "\n# cargo clippy" | ||
|
||
diff=$(cargo clippy --bins --tests --examples --all -- -D warnings) | ||
result=$? | ||
|
||
if [[ ${result} -ne 0 ]] ; then | ||
cat <<\EOF | ||
There are some code style issues, run `cargo clippy` first. | ||
EOF | ||
exit 1 | ||
fi | ||
|
||
echo "" | ||
|
||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
echo "Pre Push Hook" | ||
|
||
echo -e "\n# cargo test" | ||
|
||
diff=$(cargo test) | ||
result=$? | ||
|
||
if [[ ${result} -ne 0 ]] ; then | ||
cat <<\EOF | ||
There are some test failing, run `cargo test` first. | ||
EOF | ||
exit 1 | ||
fi | ||
|
||
echo "" | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Configuration file for Rustfmt | ||
# https://rust-lang.github.io/rustfmt | ||
|
||
version = "Two" | ||
|
||
# Basic | ||
hard_tabs = true | ||
max_width = 100 | ||
|
||
# Imports | ||
imports_granularity = "Crate" | ||
|
||
# Consistency | ||
newline_style = "Unix" | ||
|
||
# Format comments | ||
comment_width = 100 | ||
wrap_comments = true | ||
|
||
# Misc | ||
chain_width = 80 | ||
match_arm_blocks = false | ||
match_block_trailing_comma = true | ||
reorder_impl_items = true | ||
trailing_semicolon = false | ||
use_field_init_shorthand = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Taplo is a TOML formater | ||
# https://taplo.tamasfe.dev/ | ||
|
||
exclude = [] | ||
|
||
[formatting] | ||
align_entries = true | ||
reorder_keys = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"recommendations": [ | ||
"editorconfig.editorconfig", | ||
"matklad.rust-analyzer" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!bin/bash | ||
|
||
rm -rf .git/hooks | ||
ln -s $PWD/.git_hooks .git/hooks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!bin/bash | ||
|
||
cargo install taplo-cli grcov | ||
cargo install conventional_commits_linter --version 0.9.0 | ||
rustup component add llvm-tools-preview | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
rm -rf ./target/debug/coverage/* | ||
rm -rf ./target/debug/profraw/* | ||
|
||
# Nightly Rust is required to use grcov for Rust coverage. | ||
# Alternatively, you can export `RUSTC_BOOTSTRAP=1`, which basically turns your stable rustc into a Nightly one. | ||
export RUSTC_BOOTSTRAP=1 | ||
export RUSTFLAGS="-Zinstrument-coverage" | ||
|
||
cargo build | ||
|
||
# Ensure each test runs gets its own profile information by defining the LLVM_PROFILE_FILE environment variable | ||
# (%p will be replaced by the process ID, and %m by the binary signature) | ||
export LLVM_PROFILE_FILE="./target/debug/profraw/%p-%m.profraw" | ||
|
||
cargo test | ||
|
||
# In the CWD, you will see a `.profraw` file has been generated. | ||
# This contains the profiling information that grcov will parse, alongside with your binaries. | ||
|
||
|
||
# Generate html report | ||
grcov . --binary-path ./target/debug -s src -t html --branch --ignore-not-existing --ignore "/*" -o ./target/debug/coverage/ | ||
|
||
# Consult the coverage | ||
open ./target/debug/coverage/index.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
fn main() { | ||
println!("Hello, world!"); | ||
println!("Hello, world!"); | ||
} |