From 3dfadffd47ff8e949de63763649685a8e7f83b9f Mon Sep 17 00:00:00 2001 From: phil Date: Wed, 8 Jan 2025 15:09:33 -0500 Subject: [PATCH] add checks or whatever --- .github/workflows/checks.yml | 29 +++++++++++++++++++++++++++++ Makefile | 13 +++++++++++++ rust-toolchain.toml | 2 ++ src/did.rs | 6 +++--- 4 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/checks.yml create mode 100644 Makefile create mode 100644 rust-toolchain.toml diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000..76e260a --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,29 @@ +name: checks + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +env: + CARGO_TERM_COLOR: always + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Build lib + run: cargo build --verbose + - name: Run tests + run: cargo test --verbose + + style: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: fmt + run: cargo fmt --all -- --check + - name: clippy + run: cargo clippy --all-targets --all-features -- -D warnings diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c680a0b --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +.PHONY: check test fmt clippy +all: check + +test: + cargo test + +fmt: + cargo fmt --all + +clippy: + cargo clippy --all-targets --all-features -- -D warnings + +check: test fmt clippy diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..aa2092b --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +components = [ "rustfmt", "clippy" ] diff --git a/src/did.rs b/src/did.rs index 48a1286..7db5f8d 100644 --- a/src/did.rs +++ b/src/did.rs @@ -115,7 +115,7 @@ mod tests { #[test] fn test_doc_exmples_atproto() { // https://atproto.com/specs/did#at-protocol-did-identifier-syntax - for case in vec!["did:plc:z72i7hdynmk6r22z27h6tvur", "did:web:blueskyweb.xyz"] { + for case in ["did:plc:z72i7hdynmk6r22z27h6tvur", "did:web:blueskyweb.xyz"] { assert!(parse_did(case).is_some(), "should pass: {case}") } } @@ -123,7 +123,7 @@ mod tests { #[test] fn test_doc_exmples_lexicon() { // https://atproto.com/specs/did#at-protocol-did-identifier-syntax - for case in vec![ + for case in [ "did:method:val:two", "did:m:v", "did:method::::val", @@ -137,7 +137,7 @@ mod tests { #[test] fn test_doc_exmples_invalid() { // https://atproto.com/specs/did#at-protocol-did-identifier-syntax - for case in vec![ + for case in [ "did:METHOD:val", "did:m123:val", "DID:method:val", -- 2.51.2