From fb966e02a35645cbf2b63252ce4876fd89fee45b Mon Sep 17 00:00:00 2001 From: Taylor Thomas Date: Wed, 13 May 2020 16:06:15 -0600 Subject: [PATCH 1/2] feat(runtime): Adds conditional compilation for windows This adds conditional compilation for the SIGINT interrupts. Due to the macro, this is mostly a copy/paste job with one version for windows --- kube/src/runtime/reflector.rs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/kube/src/runtime/reflector.rs b/kube/src/runtime/reflector.rs index a76b92585..c4e3ee254 100644 --- a/kube/src/runtime/reflector.rs +++ b/kube/src/runtime/reflector.rs @@ -4,10 +4,13 @@ use crate::{ }; use futures::{future::FutureExt, lock::Mutex, pin_mut, select, TryStreamExt}; use serde::de::DeserializeOwned; -use tokio::{ - signal::{self, ctrl_c}, - time::delay_for, -}; +use tokio::{signal::ctrl_c, time::delay_for}; + +#[cfg(not(target_family = "windows"))] +use tokio::signal; + +#[cfg(target_family = "windows")] +use tokio::sync::mpsc::{channel, Receiver}; use std::{collections::BTreeMap, sync::Arc, time::Duration}; @@ -59,10 +62,18 @@ where // local development needs listening for ctrl_c let ctrlc_fut = ctrl_c().fuse(); // kubernetes apps need to listen for SIGTERM (30s warning) - use signal::unix::{signal, SignalKind}; // TODO: conditional compile + #[cfg(not(target_family = "windows"))] + use signal::unix::{signal, SignalKind}; + #[cfg(not(target_family = "windows"))] let mut sigterm = signal(SignalKind::terminate()).unwrap(); + #[cfg(not(target_family = "windows"))] let sigterm_fut = sigterm.recv().fuse(); + #[cfg(target_family = "windows")] + let (_tx, mut rx): (_, Receiver<()>) = channel(1); + #[cfg(target_family = "windows")] + let sigterm_fut = rx.recv().fuse(); + // and reflector needs to poll continuously let poll_fut = self.poll().fuse(); From a2e030d4400a13982db581aaac21db01ab45f887 Mon Sep 17 00:00:00 2001 From: Taylor Thomas Date: Thu, 14 May 2020 12:03:07 -0600 Subject: [PATCH 2/2] Attempts to add windows build --- .circleci/config.yml | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 61c38f772..fb8088b0d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,10 +1,14 @@ version: 2.1 +orbs: + win: circleci/windows@2.4.0 + workflows: version: 2 all_jobs: jobs: - cargo_test + - windows_test jobs: cargo_test: @@ -18,7 +22,7 @@ jobs: - run: grep "\[dependencies\]" -A 9000 kube/Cargo.toml > deps_checksum - restore_cache: keys: - - cache-{{ checksum "deps_checksum" }} + - cache-{{ checksum "deps_checksum" }} - run: cargo build - run: cargo test --lib - run: cargo test --example crd_api crd_reflector @@ -31,3 +35,35 @@ jobs: - target/debug/build - target/debug/deps key: cache-{{ checksum "deps_checksum" }} + windows_test: + environment: + - CARGO_INCREMENTAL: 0 + - CARGO_BUILD_TARGET: "x86_64-pc-windows-msvc" + executor: + name: win/default + shell: bash.exe + steps: + - checkout + - run: + name: "HACK: remove gitconfig to prevent ssh fetches from cargo" + command: rm ~/.gitconfig + - run: curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable --target $CARGO_BUILD_TARGET + - run: echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> $BASH_ENV + - run: grep "\[dependencies\]" -A 9000 kube/Cargo.toml > deps_checksum + - restore_cache: + keys: + - cache-{{ checksum "deps_checksum" }} + # To avoid openssl dependencies on windows, we need to set the rustls-tls feature, which + # requires being at the crate level rather than the workspace level + - run: cd kube && cargo test --example crd_api crd_reflector --no-default-features --features=rustls-tls + - run: cd kube-derive && cargo test -j4 + - run: cd kube && cargo test -j4 --no-default-features --features=rustls-tls + - run: cd kube-derive && cargo test --lib + - run: cd kube && cargo test --lib --no-default-features --features=rustls-tls + - save_cache: + paths: + - "$HOME/.cargo/registry" + - target/debug/.fingerprint + - target/debug/build + - target/debug/deps + key: cache-{{ checksum "deps_checksum" }}