Skip to content

Commit b879689

Browse files
authored
Adjust GH Actions (#1538)
1 parent 3fac49f commit b879689

File tree

7 files changed

+95
-75
lines changed

7 files changed

+95
-75
lines changed

.github/workflows/benches.yml

+27-9
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,44 @@
11
name: Benches
22

33
on:
4+
push:
5+
branches: [ master ]
6+
paths-ignore:
7+
- "**.md"
8+
- "distr_test/**"
9+
- "examples/**"
410
pull_request:
5-
paths:
6-
- ".github/workflows/benches.yml"
7-
- "benches/**"
11+
branches: [ master ]
12+
paths-ignore:
13+
- "**.md"
14+
- "distr_test/**"
15+
- "examples/**"
16+
17+
defaults:
18+
run:
19+
working-directory: ./benches
820

921
jobs:
10-
benches:
22+
clippy-fmt:
23+
name: Check Clippy and rustfmt
1124
runs-on: ubuntu-latest
12-
defaults:
13-
run:
14-
working-directory: ./benches
1525
steps:
1626
- uses: actions/checkout@v4
1727
- uses: dtolnay/rust-toolchain@master
1828
with:
19-
toolchain: nightly
29+
toolchain: stable
2030
components: clippy, rustfmt
2131
- name: Rustfmt
2232
run: cargo fmt -- --check
2333
- name: Clippy
2434
run: cargo clippy --all-targets -- -D warnings
25-
- name: Build
35+
benches:
36+
name: Test benchmarks
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v4
40+
- uses: dtolnay/rust-toolchain@master
41+
with:
42+
toolchain: nightly
43+
- name: Test
2644
run: RUSTFLAGS=-Dwarnings cargo test --benches

.github/workflows/distr_test.yml

+27-8
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,43 @@
11
name: distr_test
22

33
on:
4+
push:
5+
branches: [ master ]
6+
paths-ignore:
7+
- "**.md"
8+
- "benches/**"
9+
- "examples/**"
410
pull_request:
5-
paths:
6-
- ".github/workflows/distr_test.yml"
7-
- "distr_test/**"
11+
branches: [ master ]
12+
paths-ignore:
13+
- "**.md"
14+
- "benches/**"
15+
- "examples/**"
16+
17+
defaults:
18+
run:
19+
working-directory: ./distr_test
820

921
jobs:
10-
distr_test:
22+
clippy-fmt:
23+
name: Check Clippy and rustfmt
1124
runs-on: ubuntu-latest
12-
defaults:
13-
run:
14-
working-directory: ./distr_test
1525
steps:
1626
- uses: actions/checkout@v4
1727
- uses: dtolnay/rust-toolchain@master
1828
with:
19-
toolchain: nightly
29+
toolchain: stable
2030
components: clippy, rustfmt
2131
- name: Rustfmt
2232
run: cargo fmt -- --check
2333
- name: Clippy
2434
run: cargo clippy --all-targets -- -D warnings
35+
ks-tests:
36+
name: Run Komogorov Smirnov tests
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v4
40+
- uses: dtolnay/rust-toolchain@master
41+
with:
42+
toolchain: nightly
43+
- run: cargo test --release

.github/workflows/test.yml

+23-13
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,37 @@
1-
name: Tests
1+
name: Main tests
22

33
on:
44
push:
55
branches: [ master, '0.[0-9]+' ]
6+
paths-ignore:
7+
- "**.md"
8+
- "benches/**"
9+
- "distr_test/**"
610
pull_request:
711
branches: [ master, '0.[0-9]+' ]
12+
paths-ignore:
13+
- "**.md"
14+
- "benches/**"
15+
- "distr_test/**"
816

917
permissions:
1018
contents: read # to fetch code (actions/checkout)
1119

1220
jobs:
21+
clippy-fmt:
22+
name: Check Clippy and rustfmt
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: dtolnay/rust-toolchain@master
27+
with:
28+
toolchain: stable
29+
components: clippy, rustfmt
30+
- name: Check Clippy
31+
run: cargo clippy --all --all-targets -- -D warnings
32+
- name: Check rustfmt
33+
run: cargo fmt --all -- --check
34+
1335
check-doc:
1436
name: Check doc
1537
runs-on: ubuntu-latest
@@ -85,7 +107,6 @@ jobs:
85107
run: |
86108
cargo test --target ${{ matrix.target }} --features=nightly
87109
cargo test --target ${{ matrix.target }} --all-features
88-
cargo test --target ${{ matrix.target }} --manifest-path benches/Cargo.toml --benches
89110
cargo test --target ${{ matrix.target }} --lib --tests --no-default-features
90111
- name: Test rand
91112
run: |
@@ -111,17 +132,6 @@ jobs:
111132
- name: Test rand_chacha
112133
run: cargo test --target ${{ matrix.target }} --manifest-path rand_chacha/Cargo.toml --features=serde
113134

114-
test-ks:
115-
runs-on: ubuntu-latest
116-
steps:
117-
- uses: actions/checkout@v4
118-
- name: Install toolchain
119-
uses: dtolnay/rust-toolchain@nightly
120-
with:
121-
target: x86_64-unknown-linux-gnu
122-
- name: Test Komogorov Smirnov
123-
run: cargo test --manifest-path distr_test/Cargo.toml --release
124-
125135
test-cross:
126136
runs-on: ${{ matrix.os }}
127137
strategy:

.github/workflows/workspace.yml

-33
This file was deleted.

benches/benches/distr.rs

+15-9
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
// option. This file may not be copied, modified, or distributed
77
// except according to those terms.
88

9-
#![feature(custom_inner_attributes)]
10-
11-
// Rustfmt splits macro invocations to shorten lines; in this case longer-lines are more readable
12-
#![rustfmt::skip]
13-
149
use criterion::{criterion_group, criterion_main, Criterion, Throughput};
1510
use criterion_cycles_per_byte::CyclesPerByte;
1611

@@ -80,7 +75,8 @@ fn bench(c: &mut Criterion<CyclesPerByte>) {
8075
let distr = Normal::new(-E, PI).unwrap();
8176

8277
c.iter(|| {
83-
distr.sample_iter(&mut rng)
78+
distr
79+
.sample_iter(&mut rng)
8480
.take(ITER_ELTS as usize)
8581
.fold(0.0, |a, r| a + r)
8682
});
@@ -121,12 +117,22 @@ fn bench(c: &mut Criterion<CyclesPerByte>) {
121117
let mut g = c.benchmark_group("weighted");
122118
distr_int!(g, "i8", usize, WeightedIndex::new([1i8, 2, 3, 4, 12, 0, 2, 1]).unwrap());
123119
distr_int!(g, "u32", usize, WeightedIndex::new([1u32, 2, 3, 4, 12, 0, 2, 1]).unwrap());
124-
distr_int!(g, "f64", usize, WeightedIndex::new([1.0f64, 0.001, 1.0/3.0, 4.01, 0.0, 3.3, 22.0, 0.001]).unwrap());
120+
distr_int!(g, "f64", usize, WeightedIndex::new([1.0f64, 0.001, 1.0 / 3.0, 4.01, 0.0, 3.3, 22.0, 0.001]).unwrap());
125121
distr_int!(g, "large_set", usize, WeightedIndex::new((0..10000).rev().chain(1..10001)).unwrap());
126122
distr_int!(g, "alias_method_i8", usize, WeightedAliasIndex::new(vec![1i8, 2, 3, 4, 12, 0, 2, 1]).unwrap());
127123
distr_int!(g, "alias_method_u32", usize, WeightedAliasIndex::new(vec![1u32, 2, 3, 4, 12, 0, 2, 1]).unwrap());
128-
distr_int!(g, "alias_method_f64", usize, WeightedAliasIndex::new(vec![1.0f64, 0.001, 1.0/3.0, 4.01, 0.0, 3.3, 22.0, 0.001]).unwrap());
129-
distr_int!(g, "alias_method_large_set", usize, WeightedAliasIndex::new((0..10000).rev().chain(1..10001).collect()).unwrap());
124+
distr_int!(
125+
g,
126+
"alias_method_f64",
127+
usize,
128+
WeightedAliasIndex::new(vec![1.0f64, 0.001, 1.0 / 3.0, 4.01, 0.0, 3.3, 22.0, 0.001]).unwrap()
129+
);
130+
distr_int!(
131+
g,
132+
"alias_method_large_set",
133+
usize,
134+
WeightedAliasIndex::new((0..10000).rev().chain(1..10001).collect()).unwrap()
135+
);
130136
g.finish();
131137

132138
let mut g = c.benchmark_group("binomial");

benches/benches/seq_choose.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ pub fn bench(c: &mut Criterion) {
6868
b.iter(|| {
6969
// Collect full result to prevent unwanted shortcuts getting
7070
// first element (in case sample_indices returns an iterator).
71-
let samples_iter = x
72-
.choose_multiple_weighted(&mut rng, amount, |_| 1.0)
73-
.unwrap();
71+
let samples_iter = x.choose_multiple_weighted(&mut rng, amount, |_| 1.0).unwrap();
7472
for (slot, sample) in y.iter_mut().zip(samples_iter) {
7573
*slot = *sample;
7674
}

benches/rustfmt.toml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
max_width = 120
2+
fn_call_width = 108

0 commit comments

Comments
 (0)