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

Enable tests on Windows on CI #518

Closed
wants to merge 1 commit into from
Closed
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
42 changes: 41 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@ 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 }}
strategy:
Expand All @@ -27,6 +34,10 @@ jobs:
rust:
- 1.36.0
- nightly
os:
- ubuntu
- windows
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@master
- name: Install Rust
Expand Down Expand Up @@ -60,3 +71,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!
Comment on lines +75 to +79
Copy link
Member Author

@taiki-e taiki-e May 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a realistic way for bors to receive build status from Github Actions, which do a lot of jobs (It's used in rust-lang/rust, rust-lang/clippy, etc. Previously we had to manually manage all job names.)


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
19 changes: 1 addition & 18 deletions bors.toml
Original file line number Diff line number Diff line change
@@ -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"]
16 changes: 9 additions & 7 deletions ci/crossbeam-epoch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 [[ "$OSTYPE" == "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
Expand Down
66 changes: 36 additions & 30 deletions crossbeam-channel/examples/stopwatch.rs
Original file line number Diff line number Diff line change
@@ -1,39 +1,45 @@
//! 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<Receiver<()>> {
let (s, r) = bounded(100);
let signals = Signals::new(&[SIGINT])?;

thread::spawn(move || {
for _ in signals.forever() {
if s.send(()).is_err() {
break;
#[cfg(windows)] // signal_hook::iterator does not work on windows
fn main() {
println!("This example does not work on Windows");
}

#[cfg(not(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<Receiver<()>> {
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();
Expand Down