Skip to content

Commit 4bfe207

Browse files
committed
Merge branch 'jbp-improve-ci-2' into main
2 parents 3e30b11 + 3b5b740 commit 4bfe207

File tree

8 files changed

+119
-64
lines changed

8 files changed

+119
-64
lines changed

.azure-pipelines.yml

-45
This file was deleted.

.github/workflows/build.yml

+88-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
1+
name: rustls
2+
3+
permissions:
4+
contents: read
5+
16
on: [push, pull_request]
2-
name: hyper-rustls
37

48
jobs:
59
build:
6-
name: "Build and test"
10+
name: Build+test
711
runs-on: ${{ matrix.os }}
812
strategy:
13+
fail-fast: false
914
matrix:
1015
# test a bunch of toolchains on ubuntu
1116
rust:
1217
- stable
1318
- beta
1419
- nightly
20+
- 1.50.0
1521
os: [ubuntu-18.04]
1622
# but only stable on macos/windows (slower platforms)
1723
include:
@@ -22,13 +28,18 @@ jobs:
2228
steps:
2329
- name: Checkout sources
2430
uses: actions/checkout@v2
31+
with:
32+
persist-credentials: false
2533

2634
- name: Install ${{ matrix.rust }} toolchain
2735
uses: actions-rs/toolchain@v1
2836
with:
2937
toolchain: ${{ matrix.rust }}
3038
override: true
3139

40+
- name: cargo check (default features)
41+
run: cargo check --all-targets
42+
3243
- name: cargo test (debug; default features)
3344
run: cargo test
3445
env:
@@ -41,10 +52,81 @@ jobs:
4152

4253
- name: cargo test (debug; webpki-tokio only)
4354
run: cargo test --no-default-features --features webpki-tokio
55+
env:
56+
RUST_BACKTRACE: 1
57+
58+
- name: cargo test (debug; all features)
59+
run: cargo test --all-features
60+
env:
61+
RUST_BACKTRACE: 1
62+
63+
- name: cargo build (debug; no default features)
64+
run: cargo build --no-default-features
65+
66+
- name: cargo test (debug; no default features; no run)
67+
run: cargo test --no-default-features --no-run
68+
69+
- name: cargo test (release; no run)
70+
run: cargo test --release --no-run
71+
72+
docs:
73+
name: Check for documentation errors
74+
runs-on: ubuntu-18.04
75+
steps:
76+
- name: Checkout sources
77+
uses: actions/checkout@v2
78+
with:
79+
persist-credentials: false
80+
81+
- name: Install rust toolchain
82+
uses: actions-rs/toolchain@v1
83+
with:
84+
toolchain: nightly
85+
override: true
86+
default: true
4487

45-
- name: cargo test (debug; no default features)
46-
run: cargo test --no-default-features
88+
- name: cargo doc (all features)
89+
run: cargo doc --all-features --no-deps
90+
env:
91+
RUSTDOCFLAGS: -Dwarnings
4792

48-
- name: cargo test (release)
49-
run: cargo test --release
93+
format:
94+
name: Format
95+
runs-on: ubuntu-latest
96+
steps:
97+
- name: Checkout sources
98+
uses: actions/checkout@v2
99+
with:
100+
persist-credentials: false
101+
- name: Install rust toolchain
102+
uses: actions-rs/toolchain@v1
103+
with:
104+
toolchain: stable
105+
override: true
106+
default: true
107+
components: rustfmt
108+
- name: Check formatting
109+
uses: actions-rs/cargo@v1
110+
with:
111+
command: fmt
112+
args: --all -- --check
50113

114+
clippy:
115+
name: Clippy
116+
runs-on: ubuntu-latest
117+
steps:
118+
- name: Checkout sources
119+
uses: actions/checkout@v2
120+
with:
121+
persist-credentials: false
122+
- name: Install rust toolchain
123+
uses: actions-rs/toolchain@v1
124+
with:
125+
toolchain: stable
126+
override: true
127+
default: true
128+
components: clippy
129+
- uses: actions-rs/cargo@v1
130+
with:
131+
command: clippy
132+
args: --all-features -- -D warnings

.rustfmt.toml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
chain_width=40

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ This is an integration between the [rustls TLS stack](https://github.com/ctz/rus
33
and the [hyper HTTP library](https://github.com/hyperium/hyper).
44

55
[![Build Status](https://github.com/ctz/hyper-rustls/workflows/hyper-rustls/badge.svg)](https://github.com/ctz/hyper-rustls/actions)
6-
[![Build Status](https://dev.azure.com/ctz99/ctz/_apis/build/status/ctz.hyper-rustls?branchName=master)](https://dev.azure.com/ctz99/ctz/_build/latest?definitionId=4&branchName=master)
76
[![Crate](https://img.shields.io/crates/v/hyper-rustls.svg)](https://crates.io/crates/hyper-rustls)
87
[![Documentation](https://docs.rs/hyper-rustls/badge.svg)](https://docs.rs/hyper-rustls/)
98

examples/server.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ fn load_certs(filename: &str) -> io::Result<Vec<rustls::Certificate>> {
109109
// Load and return certificate.
110110
let certs = rustls_pemfile::certs(&mut reader)
111111
.map_err(|_| error("failed to load certificate".into()))?;
112-
Ok(certs.into_iter().map(rustls::Certificate).collect())
112+
Ok(certs
113+
.into_iter()
114+
.map(rustls::Certificate)
115+
.collect())
113116
}
114117

115118
// Load private key from file.

src/config.rs

+12-7
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,18 @@ impl ConfigBuilderExt for ConfigBuilder<ClientConfig, WantsVerifier> {
5454
#[cfg_attr(docsrs, doc(cfg(feature = "webpki-roots")))]
5555
fn with_webpki_roots(self) -> ConfigBuilder<ClientConfig, WantsTransparencyPolicyOrClientCert> {
5656
let mut roots = rustls::RootCertStore::empty();
57-
roots.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map(|ta| {
58-
rustls::OwnedTrustAnchor::from_subject_spki_name_constraints(
59-
ta.subject,
60-
ta.spki,
61-
ta.name_constraints,
62-
)
63-
}));
57+
roots.add_server_trust_anchors(
58+
webpki_roots::TLS_SERVER_ROOTS
59+
.0
60+
.iter()
61+
.map(|ta| {
62+
rustls::OwnedTrustAnchor::from_subject_spki_name_constraints(
63+
ta.subject,
64+
ta.spki,
65+
ta.name_constraints,
66+
)
67+
}),
68+
);
6469
self.with_root_certificates(roots)
6570
}
6671
}

src/connector.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,25 @@ where
7474
let connecting_future = self.http.call(dst);
7575

7676
let f = async move {
77-
let tcp = connecting_future.await.map_err(Into::into)?;
77+
let tcp = connecting_future
78+
.await
79+
.map_err(Into::into)?;
7880

7981
Ok(MaybeHttpsStream::Http(tcp))
8082
};
8183
Box::pin(f)
8284
} else if sch == &http::uri::Scheme::HTTPS {
8385
let cfg = self.tls_config.clone();
84-
let hostname = dst.host().unwrap_or_default().to_string();
86+
let hostname = dst
87+
.host()
88+
.unwrap_or_default()
89+
.to_string();
8590
let connecting_future = self.http.call(dst);
8691

8792
let f = async move {
88-
let tcp = connecting_future.await.map_err(Into::into)?;
93+
let tcp = connecting_future
94+
.await
95+
.map_err(Into::into)?;
8996
let connector = TlsConnector::from(cfg);
9097
let dnsname = rustls::ServerName::try_from(hostname.as_str())
9198
.map_err(|_| io::Error::new(io::ErrorKind::Other, "invalid dnsname"))?;

src/connector/builder.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,10 @@ mod tests {
284284
.https_only()
285285
.enable_http1()
286286
.build();
287-
assert!(connector.tls_config.alpn_protocols.is_empty());
287+
assert!(connector
288+
.tls_config
289+
.alpn_protocols
290+
.is_empty());
288291
let connector = HttpsConnectorBuilder::new()
289292
.with_tls_config(tls_config.clone())
290293
.https_only()

0 commit comments

Comments
 (0)