Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .github/actions/build-docs/action.yml

This file was deleted.

16 changes: 10 additions & 6 deletions .github/actions/ci/action.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
name: CI Workflow
description: 'Shared CI workflow.'
description: "Shared CI workflow."

inputs:
feature-flags:
description: 'Cargo feature flags to pass to test and clippy commands'
cargo-flags:
description: "Flags to pass to cargo commands."
required: false
default: ''
default: ""
cargo-test-flags:
description: "Flags to pass to cargo test commands."
required: false
default: ""

runs:
using: composite
Expand All @@ -16,8 +20,8 @@ runs:

- name: Run tests
shell: bash
run: cargo test ${{ inputs.feature-flags }} -p launchdarkly-server-sdk
run: cargo test ${{ inputs.cargo-flags }} ${{ inputs.cargo-test-flags }} -p launchdarkly-server-sdk

- name: Run clippy checks
shell: bash
run: cargo clippy ${{ inputs.feature-flags }} -p launchdarkly-server-sdk -- -D warnings
run: cargo clippy ${{ inputs.cargo-flags }} -p launchdarkly-server-sdk -- -D warnings
12 changes: 6 additions & 6 deletions .github/actions/contract-tests/action.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
name: Contract test runner
description: 'Reusable contract runner action'
description: "Reusable contract runner action"
inputs:
tls_feature:
description: 'Which TLS feature do you want to enable?'
cargo-flags:
description: "Flags to pass to cargo commands."
required: true
token:
description: 'GH Token used for retrieving SDK test harness.'
description: "GH Token used for retrieving SDK test harness."
required: true

runs:
using: composite
steps:
- name: Build contract tests
shell: bash
run: TLS_FEATURE="${{ inputs.tls_feature }}" make build-contract-tests
run: CARGO_FLAGS="${{ inputs.cargo-flags }}" make build-contract-tests

- name: Start contract test service
shell: bash
run: TLS_FEATURE="${{ inputs.tls_feature }}" make start-contract-test-service-bg
run: CARGO_FLAGS="${{ inputs.cargo-flags }}" make start-contract-test-service-bg

- uses: launchdarkly/gh-actions/actions/contract-tests@contract-tests-v1.0.2
with:
Expand Down
66 changes: 27 additions & 39 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,31 @@ jobs:
matrix:
features:
- name: "default"
flags: ""

- name: "no-features"
flags: "--no-default-features"
- name: "hyper"
flags: "--no-default-features --features hyper"
- name: "hyper-rustls"
flags: "--no-default-features --features hyper-rustls"
cargo-flags: "--no-default-features"
cargo-test-flags: "--lib"
skip_contract_tests: "true"

name: CI (${{ matrix.features.name }})
- name: "hyper"
cargo-flags: "--no-default-features --features hyper"
cargo-test-flags: "--lib"

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # If you only need the current version keep this.
- name: "hyper-rustls-native-roots"
cargo-flags: "--no-default-features --features hyper-rustls-native-roots"

- name: Get Rust version
id: rust-version
run: cat ./.github/variables/rust-versions.env >> $GITHUB_OUTPUT
- name: "hyper-rustls-webpki-roots"
cargo-flags: "--no-default-features --features hyper-rustls-webpki-roots"

- name: Setup rust tooling
run: |
rustup override set ${{ steps.rust-version.outputs.target }}
rustup component add rustfmt clippy
- name: "native-tls"
cargo-flags: "--no-default-features --features native-tls"

- uses: ./.github/actions/ci
with:
feature-flags: ${{ matrix.features.flags }}

contract-tests:
runs-on: ubuntu-latest
name: CI (${{ matrix.features.name }})

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-depth: 0 # If you only need the current version keep this.

- name: Get Rust version
id: rust-version
Expand All @@ -62,16 +52,15 @@ jobs:
rustup override set ${{ steps.rust-version.outputs.target }}
rustup component add rustfmt clippy

- name: "Run contract tests with hyper_rustls"
uses: ./.github/actions/contract-tests
- uses: ./.github/actions/ci
with:
tls_feature: "hyper-rustls"
token: ${{ secrets.GITHUB_TOKEN }}
cargo-flags: ${{ matrix.features.cargo-flags }}
cargo-test-flags: ${{ matrix.features.cargo-test-flags }}

- name: "Run contract tests with hyper_tls"
uses: ./.github/actions/contract-tests
- uses: ./.github/actions/contract-tests
if: ${{ matrix.features.skip_contract_tests != 'true' }}
with:
tls_feature: "tls"
cargo-flags: ${{ matrix.features.cargo-flags }}
token: ${{ secrets.GITHUB_TOKEN }}

build-docs:
Expand All @@ -83,15 +72,14 @@ jobs:
with:
fetch-depth: 0

- name: Get Rust version
id: rust-version
run: cat ./.github/variables/rust-versions.env >> $GITHUB_OUTPUT

- name: Setup rust tooling
run: |
rustup override set ${{ steps.rust-version.outputs.target }}
run: rustup override set nightly

- name: Install cargo-docs-rs
run: cargo install cargo-docs-rs

- uses: ./.github/actions/build-docs
- name: Build documentation
run: cargo docs-rs -p launchdarkly-server-sdk

musl-build:
runs-on: ubuntu-latest
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/manual-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ jobs:
rustup component add rustfmt clippy
- uses: ./.github/actions/ci
- uses: ./.github/actions/build-docs

- uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.2.0
name: "Get crates.io token"
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
TEMP_TEST_OUTPUT=/tmp/contract-test-service.log
TLS_FEATURE ?= hyper-rustls
CARGO_FLAGS ?= hyper-rustls-native-roots

build-contract-tests:
cargo build -p contract-tests --release --no-default-features --features "$(TLS_FEATURE)"
cargo build -p contract-tests --release $(CARGO_FLAGS)

start-contract-test-service: build-contract-tests
@./target/release/contract-tests

start-contract-test-service-bg:
@echo "Test service output will be captured in $(TEMP_TEST_OUTPUT)"
@make start-contract-test-service >$(TEMP_TEST_OUTPUT) 2>&1 &
@$(MAKE) start-contract-test-service >$(TEMP_TEST_OUTPUT) 2>&1 &

run-contract-tests:
@curl -s https://raw.githubusercontent.com/launchdarkly/sdk-test-harness/main/downloader/run.sh \
Expand Down
29 changes: 25 additions & 4 deletions contract-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,33 @@ serde = { version = "1.0.132", features = ["derive"] }
serde_json = "1.0.73"
futures = "0.3.12"
hyper-util = { version = "0.1", features = ["client-legacy", "http1", "http2", "tokio"] }
hyper-rustls = { version = "0.27", default-features = false, features = ["http1", "http2", "native-tokio", "ring", "webpki-roots"], optional = true }
hyper-rustls = { version = "0.27", default-features = false, features = ["http1", "http2", "ring"], optional = true }
hyper-tls = { version = "0.6.0", optional = true }
reqwest = { version = "0.12.4", features = ["default", "blocking", "json"] }
async-mutex = "1.4.0"

[features]
default = ["hyper-rustls"]
hyper-rustls = ["dep:hyper-rustls", "launchdarkly-server-sdk/hyper-rustls"]
tls = ["hyper-tls", "launchdarkly-server-sdk/hyper"]
default = ["hyper"]

hyper = [
"launchdarkly-sdk-transport/hyper",
"eventsource-client/hyper"
]
hyper-rustls-native-roots = [
"hyper",
"dep:hyper-rustls",
"launchdarkly-sdk-transport/hyper-rustls-native-roots",
"eventsource-client/hyper-rustls-native-roots"
]
hyper-rustls-webpki-roots = [
"hyper",
"dep:hyper-rustls",
"launchdarkly-sdk-transport/hyper-rustls-webpki-roots",
"eventsource-client/hyper-rustls-webpki-roots"
]
native-tls = [
"hyper",
"dep:hyper-tls",
"launchdarkly-sdk-transport/native-tls",
"eventsource-client/native-tls"
]
45 changes: 30 additions & 15 deletions contract-tests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,31 +207,31 @@ struct AppState {
https_connector: HttpsConnector,
}

#[cfg(feature = "hyper-rustls")]
#[cfg(any(
feature = "hyper-rustls-native-roots",
feature = "hyper-rustls-webpki-roots"
))]
type HttpsConnector =
hyper_rustls::HttpsConnector<hyper_util::client::legacy::connect::HttpConnector>;

#[cfg(feature = "tls")]
#[cfg(feature = "native-tls")]
type HttpsConnector = hyper_tls::HttpsConnector<hyper_util::client::legacy::connect::HttpConnector>;

#[cfg(not(any(
feature = "hyper-rustls-native-roots",
feature = "hyper-rustls-webpki-roots",
feature = "native-tls"
)))]
type HttpsConnector = hyper_util::client::legacy::connect::HttpConnector;

#[actix_web::main]

async fn main() -> std::io::Result<()> {
env_logger::init();

#[cfg(not(any(feature = "tls", feature = "hyper-rustls")))]
{
compile_error!("one of the { \"tls\", \"hyper-rustls\" } features must be enabled");
}
#[cfg(all(feature = "tls", feature = "hyper-rustls"))]
{
compile_error!(
"only one of the { \"tls\", \"hyper-rustls\" } features can be enabled at a time"
);
}

let (tx, rx) = mpsc::channel::<()>();

#[cfg(feature = "hyper-rustls")]
#[cfg(feature = "hyper-rustls-native-roots")]
let https_connector = hyper_rustls::HttpsConnectorBuilder::new()
.with_native_roots()
.expect("Failed to load native root certificates")
Expand All @@ -240,9 +240,24 @@ async fn main() -> std::io::Result<()> {
.enable_http2()
.build();

#[cfg(feature = "tls")]
#[cfg(feature = "hyper-rustls-webpki-roots")]
let https_connector = hyper_rustls::HttpsConnectorBuilder::new()
.with_webpki_roots()
.https_or_http()
.enable_http1()
.enable_http2()
.build();

#[cfg(feature = "native-tls")]
let https_connector = hyper_tls::HttpsConnector::new();

#[cfg(not(any(
feature = "hyper-rustls-native-roots",
feature = "hyper-rustls-webpki-roots",
feature = "native-tls"
)))]
let https_connector = hyper_util::client::legacy::connect::HttpConnector::new();

let state = web::Data::new(AppState {
counter: Mutex::new(0),
client_entities: Mutex::new(HashMap::new()),
Expand Down
29 changes: 24 additions & 5 deletions launchdarkly-server-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,34 @@ reqwest = { version = "0.12.4", features = ["json"] }
testing_logger = "0.1.1"

[features]
default = ["hyper-rustls"]
hyper = ["launchdarkly-sdk-transport/hyper", "eventsource-client/hyper"]
hyper-rustls = ["hyper", "launchdarkly-sdk-transport/hyper-rustls", "eventsource-client/hyper-rustls"]
default = ["hyper-rustls-native-roots"]

hyper = [
"launchdarkly-sdk-transport/hyper",
"eventsource-client/hyper"
]
hyper-rustls-native-roots = [
"hyper",
"launchdarkly-sdk-transport/hyper-rustls-native-roots",
"eventsource-client/hyper-rustls-native-roots"
]
hyper-rustls-webpki-roots = [
"hyper",
"launchdarkly-sdk-transport/hyper-rustls-webpki-roots",
"eventsource-client/hyper-rustls-webpki-roots"
]
native-tls = [
"hyper",
"launchdarkly-sdk-transport/native-tls",
"eventsource-client/native-tls"
]

event-compression = ["flate2"]

[[example]]
name = "print_flags"
required-features = ["hyper-rustls"]
required-features = ["hyper-rustls-native-roots"]

[[example]]
name = "progress"
required-features = ["hyper-rustls"]
required-features = ["hyper-rustls-native-roots"]
Loading