Compare commits

..

No commits in common. "087fdc7ea59120006cda574bd7c4ee4926c91800" and "e20000513ad8cb0194ad78b363173de4d60c26ce" have entirely different histories.

7 changed files with 135 additions and 54 deletions

View File

@ -9,30 +9,112 @@ env:
RUSTFLAGS: --deny warnings
RUSTDOCFLAGS: --deny warnings
jobs:
build-and-test:
# Run tests
test:
name: Tests
runs-on: ubuntu-latest
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Install Rust
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends \
libasound2-dev libudev-dev libwayland-dev \
libxkbcommon-dev
- name: Populate target directory from cache
uses: Leafwing-Studios/cargo-cache@v2
with:
sweep-cache: true
- name: Install cargo-nextest
run: cargo install cargo-nextest --locked
- name: Run tests with nextest
run: |
cargo nextest run \
--all-features \
--all-targets
# Workaround for https://github.com/rust-lang/cargo/issues/6669
cargo test \
--locked \
--workspace \
--all-features \
--doc
# Run clippy lints
clippy:
name: Clippy
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: clippy, rustfmt
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.9
- name: Install cargo-nextest
uses: taiki-e/install-action@cargo-nextest
- name: Run Clippy
run: cargo clippy --locked --workspace --all-targets --all-features -- -D warnings
- name: Run formatting
run: cargo fmt --all --check
- name: Run Tests
components: clippy
- name: Install dependencies
run: |
cargo nextest run --all-features --all-targets
cargo test --locked --workspace --all-features --doc
- name: Check Documentation
run: cargo doc --locked --workspace --all-features --document-private-items --no-deps
sudo apt-get update
sudo apt-get install --no-install-recommends \
libasound2-dev libudev-dev libwayland-dev \
libxkbcommon-dev
- name: Populate target directory from cache
uses: Leafwing-Studios/cargo-cache@v2
with:
sweep-cache: true
- name: Run clippy lints
run: |
cargo clippy \
--locked \
--workspace \
--all-features \
-- \
--deny warnings
# Check formatting
format:
name: Format
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Run cargo fmt
run: |
cargo fmt \
--all \
-- \
--check
# Check documentation
doc:
name: Docs
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends \
libasound2-dev libudev-dev libwayland-dev \
libxkbcommon-dev
- name: Populate target directory from cache
uses: Leafwing-Studios/cargo-cache@v2
with:
sweep-cache: true
- name: Check documentation
run: |
cargo doc \
--locked \
--workspace \
--all-features \
--document-private-items \
--no-deps

View File

@ -15,9 +15,10 @@ on:
jobs:
audit:
name: Audit
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v4
- uses: actions-rust-lang/audit@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
@ -27,17 +28,11 @@ jobs:
- audit
runs-on: ubuntu-latest
timeout-minutes: 25
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@stable
- uses: actions/checkout@v4
with:
toolchain: stable
components: clippy, rustfmt
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.9
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
- name: cargo-release Cache
id: cargo_release_cache
uses: actions/cache@v4
@ -65,4 +60,11 @@ jobs:
# to the tag while building, which is a detached head
run: |
cargo release publish --workspace --all-features --allow-branch HEAD --no-confirm --no-verify --execute
cargo release \
publish \
--workspace \
--all-features \
--allow-branch HEAD \
--no-confirm \
--no-verify \
--execute

View File

@ -174,13 +174,13 @@ fn parse_default(list: &MetaList) -> Result<Option<Expr>> {
let value = meta.value()?;
let expr = value.parse::<Expr>()?;
if let Expr::Lit(expr_lit) = &expr
&& let Lit::Str(lit_str) = &expr_lit.lit
{
default_expr = Some(parse_quote! {
#lit_str.to_string()
});
return Ok(());
if let Expr::Lit(expr_lit) = &expr {
if let Lit::Str(lit_str) = &expr_lit.lit {
default_expr = Some(parse_quote! {
#lit_str.to_string()
});
return Ok(());
}
}
default_expr = Some(expr);
}

View File

@ -40,9 +40,9 @@ fn main() {
// Example assertions (adjust based on your actual file contents)
assert_eq!(json_data.key, "json key".to_string());
assert_eq!(json_data.number, 123);
assert!(!json_data.exists); // `bool::default()` is `false`
assert_eq!(json_data.exists, false); // `bool::default()` is `false`
assert_eq!(toml_data.key, "default key".to_string());
assert_eq!(toml_data.number, 456);
assert!(toml_data.exists);
assert_eq!(toml_data.exists, true);
}

View File

@ -1,6 +0,0 @@
error: FromFile only works on structs.
Enums are not supported.
--> tests/ui/enum_not_supported.rs:4:6
|
4 | enum MyEnum {
| ^^^^^^

View File

@ -0,0 +1,9 @@
use filecaster::FromFile;
#[derive(FromFile)]
struct MyStruct {
#[from_file(unknown)]
field: i32,
}
fn main() {}

View File

@ -1,6 +0,0 @@
error: FromFile only works on structs with *named* fields.
Tuple structs and unit structs are not supported.
--> tests/ui/tuple_struct_not_supported.rs:4:8
|
4 | struct MyTuple(i32, String);
| ^^^^^^^