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
49 changes: 49 additions & 0 deletions .github/workflows/build_mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Rust CI on Mac

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

env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4

- name: Cache Cargo registry and build artifacts
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.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
run: |
for example in $(ls examples/*.rs); do
name=$(basename "$example" .rs)
echo "Building example: $name"
cargo build --example "$name" --verbose
done

6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -948,10 +948,16 @@ mod tests {
result.duration > Duration::from_secs(2),
"Duration should be > 2s"
); // 20 * 0.1s
#[cfg(not(target_os = "macos"))]
assert!(
result.duration < Duration::from_secs(3),
"Duration should be < 3s"
);
#[cfg(target_os = "macos")]
assert!(
result.duration < Duration::from_secs(4),
"Duration should be < 4s"
); // macOS has longer sleep resolution
});
}

Expand Down
Loading