mirror of
https://github.com/MingweiSamuel/Riven.git
synced 2025-01-24 09:47:26 -08:00
Fix #77 * Check MSRV in CI * Lower MSRV to 1.71.1 by gating `allow(..., reason = "...")` * Sets all min dependency crate versions needed by riven, via `-Z direct-minimal-versions` * Adds `test-min-deps.bash` script to run `-Z direct-minimal-versions` * Removes underutilized `scan_fmt` dependency, replaces with simple string manipulation code
This commit is contained in:
parent
bb8bd229f0
commit
561139e91f
5 changed files with 75 additions and 37 deletions
36
.github/workflows/ci.yml
vendored
36
.github/workflows/ci.yml
vendored
|
@ -35,16 +35,16 @@ jobs:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Node
|
# - name: Setup Node
|
||||||
uses: actions/setup-node@v4
|
# uses: actions/setup-node@v4
|
||||||
with:
|
# with:
|
||||||
node-version: 20
|
# node-version: 20
|
||||||
|
|
||||||
- name: Install Node dependencies
|
# - name: Install Node dependencies
|
||||||
run: npm ci --prefix riven/srcgen
|
# run: npm ci --prefix riven/srcgen
|
||||||
|
|
||||||
- name: Run codegen
|
# - name: Run codegen
|
||||||
run: node riven/srcgen
|
# run: node riven/srcgen
|
||||||
|
|
||||||
- name: Install Rust nightly toolchain
|
- name: Install Rust nightly toolchain
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
|
@ -121,3 +121,23 @@ jobs:
|
||||||
with:
|
with:
|
||||||
command: clippy
|
command: clippy
|
||||||
args: --all-features --all-targets -- -D warnings
|
args: --all-features --all-targets -- -D warnings
|
||||||
|
|
||||||
|
msrv:
|
||||||
|
name: Verify MSRV
|
||||||
|
needs: pre_job
|
||||||
|
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install Rust nightly toolchain
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
profile: minimal
|
||||||
|
toolchain: nightly
|
||||||
|
override: true
|
||||||
|
components: rustfmt
|
||||||
|
|
||||||
|
- run: cargo install cargo-msrv --no-default-features
|
||||||
|
- run: cargo msrv verify --path riven
|
||||||
|
|
|
@ -7,6 +7,7 @@ description = "Riot Games API Library"
|
||||||
readme = "../README.md"
|
readme = "../README.md"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
rust-version = "1.71.1"
|
||||||
include = ["src/**", "../README.md", "/examples"]
|
include = ["src/**", "../README.md", "/examples"]
|
||||||
keywords = ["riot-games", "riot", "league", "league-of-legends"]
|
keywords = ["riot-games", "riot", "league", "league-of-legends"]
|
||||||
categories = ["api-bindings", "web-programming::http-client", "wasm"]
|
categories = ["api-bindings", "web-programming::http-client", "wasm"]
|
||||||
|
@ -48,45 +49,45 @@ name = "proxy"
|
||||||
required-features = ["__proxy"]
|
required-features = ["__proxy"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
futures = "0.3"
|
futures = "0.3.0"
|
||||||
log = "0.4"
|
log = "0.4.8"
|
||||||
memo-map = "0.3"
|
memo-map = "0.3.0"
|
||||||
metrics = { version = "0.24", optional = true }
|
metrics = { version = "0.24.0", optional = true }
|
||||||
num_enum = "0.5"
|
num_enum = "0.5.0"
|
||||||
parking_lot = "0.12"
|
parking_lot = "0.12.0"
|
||||||
reqwest = { version = "0.11", default-features = false, features = [
|
reqwest = { version = "0.11.2", default-features = false, features = [
|
||||||
"gzip",
|
"gzip",
|
||||||
"json",
|
"json",
|
||||||
] }
|
] }
|
||||||
scan_fmt = { version = "0.2", default-features = false }
|
serde = { version = "1.0.85", features = ["derive"] }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde_derive = "1.0.85"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0.1"
|
||||||
serde_repr = "0.1"
|
serde_repr = "0.1.0"
|
||||||
slab = "0.4"
|
slab = "0.4.4"
|
||||||
strum = "0.20"
|
strum = "0.20.0"
|
||||||
strum_macros = "0.20"
|
strum_macros = "0.20.0"
|
||||||
tracing = { version = "0.1", optional = true }
|
tracing = { version = "0.1.22", optional = true }
|
||||||
|
|
||||||
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
||||||
tokio = { version = "1", default-features = false, features = ["time"] }
|
tokio = { version = "1.20.0", default-features = false, features = ["time"] }
|
||||||
|
|
||||||
[target.'cfg(target_family = "wasm")'.dependencies]
|
[target.'cfg(target_family = "wasm")'.dependencies]
|
||||||
gloo-timers = { version = "0.3", features = ["futures"] }
|
gloo-timers = { version = "0.3", features = ["futures"] }
|
||||||
web-time = "1.0.0"
|
web-time = "1.0.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
env_logger = "0.11.0"
|
env_logger = ">=0.10.0,<0.12.0"
|
||||||
fake_instant = "0.5.0"
|
fake_instant = "0.5.0"
|
||||||
tracing = "0.1"
|
tracing = "0.1.22"
|
||||||
tracing-subscriber = "0.3.17"
|
tracing-subscriber = "0.3.17"
|
||||||
|
|
||||||
[target.'cfg(not(target_family = "wasm"))'.dev-dependencies]
|
[target.'cfg(not(target_family = "wasm"))'.dev-dependencies]
|
||||||
hyper = { version = "0.14", features = ["server"] }
|
hyper = { version = "0.14.5", features = ["server"] }
|
||||||
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
|
tokio = { version = "1.20.0", features = ["macros", "rt-multi-thread"] }
|
||||||
tokio-shared-rt = "0.1"
|
tokio-shared-rt = "0.1.0"
|
||||||
|
|
||||||
[target.'cfg(target_family = "wasm")'.dev-dependencies]
|
[target.'cfg(target_family = "wasm")'.dev-dependencies]
|
||||||
console_error_panic_hook = "0.1"
|
console_error_panic_hook = "0.1"
|
||||||
console_log = "1.0"
|
console_log = "1.0"
|
||||||
wasm-bindgen = "0.2"
|
wasm-bindgen = "0.2.70"
|
||||||
wasm-bindgen-test = "0.3"
|
wasm-bindgen-test = "0.3"
|
||||||
|
|
|
@ -3,7 +3,6 @@ use std::cmp;
|
||||||
use futures::FutureExt;
|
use futures::FutureExt;
|
||||||
use parking_lot::{RwLock, RwLockUpgradableReadGuard};
|
use parking_lot::{RwLock, RwLockUpgradableReadGuard};
|
||||||
use reqwest::{Response, StatusCode};
|
use reqwest::{Response, StatusCode};
|
||||||
use scan_fmt::scan_fmt;
|
|
||||||
#[cfg(feature = "tracing")]
|
#[cfg(feature = "tracing")]
|
||||||
use tracing as log;
|
use tracing as log;
|
||||||
|
|
||||||
|
@ -272,11 +271,19 @@ fn buckets_from_header(
|
||||||
debug_assert!(size == count_header.split(',').count());
|
debug_assert!(size == count_header.split(',').count());
|
||||||
let mut out = Vec::with_capacity(size);
|
let mut out = Vec::with_capacity(size);
|
||||||
|
|
||||||
|
// Pair: "100:60"
|
||||||
|
fn scan_pair(entry: &str) -> Option<(usize, u64)> {
|
||||||
|
let (val_str, secs_str) = entry.split_once(':')?;
|
||||||
|
let val: usize = val_str.parse().ok()?;
|
||||||
|
let secs: u64 = secs_str.parse().ok()?;
|
||||||
|
Some((val, secs))
|
||||||
|
}
|
||||||
|
|
||||||
for (limit_entry, count_entry) in limit_header.split(',').zip(count_header.split(',')) {
|
for (limit_entry, count_entry) in limit_header.split(',').zip(count_header.split(',')) {
|
||||||
let (limit, limit_secs) = scan_fmt!(limit_entry, "{d}:{d}", usize, u64)
|
let (limit, limit_secs) = scan_pair(limit_entry)
|
||||||
.unwrap_or_else(|_| panic!("Failed to parse limit entry \"{}\".", limit_entry));
|
.unwrap_or_else(|| panic!("Failed to parse limit entry \"{}\".", limit_entry));
|
||||||
let (count, count_secs) = scan_fmt!(count_entry, "{d}:{d}", usize, u64)
|
let (count, count_secs) = scan_pair(count_entry)
|
||||||
.unwrap_or_else(|_| panic!("Failed to parse count entry \"{}\".", count_entry));
|
.unwrap_or_else(|| panic!("Failed to parse count entry \"{}\".", count_entry));
|
||||||
debug_assert!(limit_secs == count_secs);
|
debug_assert!(limit_secs == count_secs);
|
||||||
|
|
||||||
let rate_usage_factor = if RateLimitType::Application == rate_limit_type {
|
let rate_usage_factor = if RateLimitType::Application == rate_limit_type {
|
||||||
|
|
|
@ -30,13 +30,15 @@ pub trait TokenBucket {
|
||||||
/// Get the duration of this bucket.
|
/// Get the duration of this bucket.
|
||||||
/// # Returns
|
/// # Returns
|
||||||
/// Duration of the bucket.
|
/// Duration of the bucket.
|
||||||
#[allow(dead_code, reason = "false positive")]
|
#[cfg_attr(feature = "nightly", allow(dead_code, reason = "false positive"))]
|
||||||
|
#[cfg_attr(not(feature = "nightly"), allow(dead_code))]
|
||||||
fn get_bucket_duration(&self) -> Duration;
|
fn get_bucket_duration(&self) -> Duration;
|
||||||
|
|
||||||
/// Get the total limit of this bucket per timespan.
|
/// Get the total limit of this bucket per timespan.
|
||||||
/// # Returns
|
/// # Returns
|
||||||
/// Total limit per timespan.
|
/// Total limit per timespan.
|
||||||
#[allow(dead_code, reason = "false positive")]
|
#[cfg_attr(feature = "nightly", allow(dead_code, reason = "false positive"))]
|
||||||
|
#[cfg_attr(not(feature = "nightly"), allow(dead_code))]
|
||||||
fn get_total_limit(&self) -> usize;
|
fn get_total_limit(&self) -> usize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
8
test-min-deps.bash
Normal file
8
test-min-deps.bash
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -euxo pipefail
|
||||||
|
|
||||||
|
RUSTFLAGS='-Aunexpected_cfgs'
|
||||||
|
cargo update -Z direct-minimal-versions
|
||||||
|
cargo build --all-targets
|
||||||
|
|
||||||
|
./test.bash
|
Loading…
Reference in a new issue