Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rustisms: part 1 #5

Merged
merged 15 commits into from
Dec 23, 2022
Merged
Show file tree
Hide file tree
Changes from 14 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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.STELE_GITHUB_TOKEN }}

- name: Run just test
- name: Run tests
run: just test

lints:
Expand Down
123 changes: 123 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ license = "AGPL-3.0"
keywords = ["authentication", "laws", "preservation"]
categories = ["authentication", "web-programming::http-server"]
repository = "https://github.com/openlawlibrary/stele"
rust-version = "1.66"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
Expand All @@ -19,6 +20,10 @@ git2 = "0.15"
lazy_static = "1.4.0"
regex = "1"
serde = "1.0"
tracing = "0.1.37"
tracing-subscriber = "0.3.16"
tracing-actix-web = "0.6.2"
derive_more = "0.99.17"

[dev-dependencies]
criterion = "0.3"
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Stele is a system for distributing, preserving, and authenticating laws.
6. We recommend using [VSCode](https://code.visualstudio.com/Download) (default settings provided in repo), but you can use any editor you like.

### Development

- Lints must pass before merging into master
- All code must have tests. Tests should conform to our testing guidelines.
- Run `just` from within the repository to list all available just commands. Currently:
Expand All @@ -31,6 +30,11 @@ Stele is a system for distributing, preserving, and authenticating laws.
- `test`: Run all tests
- On windows, especially, you may wish to run just through the nu shell, which can be done by calling all commands with the `--shell` command, e.g. `just --shell nu lint`.

## Logging

The ENV variable `RUST_LOG` can be set with one of `trace`, `debug`, `info`, `warn`, `error`. Filters can be set based on the `target` components seen in the logs lines, for example: to use `trace` but turn down the noise from the Actix dispatcher: `RUST_LOG="trace,actix_http::h1::dispatcher=warn"`

See [tracing-subscriber docs](https://docs.rs/tracing-subscriber/latest/tracing_subscriber/fmt/index.html#filtering-events-with-environment-variables) and [env_logger syntax](https://docs.rs/env_logger/latest/env_logger/#enabling-logging]).

## Q&A
- Why do we suggest NuShell?
Expand Down
22 changes: 4 additions & 18 deletions benches/git_benchmark.rs
Original file line number Diff line number Diff line change
@@ -1,34 +1,20 @@
//! benchmark for git utils
#![allow(clippy::self_named_module_files)]
#![allow(clippy::std_instead_of_alloc)]
#![allow(clippy::implicit_return)]
#![allow(clippy::multiple_crate_versions)]
#![allow(clippy::expect_used)]
#![allow(missing_docs)]

use criterion::{criterion_group, criterion_main, Criterion};
use std::env::current_exe;
use std::fs::create_dir_all;
use std::path::PathBuf;
use std::sync::Once;
use stele::utils::git::Repo;

/// get the path to the test library at `$REPO_ROOT/test/library`.
/// get the path to the test library at `$REPO_ROOT/tests/fixtures/library`.
fn get_test_library_path() -> PathBuf {
let mut library_path = current_exe()
.expect("Something went wrong getting the library path")
.parent()
.expect("Something went wrong getting the library path")
.parent()
.expect("Something went wrong getting the library path")
.parent()
.expect("Something went wrong getting the library path")
.parent()
.expect("Something went wrong getting the library path")
.to_owned();
library_path.push("test");
library_path.push("library");
library_path
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
path.push("tests/fixtures/library");
path
}

/// ensure `initialize` function, below, is only called once
Expand Down
29 changes: 29 additions & 0 deletions etc/NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Project Notes

## Pedantic Rust Editor Settings
If you would like to make your editor always give you the most verbose feedback in any Rust project, you can use something like this. It can be used as-is in VSCode, or converted to something similar in your editor of choice.

```json
{
"rust-analyzer.checkOnSave.overrideCommand": [
tombh marked this conversation as resolved.
Show resolved Hide resolved
"cargo",
"clippy",
"--message-format=json",
"--all-targets",
"--all-features",
"--",
"-W",
"clippy::all",
"-W",
"clippy::pedantic",
"-W",
"clippy::restriction",
"-W",
"clippy::nursery",
"-W",
"clippy::cargo",
"-W",
"missing_docs"
],
}
```
4 changes: 2 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ lint: format clippy

# Format code
format:
cargo fmt --all -- --check
cargo fmt --all -- --check

# Run all tests
test:
Expand All @@ -27,4 +27,4 @@ ci: lint test bench

# Run all benchmarks
bench:
cargo bench
cargo bench
Loading