Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try out fopro? #8153

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
66 changes: 66 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,27 @@ jobs:
with:
tool: cargo-nextest

- name: Cache .fopro-cache
uses: actions/cache@v4
with:
path: .fopro-cache
key: ${{ runner.os }}-fopro-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-fopro-

- name: Install and launch fopro
run: |
curl -sL https://github.com/bearcove/fopro/releases/download/v2.0.3/fopro-installer.sh | bash
RUST_LOG=warn ~/.cargo/bin/fopro &
echo "UV_ALL_PROXY=localhost:8080" >> $GITHUB_ENV
echo "UV_CA_CERT=/tmp/fopro-ca.crt" >> $GITHUB_ENV

- name: "Download deps"
run: |
cargo nextest list \
--features python-patch \
--workspace

- name: "Cargo test"
run: |
cargo nextest run \
Expand Down Expand Up @@ -239,6 +260,27 @@ jobs:
with:
tool: cargo-nextest

- name: Cache .fopro-cache
uses: actions/cache@v4
with:
path: .fopro-cache
key: ${{ runner.os }}-fopro-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-fopro-

- name: Install and launch fopro
run: |
curl -sL https://github.com/bearcove/fopro/releases/download/v2.0.3/fopro-installer.sh | bash
RUST_LOG=warn ~/.cargo/bin/fopro &
echo "UV_ALL_PROXY=localhost:8080" >> $GITHUB_ENV
echo "UV_CA_CERT=/tmp/fopro-ca.crt" >> $GITHUB_ENV

- name: "Download deps"
run: |
cargo nextest list \
--features python-patch \
--workspace

- name: "Cargo test"
run: |
cargo nextest run \
Expand Down Expand Up @@ -295,9 +337,33 @@ jobs:
with:
tool: cargo-nextest

- name: Cache .fopro-cache
uses: actions/cache@v4
with:
path: .fopro-cache
key: ${{ runner.os }}-fopro-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-fopro-

- name: Install and launch fopro
run: |
Invoke-WebRequest -Uri https://github.com/bearcove/fopro/releases/download/v2.0.3/fopro-installer.ps1 -OutFile fopro-installer.ps1
.\fopro-installer.ps1
echo "UV_ALL_PROXY=127.0.0.1:8080" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "UV_CA_CERT=$env:TEMP\fopro-ca.crt" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

- name: "Download deps"
working-directory: ${{ env.UV_WORKSPACE }}
run: |
cargo nextest list --no-default-features --features python,pypi --workspace

- name: "Cargo test"
working-directory: ${{ env.UV_WORKSPACE }}
run: |
$env:RUST_LOG = "warn"
Start-Process -FilePath "${{ env.DEV_DRIVE }}\.cargo\bin\fopro.exe" -NoNewWindow
$env:RUST_LOG = $null
Test-NetConnection -ComputerName 127.0.0.1 -Port 8080
cargo nextest run --no-default-features --features python,pypi --workspace --status-level skip --failure-output immediate-final --no-fail-fast -j 20 --final-status-level slow

- name: "Smoke test"
Expand Down
19 changes: 17 additions & 2 deletions crates/uv-client/src/base_client.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use itertools::Itertools;
use reqwest::{Client, ClientBuilder, Response};
use reqwest::{Client, ClientBuilder, Proxy, Response};
use reqwest_middleware::ClientWithMiddleware;
use reqwest_retry::policies::ExponentialBackoff;
use reqwest_retry::{
Expand Down Expand Up @@ -248,11 +248,26 @@ impl<'a> BaseClientBuilder<'a> {
.tls_built_in_root_certs(false);

// If necessary, accept invalid certificates.
let client_builder = match security {
let mut client_builder = match security {
Security::Secure => client_builder,
Security::Insecure => client_builder.danger_accept_invalid_certs(true),
};

if let Ok(proxy) = std::env::var("UV_ALL_PROXY") {
tracing::debug!("UV_ALL_PROXY set, using proxy: {}", proxy);
client_builder =
client_builder.proxy(Proxy::all(&proxy).expect("Failed to create proxy"));
}

if let Ok(ca_cert) = std::env::var("UV_CA_CERT") {
// read it in PEM format
let ca_cert = fs_err::read(&ca_cert).expect("Failed to read UV_CA_CERT path");
let cert =
reqwest::Certificate::from_pem(&ca_cert).expect("Failed to parse UV_CA_CERT");
tracing::debug!("UV_CA_CERT set, using CA certificate");
client_builder = client_builder.add_root_certificate(cert);
}

let client_builder = if self.native_tls || ssl_cert_file_exists {
client_builder.tls_built_in_native_certs(true)
} else {
Expand Down
Loading