Simplify testing and linting strategies for CI; remove launched segment of ssh tests (will test another way)

pull/191/head
Chip Senkbeil 1 year ago
parent be9b952164
commit 55ca9ba3d2
No known key found for this signature in database
GPG Key ID: 35EF1F8EC72A4131

@ -40,16 +40,8 @@ jobs:
- uses: Swatinem/rust-cache@v2
- name: Check Cargo availability
run: cargo --version
- name: distant-auth (all features)
run: cargo clippy -p distant-auth --all-targets --verbose --all-features
- name: distant-net (all features)
run: cargo clippy -p distant-net --all-targets --verbose --all-features
- name: distant-core (all features)
run: cargo clippy -p distant-core --all-targets --verbose --all-features
- name: distant-ssh2 (all features)
run: cargo clippy -p distant-ssh2 --all-targets --verbose --all-features
- name: distant (all features)
run: cargo clippy --all-targets --verbose --all-features
- name: Run clippy (all features_
run: cargo clippy --workspace --all-targets --verbose --all-features
rustfmt:
name: "Verify code formatting (${{ matrix.os }})"
runs-on: ${{ matrix.os }}
@ -157,58 +149,11 @@ jobs:
New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType String -Force
}
- name: Extend Windows retry count to be more resilient
if: matrix.os == 'windows-latest'
run: echo "NEXTEST_RETRIES=9" >> $GITHUB_ENV
shell: bash
- name: Run auth tests (all features)
run: cargo nextest run --profile ci --release --all-features -p distant-auth
- name: Run net tests (default features)
run: cargo nextest run --profile ci --release -p distant-net
- name: Build core (default features)
run: cargo build --release -p distant-core
- name: Run core tests (all features)
run: cargo nextest run --profile ci --release --all-features -p distant-core
if: matrix.os == 'windows-latest'
- name: Ensure /run/sshd exists on Unix
run: mkdir -p /run/sshd
if: matrix.os == 'ubuntu-latest'
- name: Build ssh2 (default features)
run: cargo build --release -p distant-ssh2
- name: Run ssh2 client tests (all features)
run: cargo nextest run --profile ci --release --all-features -p distant-ssh2 ssh2::client
- name: Build CLI (no default features)
run: cargo build --release --no-default-features
- name: Build CLI (default features)
run: cargo build --release
- name: Run CLI tests (all features)
run: cargo nextest run --profile ci --release --all-features
ssh-launch-tests:
name: "Test ssh launch using Rust ${{ matrix.rust }} on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
env:
RUSTFLAGS: --cfg ci
RUST_LOG: trace
strategy:
fail-fast: false
matrix:
include:
- { rust: stable, os: macos-latest }
- { rust: stable, os: ubuntu-latest }
steps:
- uses: actions/checkout@v3
- name: Install Rust ${{ matrix.rust }}
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
- uses: taiki-e/install-action@v1
with:
tool: cargo-nextest@0.9.45
- uses: Swatinem/rust-cache@v2
- name: Check Cargo availability
run: cargo --version
- name: Install distant cli for use in launch tests
run: |
cargo install --path .
echo "DISTANT_PATH=$HOME/.cargo/bin/distant" >> $GITHUB_ENV
- name: Run ssh2 launch tests (all features)
run: cargo nextest run --profile ci --release --all-features -p distant-ssh2 ssh2::launched
- name: Run all workspace tests (all features)
run: cargo nextest run --profile ci --release --all-features --workspace

File diff suppressed because it is too large Load Diff

@ -1,3 +1,2 @@
mod client;
mod launched;
mod ssh;

@ -15,7 +15,7 @@ use assert_fs::TempDir;
use async_trait::async_trait;
use derive_more::{Deref, DerefMut, Display};
use distant_core::DistantClient;
use distant_ssh2::{DistantLaunchOpts, Ssh, SshAuthEvent, SshAuthHandler, SshOpts};
use distant_ssh2::{Ssh, SshAuthEvent, SshAuthHandler, SshOpts};
use log::*;
use once_cell::sync::Lazy;
use rstest::*;
@ -638,38 +638,6 @@ pub async fn client(sshd: Sshd) -> Ctx<DistantClient> {
}
}
/// Fixture to establish a client to a launched server
#[fixture]
pub async fn launched_client(sshd: Sshd) -> Ctx<DistantClient> {
let binary = std::env::var("DISTANT_PATH").unwrap_or_else(|_| String::from("distant"));
debug!("Setting path to distant binary as {binary}");
// Attempt to launch the server and connect to it, using $DISTANT_PATH as the path to the
// binary if provided, defaulting to assuming the binary is on our ssh path otherwise
//
// NOTE: Wrapping in ctx does not fully clean up the test as the launched distant server
// is not cleaned up during drop. We don't know what the server's pid is, so our
// only option would be to look up all running distant servers and kill them on drop,
// but that would cause other tests to fail.
//
// Setting an expiration of 1s would clean up running servers and possibly be good enough
let ssh_client = load_ssh_client(&sshd).await;
let mut client = ssh_client
.launch_and_connect(DistantLaunchOpts {
binary,
args: "--shutdown lonely=10".to_string(),
..Default::default()
})
.await
.context("Failed to launch and connect to distant server")
.unwrap();
client.shutdown_on_drop(true);
Ctx {
sshd,
value: client,
}
}
/// Access to raw [`Ssh`] client
#[fixture]
pub async fn ssh(sshd: Sshd) -> Ctx<Ssh> {

Loading…
Cancel
Save