Skip to content

Commit 81224df

Browse files
committed
Merge #400: Integrate bitreq crate into CI tests
3497da8 Remove bitreq README.md MSRV and test badges (Jamil Lambert, PhD) 9fd5af7 Remove bitreq github workflows (Jamil Lambert, PhD) df90f00 Add bitreq to list of crates to test (Jamil Lambert, PhD) 8f30a45 Add testvars.sh to bitreq (Jamil Lambert, PhD) 921652d Remove std attribute from no-std example (Jamil Lambert, PhD) f97b8c6 Remove trailing whitespaces from no-std example (Jamil Lambert, PhD) cf0e5a5 Replace LazyLock with OnceLock (Jamil Lambert, PhD) de4ece5 Make proxy std only (Jamil Lambert, PhD) Pull request description: `bitreq` was developed as a standalone repo with its own `.github/workflow` directory that had workflows to test and lint it. It's now a leaf crate in `corepc` and test and lint workflows in its own subdirectory are not run. It is not included in CI tests and contains some issues that cause CI tests to fail. Fix the CI errors, integrate into CI and remove redundant workflow files and badges: - Add `std` to the `proxy` feature since it only works with `std`. - Replace `LazyLock` which is only in stable rustc from 1.80. Use `OnceLock` instead which is stable from 1.70. - Remove trailing white spaces from the `no-std` example. - Remove `std` attribute from `no-std.rs`. The example is broken and commented out, but still causes a compile failure in `no-std` since the attribute made the module empty. The example was left in so that it can be fixed and used later rather than just deleting it. - Add `test_vars.sh` to integrate `bitreq` into the CI tests. - Add `bitreq` to the list of crates to test. - Remove the workflow files in the `bitreq` subdirectory, these are no longer run now it is part of the `corepc` workspace and not its own repo. - Remove the broken `README.md` badges. Closes #397 ACKs for top commit: oleonardolima: cACK 3497da8 tcharding: ACK 3497da8 Tree-SHA512: 850a222d9d427393680e9d49c9b61b8c64dc1efd09d85a2e27b2a9b68576f4a8b5fa40cf4e1df640c0e9032b4f1dec21f28692ae96340425e1028943f4ae6637
2 parents b68f20d + 3497da8 commit 81224df

File tree

9 files changed

+25
-129
lines changed

9 files changed

+25
-129
lines changed

bitreq/.github/workflows/lint.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

bitreq/.github/workflows/msrv.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

bitreq/.github/workflows/unit-tests.yml

Lines changed: 0 additions & 63 deletions
This file was deleted.

bitreq/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ https = ["https-rustls"]
5050
https-rustls = ["rustls", "webpki-roots", "rustls-webpki"]
5151
https-rustls-probe = ["rustls", "rustls-native-certs"]
5252
json-using-serde = ["serde", "serde_json"]
53-
proxy = ["base64"]
53+
proxy = ["base64", "std"]
5454
async = ["tokio", "std"]
5555
async-https = ["async", "https-rustls", "tokio-rustls"]
5656

bitreq/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# bitreq - forked from minreq
22
[![Crates.io](https://img.shields.io/crates/d/bitreq.svg)](https://crates.io/crates/bitreq)
33
[![Documentation](https://docs.rs/bitreq/badge.svg)](https://docs.rs/bitreq)
4-
![Unit tests](https://github.com/tcharding/bitreq/actions/workflows/unit-tests.yml/badge.svg)
5-
![MSRV](https://github.com/tcharding/bitreq/actions/workflows/msrv.yml/badge.svg)
64

75
This crate is a fork for the very nice
86
[minreq](https://github.com/neonmoe/minreq). I chose to fork and

bitreq/contrib/test_vars.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# No shebang, this file should not be executed.
2+
# shellcheck disable=SC2148
3+
#
4+
# disable verify unused vars, despite the fact that they are used when sourced
5+
# shellcheck disable=SC2034
6+
7+
# Test all these features with "std" enabled.
8+
FEATURES_WITH_STD="log https https-rustls proxy async async-https"
9+
10+
# Test all these features without "std" enabled.
11+
FEATURES_WITHOUT_STD="log https https-rustls"
12+
13+
# Run these examples.
14+
EXAMPLES=""

bitreq/examples/no-std.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//! This is a simple example to demonstrate the usage of this library.
22
3-
#![cfg(feature = "std")]
4-
53
const _RESPONSE: &str = r#"<!doctype html>
64
<html>
75
<head>
@@ -16,7 +14,7 @@ const _RESPONSE: &str = r#"<!doctype html>
1614
margin: 0;
1715
padding: 0;
1816
font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
19-
17+
2018
}
2119
div {
2220
width: 600px;
@@ -36,7 +34,7 @@ const _RESPONSE: &str = r#"<!doctype html>
3634
width: auto;
3735
}
3836
}
39-
</style>
37+
</style>
4038
</head>
4139
4240
<body>

bitreq/src/connection/rustls_stream.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use alloc::sync::Arc;
55
use core::convert::TryFrom;
66
use std::io::{self, Write};
77
use std::net::TcpStream;
8+
use std::sync::OnceLock;
89

910
use rustls::{self, ClientConfig, ClientConnection, RootCertStore, ServerName, StreamOwned};
1011
#[cfg(feature = "rustls-webpki")]
@@ -15,8 +16,9 @@ use crate::Error;
1516

1617
pub type SecuredStream = StreamOwned<ClientConnection, TcpStream>;
1718

18-
#[allow(clippy::incompatible_msrv)] // We only guarantee MSRV for a subset of features.
19-
static CONFIG: std::sync::LazyLock<Arc<ClientConfig>> = std::sync::LazyLock::new(|| {
19+
static CONFIG: OnceLock<Arc<ClientConfig>> = OnceLock::new();
20+
21+
fn build_client_config() -> Arc<ClientConfig> {
2022
let mut root_certificates = RootCertStore::empty();
2123

2224
// Try to load native certs
@@ -44,7 +46,7 @@ static CONFIG: std::sync::LazyLock<Arc<ClientConfig>> = std::sync::LazyLock::new
4446
.with_root_certificates(root_certificates)
4547
.with_no_client_auth();
4648
Arc::new(config)
47-
});
49+
}
4850

4951
pub fn create_secured_stream(conn: &Connection) -> Result<HttpStream, Error> {
5052
// Rustls setup
@@ -54,8 +56,8 @@ pub fn create_secured_stream(conn: &Connection) -> Result<HttpStream, Error> {
5456
Ok(result) => result,
5557
Err(err) => return Err(Error::IoError(io::Error::new(io::ErrorKind::Other, err))),
5658
};
57-
let sess =
58-
ClientConnection::new(CONFIG.clone(), dns_name).map_err(Error::RustlsCreateConnection)?;
59+
let sess = ClientConnection::new(CONFIG.get_or_init(build_client_config).clone(), dns_name)
60+
.map_err(Error::RustlsCreateConnection)?;
5961

6062
// Connect
6163
#[cfg(feature = "log")]

contrib/crates.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# shellcheck disable=SC2148
33

44
# Crates in this workspace to test.
5-
CRATES=("types" "client" "jsonrpc")
5+
CRATES=("bitreq" "client" "jsonrpc" "types")

0 commit comments

Comments
 (0)