Skip to content

Commit

Permalink
Faster, better CI (#5)
Browse files Browse the repository at this point in the history
* Set msrv, reduce allocation pressure

* Rework error enum

* Change err collection to an option, better test coverage

* Update ci check

* Format

* Bump crate version
  • Loading branch information
MarcusGrass committed Jul 21, 2023
1 parent f882205 commit 5df69ff
Show file tree
Hide file tree
Showing 6 changed files with 194 additions and 154 deletions.
27 changes: 15 additions & 12 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
name: check_commit
name: "CI"

on:
push:
branches:
- main
- dev
pull_request: {}

jobs:
build:
check:
# Want to run this on aarch64 but https://github.com/actions/runner-images/issues/5631
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build no features
run: cargo build --no-default-features --verbose
- name: Run tests no features
run: cargo test --no-default-features
- name: Build with error cause
run: cargo test --features with_error_cause
- name: Run tests with error cause
run: cargo test --features with_error_cause
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: x86_64-unknown-linux-gnu
components: clippy,rustfmt
- name: Check formatting
run: cargo fmt --all --check
- name: Check clippy
run: cargo clippy
- name: test
run: cargo test
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "http-range-header"
version = "0.3.1"
version = "0.4.0"
edition = "2018"
license = "MIT"
readme = "./README.md"
Expand All @@ -11,6 +11,9 @@ categories = ["parser-implementations", "network-programming", "web-programming"
keywords = ["http", "parser", "http-headers", "headers", "range"]
exclude = ["/.github", "CONTRIBUTING.md"]

[package.metadata]
msrv = "1.60.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
with_error_cause = []
Expand Down
12 changes: 12 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
### Fixed

## [0.4.0] - ReleaseDate
### Added
- Bench error performance

### Changed
- Msrv set to 1.60.0 to match [tower-http](https://github.com/tower-rs/tower-http)
- Use higher `Rust` version features to improve performance
- Remove feature `with_error_cause`
- Convert Error into an enum

### Fixed

## [0.3.1] - 2023-07-21

### Fixed
Expand Down
9 changes: 9 additions & 0 deletions benches/benchmark.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use criterion::{black_box, criterion_group, criterion_main};
use http_range_header::RangeUnsatisfiableError;

pub fn bench(c: &mut criterion::Criterion) {
c.bench_function("Standard range", |b| {
Expand Down Expand Up @@ -29,6 +30,14 @@ pub fn bench(c: &mut criterion::Criterion) {
.validate(black_box(10_000))
})
});
c.bench_function("Bad multipart range", |b| {
b.iter(|| {
assert_eq!(
Err(RangeUnsatisfiableError::ZeroSuffix),
http_range_header::parse_range_header(black_box("bytes=0-19, -0"))
);
})
});
}
criterion_group!(benches, bench);
criterion_main!(benches);

0 comments on commit 5df69ff

Please sign in to comment.