Skip to content
Open
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
52 changes: 52 additions & 0 deletions .github/workflows/build_windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Rust CI on Windows

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -Ctarget-feature=+crt-static

jobs:
build:
runs-on: windows-2022
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Cache Cargo registry and build artifacts
uses: actions/cache@v4
with:
path: |
C:\Users\runneradmin\.cargo\registry
C:\Users\runneradmin\.cargo\git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

- name: Set up Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Build
run: cargo build --verbose

- name: Run tests
run: cargo test --verbose

- name: Build examples (Windows)
shell: pwsh
run: |
Get-ChildItem examples\*.rs | ForEach-Object {
$name = $_.BaseName
Write-Host "Building example: $name"
cargo build --example $name --verbose
}

22 changes: 16 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] } # For
tempfile = "3" # For creating temporary directories in examples/tests
anyhow = "1.0" # For simple error handling in examples
futures = "0.3" # For simulataneous_git_clone example
windows-sys = { version = "0.59.0", features = ["Win32", "Win32_System", "Win32_System_Threading", "Win32_Foundation"] }
# Dependency on the library itself (needed for building examples within the workspace)
# This line might not be strictly necessary if cargo automatically detects it,
# but explicitly listing it can sometimes help.
Expand Down
9 changes: 5 additions & 4 deletions examples/git_clone_kernel.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// examples/git_clone_kernel.rs

use command_timeout::{run_command_with_timeout, CommandError, CommandOutput};
#[cfg(unix)]
use std::os::unix::process::ExitStatusExt;
use command_timeout::{run_command_with_timeout, CommandError, CommandOutput};
use std::path::PathBuf; // <<< Import PathBuf
use std::process::{Command, ExitStatus};
use std::time::Duration;
Expand Down Expand Up @@ -34,11 +34,11 @@ async fn main() -> Result<(), anyhow::Error> {
let min_timeout = Duration::from_secs(10);
let max_timeout = Duration::from_secs(60 * 60 * 24 * 7); // 1 week (effectively infinite)
let activity_timeout = Duration::from_secs(60 * 5); // 5 minutes
// -----------------------------
// -----------------------------

// Create a temporary directory builder
let temp_dir_builder = Builder::new().prefix("kernel_clone_persistent").tempdir()?; // Use a different prefix
// --- CHANGE: Keep the path instead of the TempDir object ---
// --- CHANGE: Keep the path instead of the TempDir object ---
let clone_target_path_buf: PathBuf = temp_dir_builder.into_path();
// --- END CHANGE ---
let clone_target_path_str = clone_target_path_buf.to_str().unwrap_or("."); // Use "." as fallback if path invalid unicode
Expand Down Expand Up @@ -122,6 +122,7 @@ fn handle_command_output(output: CommandOutput) {
warn!("Exit Code: {}", code);
}
// signal() is now available because ExitStatusExt is in scope
#[cfg(unix)]
if let Some(signal) = status.signal() {
warn!("Terminated by Signal: {}", signal);
}
Expand Down
2 changes: 2 additions & 0 deletions examples/simultaneous_git_clone.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use anyhow::{Context, Result};
use command_timeout::{run_command_with_timeout, CommandError, CommandOutput};
use std::collections::HashMap;
#[cfg(unix)]
use std::os::unix::process::ExitStatusExt;
use std::path::{Path, PathBuf};
use std::process::Command;
Expand Down Expand Up @@ -190,6 +191,7 @@ fn handle_command_output(output: CommandOutput, repo_url: &str, target_path: &Pa
warn!("Exit Code: {}", code);
}
// signal() is now available because ExitStatusExt is in scope
#[cfg(unix)]
if let Some(signal) = status.signal() {
warn!("Terminated by Signal: {}", signal);
}
Expand Down
Loading
Loading