From 938820484c4710faceb3523d40084d20f621caf2 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Mon, 25 May 2020 10:40:49 +0900 Subject: [PATCH] Enable tests on Windows on CI --- .github/workflows/ci.yml | 45 ++++++++++++++++- bors.toml | 19 +------ ci/crossbeam-epoch.sh | 16 +++--- crossbeam-channel/examples/stopwatch.rs | 66 ++++++++++++++----------- 4 files changed, 90 insertions(+), 56 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c91411875..925c08a28 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,13 +7,21 @@ on: - staging - trying +env: + RUSTFLAGS: -Dwarnings + RUST_BACKTRACE: 1 + +defaults: + run: + shell: bash + jobs: # Test crates on their minimum Rust versions and nightly Rust. test: name: test - runs-on: ubuntu-latest env: RUST_VERSION: ${{ matrix.rust }} + OS: ${{ matrix.os }} strategy: matrix: crates: @@ -27,6 +35,12 @@ jobs: rust: - 1.36.0 - nightly + os: + - ubuntu-latest + include: + - os: windows-latest + rust: nightly + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@master - name: Install Rust @@ -60,3 +74,32 @@ jobs: run: rustup update stable && rustup default stable - name: rustfmt run: ./ci/rustfmt.sh + + # These jobs don't actually test anything, but they're used to tell bors the + # build completed, as there is no practical way to detect when a workflow is + # successful listening to webhooks only. + # + # ALL THE PREVIOUS JOBS NEEDS TO BE ADDED TO THE `needs` SECTION OF THIS JOB! + + ci-success: + name: ci + if: github.event_name == 'push' && success() + needs: + - test + - dependencies + - rustfmt + runs-on: ubuntu-latest + steps: + - name: Mark the job as a success + run: exit 0 + ci-failure: + name: ci + if: github.event_name == 'push' && !success() + needs: + - test + - dependencies + - rustfmt + runs-on: ubuntu-latest + steps: + - name: Mark the job as a failure + run: exit 1 diff --git a/bors.toml b/bors.toml index 21bb0c31f..0b9053503 100644 --- a/bors.toml +++ b/bors.toml @@ -1,18 +1 @@ -status = [ - "test (crossbeam, 1.36.0)", - "test (crossbeam, nightly)", - "test (crossbeam-channel, 1.36.0)", - "test (crossbeam-channel, nightly)", - "test (crossbeam-deque, 1.36.0)", - "test (crossbeam-deque, nightly)", - "test (crossbeam-epoch, 1.36.0)", - "test (crossbeam-epoch, nightly)", - "test (crossbeam-queue, 1.36.0)", - "test (crossbeam-queue, nightly)", - "test (crossbeam-skiplist, 1.36.0)", - "test (crossbeam-skiplist, nightly)", - "test (crossbeam-utils, 1.36.0)", - "test (crossbeam-utils, nightly)", - "dependencies", - "rustfmt", -] +status = ["ci"] diff --git a/ci/crossbeam-epoch.sh b/ci/crossbeam-epoch.sh index 789aa9096..076762f8e 100755 --- a/ci/crossbeam-epoch.sh +++ b/ci/crossbeam-epoch.sh @@ -13,13 +13,15 @@ if [[ "$RUST_VERSION" == "nightly" ]]; then cargo check --no-default-features --features nightly cargo test --features nightly - ASAN_OPTIONS="detect_odr_violation=0 detect_leaks=0" \ - RUSTFLAGS="-Z sanitizer=address" \ - cargo run \ - --release \ - --target x86_64-unknown-linux-gnu \ - --features sanitize,nightly \ - --example sanitize + if [[ "$OS" == "linux" ]]; then + ASAN_OPTIONS="detect_odr_violation=0 detect_leaks=0" \ + RUSTFLAGS="-Z sanitizer=address" \ + cargo run \ + --release \ + --target x86_64-unknown-linux-gnu \ + --features sanitize,nightly \ + --example sanitize + fi # Check for no_std environment. cargo check --target thumbv7m-none-eabi --no-default-features diff --git a/crossbeam-channel/examples/stopwatch.rs b/crossbeam-channel/examples/stopwatch.rs index 79957c4fe..b4e34ea2f 100644 --- a/crossbeam-channel/examples/stopwatch.rs +++ b/crossbeam-channel/examples/stopwatch.rs @@ -1,39 +1,40 @@ //! Prints the elapsed time every 1 second and quits on Ctrl+C. -use std::io; -use std::thread; -use std::time::{Duration, Instant}; - -use crossbeam_channel::{bounded, select, tick, Receiver}; -use signal_hook::iterator::Signals; -use signal_hook::SIGINT; - -// Creates a channel that gets a message every time `SIGINT` is signalled. -fn sigint_notifier() -> io::Result> { - let (s, r) = bounded(100); - let signals = Signals::new(&[SIGINT])?; - - thread::spawn(move || { - for _ in signals.forever() { - if s.send(()).is_err() { - break; +#[cfg(not(windows))] // signal_hook::iterator does not work on windows +fn main() { + use std::io; + use std::thread; + use std::time::{Duration, Instant}; + + use crossbeam_channel::{bounded, select, tick, Receiver}; + use signal_hook::iterator::Signals; + use signal_hook::SIGINT; + + // Creates a channel that gets a message every time `SIGINT` is signalled. + fn sigint_notifier() -> io::Result> { + let (s, r) = bounded(100); + let signals = Signals::new(&[SIGINT])?; + + thread::spawn(move || { + for _ in signals.forever() { + if s.send(()).is_err() { + break; + } } - } - }); + }); - Ok(r) -} + Ok(r) + } -// Prints the elapsed time. -fn show(dur: Duration) { - println!( - "Elapsed: {}.{:03} sec", - dur.as_secs(), - dur.subsec_nanos() / 1_000_000 - ); -} + // Prints the elapsed time. + fn show(dur: Duration) { + println!( + "Elapsed: {}.{:03} sec", + dur.as_secs(), + dur.subsec_nanos() / 1_000_000 + ); + } -fn main() { let start = Instant::now(); let update = tick(Duration::from_secs(1)); let ctrl_c = sigint_notifier().unwrap(); @@ -52,3 +53,8 @@ fn main() { } } } + +#[cfg(windows)] +fn main() { + println!("This example does not work on Windows"); +}