Skip to content

Commit

Permalink
ci: msrv
Browse files Browse the repository at this point in the history
  • Loading branch information
SteelAlloy committed Sep 15, 2024
1 parent 1820011 commit 495248f
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 32 deletions.
24 changes: 19 additions & 5 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
37 changes: 30 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,36 @@
<div align="center">
<img src="assets/doc/logo.svg" width="256">
<h1>Rust <a href="https://www.thumbor.org/">Thumbor</a> client</h1>
<a href="https://github.com/SteelAlloy/thumbor-rs">
<img
alt="Repository"
src="https://img.shields.io/badge/github-thumbor--rs-228b22?style=for-the-badge&labelColor=555555&logo=github"
height="25"
/>
</a>
<a href="https://crates.io/crates/thumbor">
<img
alt="Crates.io Version"
src="https://img.shields.io/crates/v/thumbor.svg?style=for-the-badge&color=e37602&logo=rust"
height="25"
/>
</a>
<a href="https://docs.rs/thumbor/latest/thumbor">
<img
alt="docs.rs"
src="https://img.shields.io/badge/docs.rs-thumbor-3b74d1?style=for-the-badge&labelColor=555555&logo=docs.rs"
height="25"
/>
</a>
<a href="https://docs.rs/thumbor/latest/thumbor">
<img
alt="Crates.io MSRV"
src="https://img.shields.io/crates/msrv/thumbor?style=for-the-badge&logo=docs.rs&color=b83fbf"
height="25"
/>
</a>
</div>

[![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 :
Expand All @@ -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");
```
36 changes: 17 additions & 19 deletions src/tests.rs
Original file line number Diff line number Diff line change
@@ -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<Server> =
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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 495248f

Please sign in to comment.