diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 79ae5a6..f2d50da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ name: CI -on: [push, pull_request] +on: [push] jobs: check: @@ -11,9 +11,9 @@ jobs: toolchain: [stable, beta, nightly] steps: - name: Checkout sources - uses: actions/checkout@v4 + uses: actions/checkout@v5 - run: rustup update ${{ matrix.toolchain }} - - run: cargo check --all-features + - run: cargo check --all test: name: Test Suite @@ -23,9 +23,9 @@ jobs: toolchain: [stable, beta, nightly] steps: - name: Checkout sources - uses: actions/checkout@v4 + uses: actions/checkout@v5 - run: rustup update ${{ matrix.toolchain }} - - run: cargo test --all-features + - run: cargo test --all lints: name: Lints @@ -35,7 +35,7 @@ jobs: toolchain: [stable, beta, nightly] steps: - name: Checkout sources - uses: actions/checkout@v4 + uses: actions/checkout@v5 - run: rustup update ${{ matrix.toolchain }} - - run: cargo fmt -- --check - - run: cargo clippy --all-features -- -D warnings + - run: cargo fmt --all -- --check + - run: cargo clippy --all -- -D warnings diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..bd19920 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,31 @@ +name: Create GitHub Release and Publish to crates.io + +on: + push: + tags: ['v*'] + +jobs: + github-release: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v5 + + - id: create-release + run: gh release create ${{ github.ref_name }} --title "${{ github.ref_name }}" --generate-notes + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + publish: + runs-on: ubuntu-latest + # environment: release # Optional: for enhanced security + permissions: + id-token: write + steps: + - uses: actions/checkout@v5 + - uses: rust-lang/crates-io-auth-action@v1 + id: auth + - run: cargo publish + env: + CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} diff --git a/Cargo.toml b/Cargo.toml index 74225d9..6ebd6e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ repository = "https://github.com/sile/eetf" readme = "README.md" keywords = ["erlang"] license = "MIT" -edition = "2021" +edition = "2024" [dependencies] byteorder = "1" diff --git a/src/codec.rs b/src/codec.rs index 77dfa99..db589b1 100644 --- a/src/codec.rs +++ b/src/codec.rs @@ -810,7 +810,7 @@ mod aux { Err(io::Error::new(io::ErrorKind::InvalidData, message)) } pub fn other_error(message: String) -> io::Result { - Err(io::Error::new(io::ErrorKind::Other, message)) + Err(io::Error::other(message)) } pub fn latin1_bytes_to_string(buf: &[u8]) -> io::Result { // FIXME: Supports Latin1 characters @@ -826,10 +826,6 @@ mod aux { } } pub fn sign_to_byte(sign: Sign) -> u8 { - if sign == Sign::Minus { - 1 - } else { - 0 - } + if sign == Sign::Minus { 1 } else { 0 } } } diff --git a/src/convert.rs b/src/convert.rs index cd94d69..c58e06f 100644 --- a/src/convert.rs +++ b/src/convert.rs @@ -96,11 +96,7 @@ pub trait AsOption { } impl AsOption for bool { fn as_option(&self) -> Option<&Self> { - if *self { - Some(self) - } else { - None - } + if *self { Some(self) } else { None } } } diff --git a/src/lib.rs b/src/lib.rs index 0285856..f7b6052 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -852,8 +852,8 @@ impl From> for Map { #[cfg(test)] mod tests { use super::*; - use crate::pattern::any; use crate::pattern::U8; + use crate::pattern::any; #[test] fn it_works() { diff --git a/tests/lib.rs b/tests/lib.rs index a4240bd..f31a4d1 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -230,7 +230,9 @@ fn reference_test() { // Encode assert_eq!( - vec![131, 90, 0, 1, 100, 0, 3, 102, 111, 111, 0, 0, 0, 0, 0, 0, 0, 123], + vec![ + 131, 90, 0, 1, 100, 0, 3, 102, 111, 111, 0, 0, 0, 0, 0, 0, 0, 123 + ], encode(Term::from(Reference::from(("foo", 123)))) ); } @@ -246,12 +248,17 @@ fn external_fun_test() { // Decode assert_eq!( Ok(ExternalFun::from(("foo", "bar", 3))), - decode(&[131, 113, 100, 0, 3, 102, 111, 111, 100, 0, 3, 98, 97, 114, 97, 3]).try_into() + decode(&[ + 131, 113, 100, 0, 3, 102, 111, 111, 100, 0, 3, 98, 97, 114, 97, 3 + ]) + .try_into() ); // Encode assert_eq!( - vec![131, 113, 100, 0, 3, 102, 111, 111, 100, 0, 3, 98, 97, 114, 97, 3], + vec![ + 131, 113, 100, 0, 3, 102, 111, 111, 100, 0, 3, 98, 97, 114, 97, 3 + ], encode(Term::from(ExternalFun::from(("foo", "bar", 3)))) ); } @@ -461,15 +468,22 @@ fn map_test() { // Decode assert_eq!( Ok(map.clone()), - decode(&[131, 116, 0, 0, 0, 2, 97, 1, 97, 2, 100, 0, 1, 97, 100, 0, 1, 98]).try_into() + decode(&[ + 131, 116, 0, 0, 0, 2, 97, 1, 97, 2, 100, 0, 1, 97, 100, 0, 1, 98 + ]) + .try_into() ); // Encode let buf = encode(Term::from(map.clone())); // Hashmap Iter is not deterministic, so we need to check both possible outputs assert!( - [131, 116, 0, 0, 0, 2, 97, 1, 97, 2, 100, 0, 1, 97, 100, 0, 1, 98] == buf.as_slice() - || [131, 116, 0, 0, 0, 2, 100, 0, 1, 97, 100, 0, 1, 98, 97, 1, 97, 2] == buf.as_slice() + [ + 131, 116, 0, 0, 0, 2, 97, 1, 97, 2, 100, 0, 1, 97, 100, 0, 1, 98 + ] == buf.as_slice() + || [ + 131, 116, 0, 0, 0, 2, 100, 0, 1, 97, 100, 0, 1, 98, 97, 1, 97, 2 + ] == buf.as_slice() ); //Access