Skip to content

Commit

Permalink
fix(ci): move msrv check to a dedicated job
Browse files Browse the repository at this point in the history
* Add `msrv` job
* Add `RUST_BACKTRACE=1`
* Add `-Dwarnings`
* Fix clippy warnings in benches
* Make job naming more consistent
  • Loading branch information
loyd committed Oct 4, 2023
1 parent fdd6be0 commit 7a70384
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 17 deletions.
47 changes: 34 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,28 @@ name: CI

on: [pull_request]

env:
RUSTFLAGS: -Dwarnings
RUST_BACKTRACE: 1
MSRV: 1.42.0

jobs:
build:
name: Build for ${{ matrix.target }} (${{ matrix.rust }})
runs-on: ubuntu-latest
# The "msrv" job should be run first as WA to avoid the bug with old cargo:
# "candidate versions found which didn't match"
#needs: msrv
strategy:
matrix:
rust:
- stable
- nightly
- 1.42.0
target:
- x86_64-unknown-linux-gnu
include:
- rust: stable
target: i686-unknown-linux-musl
name: cargo +${{ matrix.rust }} build --target ${{ matrix.target }}
steps:
- uses: actions/checkout@master
- name: Install toolchain
Expand All @@ -32,13 +39,30 @@ jobs:
command: build
args: --all-targets --target ${{ matrix.target }}

msrv:
name: Build (MSRV)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.MSRV }}
override: true
- name: cargo +${{ env.MSRV }} build
uses: actions-rs/cargo@v1
with:
command: build
env:
RUSTFLAGS: "" # remove -Dwarnings

test:
name: Tests
name: Tests (nightly)
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@master

- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
Expand All @@ -49,13 +73,11 @@ jobs:
run: cargo test

test-loom:
name: Loom tests
name: Loom tests (nightly)
runs-on: ubuntu-latest
needs: build

steps:
- uses: actions/checkout@master

- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
Expand All @@ -65,10 +87,10 @@ jobs:
- name: Run Loom tests
run: ./bin/loom.sh

clippy_check:
clippy:
name: Clippy (stable)
runs-on: ubuntu-latest
needs: build

steps:
- uses: actions/checkout@v2
- name: Install toolchain
Expand All @@ -78,17 +100,16 @@ jobs:
toolchain: stable
components: clippy
override: true
- name: Run clippy
- name: cargo clippy --all-targets --all-features
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features
args: --all-targets --all-features

rustfmt:
name: rustfmt
name: Rustfmt (stable)
runs-on: ubuntu-latest
needs: build

steps:
- uses: actions/checkout@v2
- name: Install toolchain
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ proptest = "1"
criterion = "0.3"
slab = "0.4.2"
memory-stats = "1"
indexmap = "2"
indexmap = "1"

[target.'cfg(loom)'.dependencies]
loom = { version = "0.5", features = ["checkpoint"], optional = true }
Expand Down
2 changes: 1 addition & 1 deletion benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl<T: Send + Sync + 'static> MultithreadedBench<T> {
let end = self.end.clone();
let slab = self.slab.clone();
thread::spawn(move || {
f(&*start, &*slab);
f(&start, &*slab);
end.wait();
});
self
Expand Down
5 changes: 3 additions & 2 deletions src/tid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use std::{
collections::VecDeque,
fmt,
marker::PhantomData,
sync::PoisonError,
};

/// Uniquely identifies a thread.
Expand Down Expand Up @@ -186,14 +185,16 @@ impl Registration {
#[cfg(not(all(loom, any(feature = "loom", test))))]
impl Drop for Registration {
fn drop(&mut self) {
use std::sync::PoisonError;

if let Some(id) = self.0.get() {
let mut free_list = REGISTRY.free.lock().unwrap_or_else(PoisonError::into_inner);
free_list.push_back(id);
}
}
}

#[cfg(test)]
#[cfg(all(test, not(loom)))]
pub(crate) fn with<R>(tid: usize, f: impl FnOnce() -> R) -> R {
struct Guard(Option<usize>);

Expand Down

0 comments on commit 7a70384

Please sign in to comment.