diff --git a/.github/workflows/build_mac.yml b/.github/workflows/build_mac.yml new file mode 100644 index 0000000..cd4ab91 --- /dev/null +++ b/.github/workflows/build_mac.yml @@ -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 + diff --git a/src/lib.rs b/src/lib.rs index 566ad6c..ef2fc34 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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 }); }