diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 3277a4a..08f3b1f 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,21 +1,35 @@ name: Rust on: - push: - branches: [ "main" ] pull_request: - branches: [ "main" ] + push: env: + RUST_BACKTRACE: 1 CARGO_TERM_COLOR: always + RUSTDOCFLAGS: --deny warnings + RUSTFLAGS: --deny warnings jobs: - build: - + stable: runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Build + run: cargo build --verbose + - name: Clippy + run: cargo clippy --verbose + - name: Run tests + run: cargo test --verbose + msrv: + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: clippy + toolchain: 1.59.0 - name: Build run: cargo build --verbose - name: Clippy diff --git a/Cargo.toml b/Cargo.toml index ca6fa9c..8a80965 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ documentation = "https://docs.rs/thumbor" readme = "README.md" license = "MIT" edition = "2021" -rust-version = "1.80" +rust-version = "1.59" authors = ["SteelAlloy"] categories = ["web-programming", "multimedia::images"] keywords = ["client", "thumbor", "crop", "resize", "image"] diff --git a/README.md b/README.md index 7944e57..ba74cd7 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,36 @@

Rust Thumbor client

+ + Repository + + + Crates.io Version + + + docs.rs + + + Crates.io MSRV +
-[![Latest Version](https://img.shields.io/crates/v/thumbor.svg)](https://crates.io/crates/thumbor) -[![Rust Documentation](https://docs.rs/thumbor/badge.svg)](https://docs.rs/thumbor) -![Crates.io](https://img.shields.io/crates/l/thumbor) -![Crates.io](https://img.shields.io/crates/d/thumbor) - ## Usage In short : @@ -29,10 +52,10 @@ use thumbor::Server; let server = Server::new("http://localhost:8888", "my-security-key").unwrap(); -let settings_builder = server.settings_builder() +let settings = server.settings_builder() .resize((300, 200)) .smart(true) .build(); -let url = settings_builder.to_url("path/to/my/image.jpg"); +let url = settings.to_url("path/to/my/image.jpg"); ``` diff --git a/src/tests.rs b/src/tests.rs index bf422cd..dca6596 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -1,24 +1,26 @@ -use std::sync::LazyLock; - use crate::{ settings::{FitIn, ResponseMode}, - Filter, Server, + Filter, Server, SettingsBuilder, }; const TEST_BASE: &str = "http://my.server.com"; const SECURITY_KEY: &str = "my-security-key"; const IMAGE_PATH: &str = "my.server.com/some/path/to/image.jpg"; -static SERVER: LazyLock = - LazyLock::new(|| Server::new(TEST_BASE, SECURITY_KEY).expect("Server creation failed")); + +fn new_builder() -> SettingsBuilder { + Server::new(TEST_BASE, SECURITY_KEY) + .expect("Server creation failed") + .settings_builder() +} #[test] fn signing_of_a_known_url_results() { let width = 300; let height = 200; - let builder = SERVER.settings_builder().resize((width, height)).build(); + let settings = new_builder().resize((width, height)).build(); - let path = builder.to_path(IMAGE_PATH); + let path = settings.to_path(IMAGE_PATH); assert_eq!( path, @@ -28,12 +30,9 @@ fn signing_of_a_known_url_results() { #[test] fn signature_with_meta() { - let builder = SERVER - .settings_builder() - .response(ResponseMode::Metadata) - .build(); + let settings = new_builder().response(ResponseMode::Metadata).build(); - let path = builder.to_path(IMAGE_PATH); + let path = settings.to_path(IMAGE_PATH); assert_eq!( path, @@ -43,9 +42,9 @@ fn signature_with_meta() { #[test] fn signature_with_smart() { - let builder = SERVER.settings_builder().smart(true).build(); + let settings = new_builder().smart(true).build(); - let path = builder.to_path(IMAGE_PATH); + let path = settings.to_path(IMAGE_PATH); assert_eq!( path, @@ -55,9 +54,9 @@ fn signature_with_smart() { #[test] fn signature_with_fit_in() { - let builder = SERVER.settings_builder().fit_in(FitIn::Default).build(); + let settings = new_builder().fit_in(FitIn::Default).build(); - let path = builder.to_path(IMAGE_PATH); + let path = settings.to_path(IMAGE_PATH); assert_eq!( path, @@ -67,12 +66,11 @@ fn signature_with_fit_in() { #[test] fn signature_with_filters() { - let builder = SERVER - .settings_builder() + let settings = new_builder() .filters([Filter::Brightness(10), Filter::Contrast(20)]) .build(); - let path = builder.to_path(IMAGE_PATH); + let path = settings.to_path(IMAGE_PATH); assert_eq!( path,