mirror of
https://github.com/kristoferssolo/filecaster.git
synced 2025-10-21 19:00:34 +00:00
Compare commits
No commits in common. "main" and "v0.2.3" have entirely different histories.
126
.github/workflows/ci.yml
vendored
126
.github/workflows/ci.yml
vendored
@ -9,30 +9,112 @@ env:
|
|||||||
RUSTFLAGS: --deny warnings
|
RUSTFLAGS: --deny warnings
|
||||||
RUSTDOCFLAGS: --deny warnings
|
RUSTDOCFLAGS: --deny warnings
|
||||||
jobs:
|
jobs:
|
||||||
build-and-test:
|
# Run tests
|
||||||
|
test:
|
||||||
|
name: Tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
timeout-minutes: 30
|
||||||
SCCACHE_GHA_ENABLED: "true"
|
|
||||||
RUSTC_WRAPPER: "sccache"
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v4
|
||||||
- name: Install Rust
|
- 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
|
uses: dtolnay/rust-toolchain@stable
|
||||||
with:
|
with:
|
||||||
toolchain: stable
|
components: clippy
|
||||||
components: clippy, rustfmt
|
- name: Install dependencies
|
||||||
- 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
|
|
||||||
run: |
|
run: |
|
||||||
cargo nextest run --all-features --all-targets
|
sudo apt-get update
|
||||||
cargo test --locked --workspace --all-features --doc
|
sudo apt-get install --no-install-recommends \
|
||||||
- name: Check Documentation
|
libasound2-dev libudev-dev libwayland-dev \
|
||||||
run: cargo doc --locked --workspace --all-features --document-private-items --no-deps
|
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
|
||||||
|
|||||||
24
.github/workflows/publish.yml
vendored
24
.github/workflows/publish.yml
vendored
@ -15,9 +15,10 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
audit:
|
audit:
|
||||||
name: Audit
|
name: Audit
|
||||||
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v4
|
||||||
- uses: actions-rust-lang/audit@v1
|
- uses: actions-rust-lang/audit@v1
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@ -27,17 +28,11 @@ jobs:
|
|||||||
- audit
|
- audit
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 25
|
timeout-minutes: 25
|
||||||
env:
|
|
||||||
SCCACHE_GHA_ENABLED: "true"
|
|
||||||
RUSTC_WRAPPER: "sccache"
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v4
|
||||||
- uses: dtolnay/rust-toolchain@stable
|
|
||||||
with:
|
with:
|
||||||
toolchain: stable
|
fetch-depth: 0
|
||||||
components: clippy, rustfmt
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
- name: Run sccache-cache
|
|
||||||
uses: mozilla-actions/sccache-action@v0.0.9
|
|
||||||
- name: cargo-release Cache
|
- name: cargo-release Cache
|
||||||
id: cargo_release_cache
|
id: cargo_release_cache
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
@ -65,4 +60,11 @@ jobs:
|
|||||||
# to the tag while building, which is a detached head
|
# to the tag while building, which is a detached head
|
||||||
|
|
||||||
run: |
|
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
|
||||||
|
|||||||
46
Cargo.lock
generated
46
Cargo.lock
generated
@ -58,7 +58,6 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"toml",
|
"toml",
|
||||||
"trybuild",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -88,12 +87,6 @@ dependencies = [
|
|||||||
"wasi",
|
"wasi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "glob"
|
|
||||||
version = "0.3.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hashbrown"
|
name = "hashbrown"
|
||||||
version = "0.15.4"
|
version = "0.15.4"
|
||||||
@ -288,12 +281,6 @@ dependencies = [
|
|||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "target-triple"
|
|
||||||
version = "0.1.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1ac9aa371f599d22256307c24a9d748c041e548cbf599f35d890f9d365361790"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tempfile"
|
name = "tempfile"
|
||||||
version = "3.20.0"
|
version = "3.20.0"
|
||||||
@ -307,15 +294,6 @@ dependencies = [
|
|||||||
"windows-sys 0.59.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "termcolor"
|
|
||||||
version = "1.4.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
|
|
||||||
dependencies = [
|
|
||||||
"winapi-util",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml"
|
name = "toml"
|
||||||
version = "0.9.2"
|
version = "0.9.2"
|
||||||
@ -355,21 +333,6 @@ version = "1.0.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fcc842091f2def52017664b53082ecbbeb5c7731092bad69d2c63050401dfd64"
|
checksum = "fcc842091f2def52017664b53082ecbbeb5c7731092bad69d2c63050401dfd64"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "trybuild"
|
|
||||||
version = "1.0.110"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "32e257d7246e7a9fd015fb0b28b330a8d4142151a33f03e6a497754f4b1f6a8e"
|
|
||||||
dependencies = [
|
|
||||||
"glob",
|
|
||||||
"serde",
|
|
||||||
"serde_derive",
|
|
||||||
"serde_json",
|
|
||||||
"target-triple",
|
|
||||||
"termcolor",
|
|
||||||
"toml",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.18"
|
version = "1.0.18"
|
||||||
@ -385,15 +348,6 @@ dependencies = [
|
|||||||
"wit-bindgen-rt",
|
"wit-bindgen-rt",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "winapi-util"
|
|
||||||
version = "0.1.9"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
|
||||||
dependencies = [
|
|
||||||
"windows-sys 0.59.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-sys"
|
name = "windows-sys"
|
||||||
version = "0.59.0"
|
version = "0.59.0"
|
||||||
|
|||||||
@ -12,7 +12,6 @@ claims = "0.8"
|
|||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
tempfile = "3.10"
|
tempfile = "3.10"
|
||||||
toml = "0.9"
|
toml = "0.9"
|
||||||
trybuild = "1.0"
|
|
||||||
|
|
||||||
[workspace.lints.clippy]
|
[workspace.lints.clippy]
|
||||||
pedantic = "warn"
|
pedantic = "warn"
|
||||||
|
|||||||
@ -60,14 +60,12 @@ fn extract_named_fields(input: &DeriveInput) -> Result<&FieldsNamed> {
|
|||||||
Fields::Named(fields) => Ok(fields),
|
Fields::Named(fields) => Ok(fields),
|
||||||
_ => Err(Error::new_spanned(
|
_ => Err(Error::new_spanned(
|
||||||
&input.ident,
|
&input.ident,
|
||||||
r#"FromFile only works on structs with *named* fields.
|
"FromFile can only be derived for structs with named fields",
|
||||||
Tuple structs and unit structs are not supported."#,
|
|
||||||
)),
|
)),
|
||||||
},
|
},
|
||||||
_ => Err(Error::new_spanned(
|
_ => Err(Error::new_spanned(
|
||||||
&input.ident,
|
&input.ident,
|
||||||
r#"FromFile only works on structs.
|
"FromFile can only be derived for structs",
|
||||||
Enums are not supported."#,
|
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -174,14 +172,14 @@ fn parse_default(list: &MetaList) -> Result<Option<Expr>> {
|
|||||||
let value = meta.value()?;
|
let value = meta.value()?;
|
||||||
let expr = value.parse::<Expr>()?;
|
let expr = value.parse::<Expr>()?;
|
||||||
|
|
||||||
if let Expr::Lit(expr_lit) = &expr
|
if let Expr::Lit(expr_lit) = &expr {
|
||||||
&& let Lit::Str(lit_str) = &expr_lit.lit
|
if let Lit::Str(lit_str) = &expr_lit.lit {
|
||||||
{
|
|
||||||
default_expr = Some(parse_quote! {
|
default_expr = Some(parse_quote! {
|
||||||
#lit_str.to_string()
|
#lit_str.to_string()
|
||||||
});
|
});
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
default_expr = Some(expr);
|
default_expr = Some(expr);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@ -28,4 +28,3 @@ merge = { workspace = true, optional = true }
|
|||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
tempfile.workspace = true
|
tempfile.workspace = true
|
||||||
toml.workspace = true
|
toml.workspace = true
|
||||||
trybuild.workspace = true
|
|
||||||
|
|||||||
@ -40,9 +40,9 @@ fn main() {
|
|||||||
// Example assertions (adjust based on your actual file contents)
|
// Example assertions (adjust based on your actual file contents)
|
||||||
assert_eq!(json_data.key, "json key".to_string());
|
assert_eq!(json_data.key, "json key".to_string());
|
||||||
assert_eq!(json_data.number, 123);
|
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.key, "default key".to_string());
|
||||||
assert_eq!(toml_data.number, 456);
|
assert_eq!(toml_data.number, 456);
|
||||||
assert!(toml_data.exists);
|
assert_eq!(toml_data.exists, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +0,0 @@
|
|||||||
use trybuild::TestCases;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn ui() {
|
|
||||||
let t = TestCases::new();
|
|
||||||
t.compile_fail("tests/ui/*.rs");
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
use filecaster::FromFile;
|
|
||||||
|
|
||||||
#[derive(FromFile)]
|
|
||||||
enum MyEnum {
|
|
||||||
A,
|
|
||||||
B,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
|
||||||
@ -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 {
|
|
||||||
| ^^^^^^
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
use filecaster::FromFile;
|
|
||||||
|
|
||||||
#[derive(FromFile)]
|
|
||||||
struct MyTuple(i32, String);
|
|
||||||
|
|
||||||
fn main() {}
|
|
||||||
@ -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);
|
|
||||||
| ^^^^^^^
|
|
||||||
Loading…
Reference in New Issue
Block a user