Skip to content

Commit

Permalink
Merge pull request #62 from martinthomson/ci-msrv
Browse files Browse the repository at this point in the history
Continuous integration updates
  • Loading branch information
martinthomson authored Jan 13, 2024
2 parents bf02e48 + 915c8d8 commit fab4f0a
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 92 deletions.
2 changes: 1 addition & 1 deletion .clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
msrv = "1.52.0"
msrv = "1.63.0"
105 changes: 41 additions & 64 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,42 @@
name: CI
on: [push, pull_request]
on:
push:
branches: ["main"]
paths-ignore: ["*.md", "LICENSE-*"]
pull_request:
branches: ["main"]
paths-ignore: ["*.md", "LICENSE-*"]
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1

jobs:
check_nss:
name: NSS Build
check:
name: Continuous Integration
runs-on: ubuntu-latest
env:
RUSTFLAGS: -C link-arg=-fuse-ld=lld
NSS_DIR: ${{ github.workspace }}/nss
strategy:
fail-fast: false
matrix:
hpke:
- nss
- rust-hpke
rust:
- 1.63.0 # MSRV
- stable

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: actions-rs/toolchain@v1
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy, llvm-tools-preview

- name: Install Build Prerequisites for NSS
if: matrix.hpke == 'nss'
run: |
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y \
build-essential \
Expand All @@ -39,71 +57,30 @@ jobs:
ssh \
zlib1g-dev \
--no-install-recommends
echo RUSTFLAGS="-C link-arg=-fuse-ld=lld" >> "$GITHUB_ENV"
- name: Fetch NSS and NSPR
if: matrix.hpke == 'nss'
run: |
hg clone https://hg.mozilla.org/projects/nspr "$NSS_DIR"/../nspr
git clone --depth 1 https://github.com/nss-dev/nss "$NSS_DIR"
echo "LD_LIBRARY_PATH=${{ github.workspace }}/dist/Debug/lib" >> "$GITHUB_ENV"
- uses: actions-rs/cargo@v1
name: Build
with:
command: build
args: --tests --no-default-features --features nss,client,server

- uses: actions-rs/cargo@v1
name: Run Tests
with:
command: test
args: --no-default-features --features nss,client,server
env:
LD_LIBRARY_PATH: ${{ github.workspace }}/dist/Debug/lib

- uses: actions-rs/cargo@v1
name: Check formatting
if: ${{ success() || failure() }}
with:
command: fmt
args: --all -- --check --config imports_granularity=Crate

- uses: actions-rs/cargo@v1
name: Clippy
if: ${{ success() || failure() }}
with:
command: clippy
args: --tests --no-default-features --features nss,client,server

check_rust_hpke:
name: rust-hpke Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions-rs/toolchain@v1
with:
toolchain: stable

- uses: actions-rs/cargo@v1
name: Build
with:
command: build
args: --tests
- name: Build
run: |
cargo +${{ matrix.rust }} build --tests --no-default-features --features ${{ matrix.hpke }},client,server
- uses: actions-rs/cargo@v1
name: Run Tests
with:
command: test
- name: Run Tests
run: |
cargo +${{ matrix.rust }} test --no-default-features --features ${{ matrix.hpke }},client,server
- uses: actions-rs/cargo@v1
name: Check formatting
- name: Check formatting
if: ${{ success() || failure() }}
with:
command: fmt
args: --all -- --check --config imports_granularity=Crate
run: |
cargo +${{ matrix.rust }} fmt --all -- --check --config imports_granularity=Crate
- uses: actions-rs/cargo@v1
name: Clippy
- name: Clippy
if: ${{ success() || failure() }}
with:
command: clippy
args: --tests
run: |
cargo clippy --tests --no-default-features --features ${{ matrix.hpke }},client,server
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,7 @@ clippy --tests`.
There is a pre-commit script that you can link to `.git/hooks/pre-commit` that
runs `cargo fmt` on all commits. Just run `./pre-commit install` to have it
install itself.

## Minnimum Supported Rust Version (MSRV)

`ohttp` and `bhttp` should compile on Rust 1.63.0.
1 change: 1 addition & 0 deletions bhttp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "bhttp"
version = "0.5.1"
authors = ["Martin Thomson <[email protected]>"]
edition = "2021"
rust-version = "1.63.0"
license = "MIT OR Apache-2.0"
description = "Binary HTTP messages (draft-ietf-httpbis-binary-message)"
repository = "https://github.com/martinthomson/ohttp"
Expand Down
2 changes: 1 addition & 1 deletion bhttp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ impl Message {

let mut header = FieldSection::read_http(r)?;

let (content, trailer) = if matches!(control.status(), Some(204) | Some(304)) {
let (content, trailer) = if matches!(control.status(), Some(204 | 304)) {
// 204 and 304 have no body, no matter what Content-Length says.
// Unfortunately, we can't do the same for responses to HEAD.
(Vec::new(), FieldSection::default())
Expand Down
2 changes: 1 addition & 1 deletion ohttp-client-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ nss = ["ohttp/nss"]
rust-hpke = ["ohttp/rust-hpke"]

[dependencies]
env_logger = {version = "0.9", default-features = false}
env_logger = {version = "0.10", default-features = false}
hex = "0.4"

[dependencies.bhttp]
Expand Down
4 changes: 2 additions & 2 deletions ohttp-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ nss = ["ohttp/nss"]
rust-hpke = ["ohttp/rust-hpke"]

[dependencies]
env_logger = {version = "0.9", default-features = false}
env_logger = {version = "0.10", default-features = false}
hex = "0.4"
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls"] }
rustls = { version = "0.19", features = ["dangerous_configuration"]}
rustls = { version = "0.21.6", features = ["dangerous_configuration"] }
structopt = "0.3"
tokio = { version = "1", features = ["full"] }

Expand Down
1 change: 1 addition & 0 deletions ohttp-client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ async fn main() -> Res<()> {
File::open(pem)?.read_to_end(&mut buf)?;
let cert = reqwest::Certificate::from_pem(buf.as_slice())?;
reqwest::ClientBuilder::new()
.danger_accept_invalid_certs(true)
.add_root_certificate(cert)
.build()?
}
Expand Down
2 changes: 1 addition & 1 deletion ohttp-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ nss = ["ohttp/nss"]
rust-hpke = ["ohttp/rust-hpke"]

[dependencies]
env_logger = {version = "0.9", default-features = false}
env_logger = {version = "0.10", default-features = false}
hex = "0.4"
structopt = "0.3"
tokio = { version = "1", features = ["full"] }
Expand Down
2 changes: 1 addition & 1 deletion ohttp-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async fn serve(
if let Ok(oe) = e.downcast::<::ohttp::Error>() {
Ok(warp::http::Response::builder()
.status(422)
.body(Vec::from(format!("Error: {:?}", oe).as_bytes())))
.body(Vec::from(format!("Error: {oe:?}").as_bytes())))
} else {
Ok(warp::http::Response::builder()
.status(400)
Expand Down
27 changes: 17 additions & 10 deletions ohttp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,42 @@ name = "ohttp"
version = "0.5.1"
authors = ["Martin Thomson <[email protected]>"]
edition = "2021"
rust-version = "1.63.0"
build = "build.rs"
license = "MIT OR Apache-2.0"
description = "Oblivious HTTP"
repository = "https://github.com/martinthomson/ohttp"

[features]
default = ["client", "server", "rust-hpke"]
app-svc = ["nss"]
client = []
server = []
nss = ["bindgen"]
external-sqlite = []
gecko = ["nss", "mozbuild"]
nss = ["bindgen", "regex-mess"]
pq = ["hpke-pq"]
regex-mess = ["regex", "regex-automata", "regex-syntax"]
rust-hpke = ["rand", "aead", "aes-gcm", "chacha20poly1305", "hkdf", "sha2", "hpke"]
gecko = ["nss", "mozbuild"]
app-svc = ["nss"]
external-sqlite = []
server = []

[dependencies]
aead = {version = "0.4", optional = true, features = ["std"]}
aes-gcm = {version = "0.9", optional = true}
byteorder = "1.3"
byteorder = "1.4"
chacha20poly1305 = {version = "0.8", optional = true}
hex = "0.4"
hkdf = {version = "0.11", optional = true}
hpke = {version = "0.10.0", optional = true, default-features = false, features = ["std", "x25519"]}
lazy_static = "1.4"
log = {version = "0.4.0", default-features = false}
log = {version = "0.4", default-features = false}
rand = {version = "0.8", optional = true}
# bindgen uses regex and friends, which have been updated past our MSRV
# however, the cargo resolver happily resolves versions that it can't compile
regex = {version = "~1.9", optional = true}
regex-automata = {version = "~0.3", optional = true}
regex-syntax = {version = "~0.7", optional = true}
sha2 = {version = "0.9", optional = true}
thiserror = "1"
hpke = {version = "0.10.0", optional = true, default-features = false, features = ["std", "x25519"]}

[dependencies.hpke-pq]
package = "hpke_pq"
Expand All @@ -50,10 +57,10 @@ serde_derive = "1.0"
toml = "0.5"

[build-dependencies.bindgen]
version = "0.64"
version = "0.69"
default-features = false
optional = true
features = ["runtime"]

[dev-dependencies]
env_logger = {version = "0.9", default-features = false}
env_logger = {version = "0.10", default-features = false}
20 changes: 10 additions & 10 deletions ohttp/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ mod nss {
libs.append(&mut nspr_libs());

for lib in &libs {
println!("cargo:rustc-link-lib=dylib={}", lib);
println!("cargo:rustc-link-lib=dylib={lib}");
}
}

Expand Down Expand Up @@ -230,10 +230,10 @@ mod nss {
}

for lib in &static_libs {
println!("cargo:rustc-link-lib=static={}", lib);
println!("cargo:rustc-link-lib=static={lib}");
}
for lib in &dynamic_libs {
println!("cargo:rustc-link-lib=dylib={}", lib);
println!("cargo:rustc-link-lib=dylib={lib}");
}
}

Expand All @@ -253,7 +253,7 @@ mod nss {
let header = header_path.to_str().unwrap();
let out = PathBuf::from(env::var("OUT_DIR").unwrap()).join(String::from(base) + ".rs");

println!("cargo:rerun-if-changed={}", header);
println!("cargo:rerun-if-changed={header}");

let mut builder = Builder::default().header(header);
builder = builder.generate_comments(false);
Expand Down Expand Up @@ -341,7 +341,7 @@ mod nss {

fn pkg_config() -> Vec<String> {
let modversion = Command::new("pkg-config")
.args(&["--modversion", "nss"])
.args(["--modversion", "nss"])
.output()
.expect("pkg-config reports NSS as absent")
.stdout;
Expand All @@ -364,7 +364,7 @@ mod nss {
}

let cfg = Command::new("pkg-config")
.args(&["--cflags", "--libs", "nss"])
.args(["--cflags", "--libs", "nss"])
.output()
.expect("NSS flags not returned by pkg-config")
.stdout;
Expand All @@ -374,13 +374,13 @@ mod nss {
for f in cfg_str.split(' ') {
if let Some(include) = f.strip_prefix("-I") {
flags.push(String::from(f));
println!("cargo:include={}", include);
println!("cargo:include={include}");
} else if let Some(path) = f.strip_prefix("-L") {
println!("cargo:rustc-link-search=native={}", path);
println!("cargo:rustc-link-search=native={path}");
} else if let Some(lib) = f.strip_prefix("-l") {
println!("cargo:rustc-link-lib=dylib={}", lib);
println!("cargo:rustc-link-lib=dylib={lib}");
} else {
println!("Warning: Unknown flag from pkg-config: {}", f);
println!("Warning: Unknown flag from pkg-config: {f}");
}
}

Expand Down
2 changes: 1 addition & 1 deletion ohttp/src/nss/hkdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub enum KeyMechanism {
impl KeyMechanism {
fn mech(self) -> CK_MECHANISM_TYPE {
CK_MECHANISM_TYPE::from(match self {
Self::Aead(Aead::Aes128Gcm) | Self::Aead(Aead::Aes256Gcm) => CKM_AES_GCM,
Self::Aead(Aead::Aes128Gcm | Aead::Aes256Gcm) => CKM_AES_GCM,
Self::Aead(Aead::ChaCha20Poly1305) => CKM_CHACHA20_POLY1305,
Self::Hkdf => CKM_HKDF_DERIVE,
})
Expand Down

0 comments on commit fab4f0a

Please sign in to comment.