Skip to content

Commit 58ae672

Browse files
committed
Implemented Github Actions and added Windows and Mac Compatibility
1 parent 1f2602f commit 58ae672

File tree

8 files changed

+252
-37
lines changed

8 files changed

+252
-37
lines changed

.github/workflows/build_linux.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Rust CI on Linux
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
workflow_dispatch:
9+
10+
env:
11+
CARGO_TERM_COLOR: always
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Cache Cargo registry and build artifacts
20+
uses: actions/cache@v4
21+
with:
22+
path: |
23+
~/.cargo/registry
24+
~/.cargo/git
25+
target
26+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
27+
restore-keys: |
28+
${{ runner.os }}-cargo-
29+
30+
- name: Set up Rust toolchain
31+
uses: actions-rs/toolchain@v1
32+
with:
33+
toolchain: stable
34+
override: true
35+
36+
- name: Build
37+
run: cargo build --verbose
38+
39+
- name: Run tests
40+
run: cargo test --verbose

.github/workflows/build_mac.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Rust CI on Mac
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
workflow_dispatch:
9+
10+
env:
11+
CARGO_TERM_COLOR: always
12+
13+
jobs:
14+
build:
15+
runs-on: macos-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Cache Cargo registry and build artifacts
20+
uses: actions/cache@v4
21+
with:
22+
path: |
23+
~/.cargo/registry
24+
~/.cargo/git
25+
target
26+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
27+
restore-keys: |
28+
${{ runner.os }}-cargo-
29+
30+
- name: Set up Rust toolchain
31+
uses: actions-rs/toolchain@v1
32+
with:
33+
toolchain: stable
34+
override: true
35+
36+
- name: Build
37+
run: cargo build --verbose
38+
39+
- name: Run tests
40+
run: cargo test --verbose
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Rust CI on Windows
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
workflow_dispatch:
9+
10+
env:
11+
CARGO_TERM_COLOR: always
12+
RUSTFLAGS: -Ctarget-feature=+crt-static
13+
14+
jobs:
15+
build:
16+
runs-on: windows-2022
17+
steps:
18+
- name: Check out repository
19+
uses: actions/checkout@v4
20+
21+
- name: Cache Cargo registry and build artifacts
22+
uses: actions/cache@v4
23+
with:
24+
path: |
25+
C:\Users\runneradmin\.cargo\registry
26+
C:\Users\runneradmin\.cargo\git
27+
target
28+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
29+
restore-keys: |
30+
${{ runner.os }}-cargo-
31+
32+
- name: Set up Rust toolchain
33+
uses: actions-rs/toolchain@v1
34+
with:
35+
toolchain: stable
36+
override: true
37+
38+
- name: Build
39+
run: cargo build --verbose
40+
41+
- name: Run tests
42+
run: cargo test --verbose

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Generated by cargo init
22

33
/target/
4-
4+
/.idea/

Cargo.lock

Lines changed: 16 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ libc = "0.2" # For setpgid and signal constants
2222
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] } # For logging setup
2323
tempfile = "3" # For creating temporary directories in examples/tests
2424
anyhow = "1.0" # For simple error handling in examples
25-
25+
windows-sys = { version = "0.59.0", features = ["Win32", "Win32_System", "Win32_System_Threading", "Win32_Foundation"] }
2626
# Dependency on the library itself (needed for building examples within the workspace)
2727
# This line might not be strictly necessary if cargo automatically detects it,
2828
# but explicitly listing it can sometimes help.

examples/git_clone_kernel.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// examples/git_clone_kernel.rs
2-
3-
use command_timeout::{run_command_with_timeout, CommandError, CommandOutput};
2+
#[cfg(unix)]
43
use std::os::unix::process::ExitStatusExt;
4+
#[cfg(windows)]
5+
use std::os::windows::process::ExitStatusExt;
6+
use command_timeout::{run_command_with_timeout, CommandError, CommandOutput};
57
use std::path::PathBuf; // <<< Import PathBuf
68
use std::process::{Command, ExitStatus};
79
use std::time::Duration;
@@ -34,11 +36,11 @@ async fn main() -> Result<(), anyhow::Error> {
3436
let min_timeout = Duration::from_secs(10);
3537
let max_timeout = Duration::from_secs(60 * 60 * 24 * 7); // 1 week (effectively infinite)
3638
let activity_timeout = Duration::from_secs(60 * 5); // 5 minutes
37-
// -----------------------------
39+
// -----------------------------
3840

3941
// Create a temporary directory builder
4042
let temp_dir_builder = Builder::new().prefix("kernel_clone_persistent").tempdir()?; // Use a different prefix
41-
// --- CHANGE: Keep the path instead of the TempDir object ---
43+
// --- CHANGE: Keep the path instead of the TempDir object ---
4244
let clone_target_path_buf: PathBuf = temp_dir_builder.into_path();
4345
// --- END CHANGE ---
4446
let clone_target_path_str = clone_target_path_buf.to_str().unwrap_or("."); // Use "." as fallback if path invalid unicode
@@ -122,9 +124,14 @@ fn handle_command_output(output: CommandOutput) {
122124
warn!("Exit Code: {}", code);
123125
}
124126
// signal() is now available because ExitStatusExt is in scope
127+
#[cfg(unix)]
125128
if let Some(signal) = status.signal() {
126129
warn!("Terminated by Signal: {}", signal);
127130
}
131+
#[cfg(windows)]
132+
if let Some(code) = status.code() {
133+
warn!("Exit Code: {}", code);
134+
}
128135
}
129136
} else {
130137
warn!("Exit Status: None (Killed by timeout, status unavailable?)");

0 commit comments

Comments
 (0)