Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add all apple platforms and bump versions #41

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
79 changes: 77 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
on: [pull_request]
on: [pull_request, push]

name: if-watch

Expand All @@ -15,7 +15,7 @@ jobs:
host: ubuntu-latest
cross: false

- target: x86_64-apple-darwin
- target: aarch64-apple-darwin
host: macos-latest
cross: false

Expand Down Expand Up @@ -107,3 +107,78 @@ jobs:

- name: cargo clippy
run: cargo clippy --workspace --all-features --examples --tests -- -D warnings

apple-platforms:
name: Test on ${{ matrix.name }}
strategy:
fail-fast: false
matrix:
include:
- name: ios
target: aarch64-apple-ios-sim
platform: auto-ios-aarch64-sim
unstable: false
deviceType: iPhone-15-Pro-Max
deviceName: my-iphone-15-pro-max
- name: tvOS
target: aarch64-apple-tvos-sim
platform: auto-tvos-aarch64-sim
unstable: true
deviceType: Apple-TV-4K-3rd-generation-4K
deviceName: my-4ktv
- name: watchOS
target: aarch64-apple-watchos-sim
platform: auto-watchos-aarch64-sim
unstable: true
deviceType: Apple-Watch-Ultra-2-49mm
deviceName: my-apple-watch
- name: visionOS
target: aarch64-apple-visionos-sim
platform: auto-visionos-aarch64-sim
unstable: true
deviceType: Apple-Vision-Pro
deviceName: my-apple-vision-pro
runs-on: macos-latest
env:
NAME: ${{ matrix.name }}
PLATFORM: ${{ matrix.platform }}
DEVICE_TYPE: ${{ matrix.deviceType }}
DEVICE_NAME: ${{ matrix.deviceName }}
BUILD_STD: ${{ matrix.unstable && '-Z build-std' || '' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: dtolnay/rust-toolchain@stable
if: ${{ !matrix.unstable }}
with:
targets: ${{ matrix.target }}

- uses: dtolnay/rust-toolchain@master
if: ${{ matrix.unstable }}
with:
toolchain: nightly
components: rust-src

- name: Check if compiles on ${{ matrix.name }}
run: cargo check --all-features --target=${{ matrix.target }} $BUILD_STD --tests

- name: Install cargo dinghy
uses: taiki-e/cache-cargo-install-action@v2
with:
tool: cargo-dinghy

- name: Start ${{ matrix.name }} simulator
id: boot-simulator
run: |
RUNTIME_ID=$(xcrun simctl list runtimes | grep $NAME | cut -d ' ' -f 7 | tail -1)
export SIM_ID=$(xcrun simctl create $DEVICE_NAME com.apple.CoreSimulator.SimDeviceType.$DEVICE_TYPE $RUNTIME_ID)
xcrun simctl boot $SIM_ID
echo "sim-id=$SIM_ID" >> $GITHUB_OUTPUT

- name: Run all tests
env:
SIM_ID: ${{ steps.boot-simulator.outputs.sim-id }}
run: cargo dinghy -d $SIM_ID -p $PLATFORM test --all-features $BUILD_STD

22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "if-watch"
version = "3.2.0"
version = "3.3.0"
authors = ["David Craven <[email protected]>", "Parity Technologies Limited <[email protected]>"]
edition = "2021"
keywords = ["asynchronous", "routing"]
Expand All @@ -22,26 +22,26 @@ ipnet = "2.3.1"
log = "0.4.14"

[target.'cfg(target_os = "linux")'.dependencies]
rtnetlink = { version = "0.10.0", default-features = false }
rtnetlink = { version = "0.14.1", default-features = false }

[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
[target.'cfg(all(target_vendor = "apple", any(target_os = "macos", target_os = "ios", target_os = "visionos", target_os = "watchos", target_os = "tvos")))'.dependencies]
core-foundation = "0.9.2"
if-addrs = "0.10.0"
system-configuration = "0.5.0"
if-addrs = "0.13.1"
system-configuration = "0.6.0"
tokio = { version = "1.21.2", features = ["rt"], optional = true }
smol = { version = "1.2.5", optional = true }
smol = { version = "2.0.0", optional = true }

[target.'cfg(target_os = "windows")'.dependencies]
if-addrs = "0.10.0"
windows = { version = "0.51.0", features = ["Win32_NetworkManagement_IpHelper", "Win32_Foundation", "Win32_NetworkManagement_Ndis", "Win32_Networking_WinSock"] }
if-addrs = "0.13.1"
windows = { version = "0.58.0", features = ["Win32_NetworkManagement_IpHelper", "Win32_Foundation", "Win32_NetworkManagement_Ndis", "Win32_Networking_WinSock"] }

[target.'cfg(not(any(target_os = "ios", target_os = "linux", target_os = "macos", target_os = "windows")))'.dependencies]
async-io = "2.0.0"
if-addrs = "0.10.0"
if-addrs = "0.13.1"

[dev-dependencies]
env_logger = "0.10.0"
smol = "1.2.5"
env_logger = "0.11.5"
smol = "2.0.0"
tokio = { version = "1.21.2", features = ["rt", "macros"] }

[[example]]
Expand Down
59 changes: 50 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@

pub use ipnet::{IpNet, Ipv4Net, Ipv6Net};

#[cfg(target_os = "macos")]
mod apple;
#[cfg(target_os = "ios")]
#[cfg(all(
target_vendor = "apple",
any(
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "watchos",
target_os = "visionos"
),
))]
mod apple;
#[cfg(not(any(
target_os = "ios",
Expand All @@ -20,28 +27,62 @@ mod linux;
#[cfg(target_os = "windows")]
mod win;

#[cfg(any(target_os = "macos", target_os = "ios"))]
#[cfg(all(
target_vendor = "apple",
any(
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "watchos",
target_os = "visionos"
),
))]
#[cfg(feature = "tokio")]
pub use apple::tokio;

#[cfg(any(target_os = "macos", target_os = "ios"))]
#[cfg(all(
target_vendor = "apple",
any(
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "watchos",
target_os = "visionos"
),
))]
#[cfg(feature = "smol")]
pub use apple::smol;

#[cfg(feature = "smol")]
#[cfg(not(any(
target_os = "ios",
all(
target_vendor = "apple",
any(
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "watchos",
target_os = "visionos"
),
),
target_os = "linux",
target_os = "macos",
target_os = "windows",
)))]
pub use fallback::smol;

#[cfg(feature = "tokio")]
#[cfg(not(any(
target_os = "ios",
all(
target_vendor = "apple",
any(
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "watchos",
target_os = "visionos"
),
),
target_os = "linux",
target_os = "macos",
target_os = "windows",
)))]
pub use fallback::tokio;
Expand Down