Skip to content

Commit

Permalink
CI (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
ironpeak authored Nov 3, 2024
1 parent 60f9069 commit e202dc1
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 14 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: cargo
directory: /
schedule:
interval: weekly
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
31 changes: 31 additions & 0 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Dependencies

on:
push:
branches:
- main
paths:
- "Cargo.toml"
- "deny.toml"
pull_request:
paths:
- "Cargo.toml"
- "deny.toml"
schedule:
- cron: "0 0 * * 0"

env:
CARGO_TERM_COLOR: always

jobs:
dependencies:
name: Check dependencies
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/checkout@v4

- name: Check dependencies
uses: EmbarkStudios/cargo-deny-action@v2
with:
command-arguments: -D warnings
94 changes: 94 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Main

on:
push:
branches:
- main
paths-ignore:
- ".github/dependabot.yml"
- ".gitignore"
- ".rustfmt.toml"
- "deny.toml"
- "LICENSE"
- "README.md"
pull_request:
paths-ignore:
- ".github/dependabot.yml"
- ".gitignore"
- ".rustfmt.toml"
- "deny.toml"
- "LICENSE"
- "README.md"

env:
CARGO_TERM_COLOR: always

jobs:
format:
name: Format
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/checkout@v4

- name: Cache crates
uses: Swatinem/rust-cache@v2

- name: Install Taplo
run: cargo install --locked taplo-cli

- name: Format
run: |
cargo fmt --all --check
taplo fmt --check
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/checkout@v4

- name: Instal stable toolchain
uses: dtolnay/rust-toolchain@stable

- name: Cache crates
uses: Swatinem/rust-cache@v2

- name: Clippy
run: cargo clippy --all-features --benches --tests -- -D warnings

- name: Rustdoc
run: cargo rustdoc --all-features -- -D warnings

doctest:
name: Doctest
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/checkout@v4

- name: Instal stable toolchain
uses: dtolnay/rust-toolchain@stable

- name: Cache crates
uses: Swatinem/rust-cache@v2

- name: Test doc
run: cargo test --all-features --doc

test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/checkout@v4

- name: Instal stable toolchain
uses: dtolnay/rust-toolchain@stable

- name: Cache crates
uses: Swatinem/rust-cache@v2

- name: Test
run: cargo test --all-features
4 changes: 4 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
reorder_imports = true
imports_granularity = "Crate"
group_imports = "StdExternalCrate"
reorder_modules = true
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ proc-macro = true
[dependencies]
proc-macro2 = "1"
quote = "1"
syn = { version = "2", default-features = false }
syn = { version = "2", features = ["full"] }

[dev-dependencies]
tokio = { version = "1", features = ["macros", "rt", "time"] }
Expand Down
5 changes: 5 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[bans]
multiple-versions = "deny"

[licenses]
allow = ["Apache-2.0", "MIT", "Unicode-DFS-2016"]
20 changes: 7 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,14 @@ fn parse_time(expr: &Expr) -> Result<Duration> {
literal.base10_parse::<u64>()? * 60 * 60 * 24,
)),
"" => Ok(Duration::from_millis(literal.base10_parse::<u64>()?)),
suffix => {
return Err(syn::Error::new(
expr.span(),
format!("Unexpected a numeric literal suffix {}", suffix),
))
}
suffix => Err(syn::Error::new(
expr.span(),
format!("Unexpected a numeric literal suffix {}", suffix),
)),
},
_ => {
return Err(syn::Error::new(expr.span(), "Expected a numeric literal"));
}
_ => Err(syn::Error::new(expr.span(), "Expected a numeric literal")),
},
_ => {
return Err(syn::Error::new(expr.span(), "Expected a numeric literal"));
}
_ => Err(syn::Error::new(expr.span(), "Expected a numeric literal")),
}
}

Expand Down Expand Up @@ -99,7 +93,7 @@ fn slow_function_warning_common(time: Duration, stmt: Stmt, function: ItemFn) ->
vis: function.vis.clone(),
sig: function.sig.clone(),
block: Box::new(Block {
brace_token: function.block.brace_token.clone(),
brace_token: function.block.brace_token,
stmts: vec![],
}),
};
Expand Down

0 comments on commit e202dc1

Please sign in to comment.