Skip to content

Commit ccf2aad

Browse files
authored
Port banches to criterion and test benches in CI (#352)
* Port benches to criterion Signed-off-by: sagudev <[email protected]> * join all CI jobs and test benches Signed-off-by: sagudev <[email protected]> * Remove unstable rustfmt options Signed-off-by: sagudev <[email protected]> * Name `cargo test benches` * long variable names Signed-off-by: sagudev <[email protected]> --------- Signed-off-by: sagudev <[email protected]>
1 parent b16bee1 commit ccf2aad

File tree

8 files changed

+329
-496
lines changed

8 files changed

+329
-496
lines changed

.github/workflows/main.yml

+28-63
Original file line numberDiff line numberDiff line change
@@ -7,89 +7,55 @@ on:
77
workflow_dispatch:
88
merge_group:
99
types: [checks_requested]
10-
10+
1111
jobs:
12-
linux-ci:
13-
name: Linux
14-
runs-on: ubuntu-latest
12+
test:
13+
name: ${{ format('{0} {1}', matrix.platform.target, matrix.features)}}
14+
runs-on: ${{ matrix.platform.os }}
15+
env:
16+
RUST_BACKTRACE: 1
1517
strategy:
1618
matrix:
17-
features: ["", "force-inprocess", "memfd", "async"]
19+
platform:
20+
- { target: aarch64-apple-darwin, os: macos-14 }
21+
- { target: x86_64-apple-darwin, os: macos-13 }
22+
- { target: x86_64-unknown-linux-gnu, os: ubuntu-latest }
23+
- { target: x86_64-pc-windows-msvc, os: windows-latest }
24+
- { target: i686-pc-windows-msvc, os: windows-latest }
25+
features: ["", "force-inprocess", "async"]
26+
include:
27+
- features: "windows-shared-memory-equality"
28+
platform: { target: x86_64-pc-windows-msvc, os: windows-latest }
29+
- features: "windows-shared-memory-equality"
30+
platform: { target: i686-pc-windows-msvc, os: windows-latest }
31+
- features: "memfd"
32+
platform: { target: x86_64-unknown-linux-gnu, os: ubuntu-latest }
1833
steps:
19-
- uses: actions/checkout@v3
34+
- uses: actions/checkout@v4
2035

21-
- name: Install nightly toolchain
22-
uses: dtolnay/rust-toolchain@nightly
36+
- name: Install stable toolchain
37+
uses: dtolnay/rust-toolchain@stable
2338
with:
2439
components: rustfmt, clippy
2540

2641
- name: rustfmt
2742
run: cargo fmt --check
2843

2944
- name: clippy
30-
run: cargo clippy --features "${{ matrix.features }}"
31-
32-
- name: Cargo build
33-
run: cargo build --features "${{ matrix.features }}"
34-
35-
- name: Cargo test
36-
run: cargo test --features "${{ matrix.features }}"
37-
env:
38-
RUST_BACKTRACE: 1
39-
40-
mac-ci:
41-
name: macOS
42-
runs-on: macos-latest
43-
strategy:
44-
matrix:
45-
features: ["", "force-inprocess", "async"]
46-
47-
steps:
48-
- uses: actions/checkout@v3
49-
50-
- name: Install nightly toolchain
51-
uses: dtolnay/rust-toolchain@nightly
52-
53-
- name: Cargo build
54-
run: cargo build --features "${{ matrix.features }}"
45+
run: cargo clippy --features "${{ matrix.features }}" --target ${{ matrix.platform.target }}
5546

5647
- name: Cargo test
57-
run: cargo test --features "${{ matrix.features }}"
58-
env:
59-
RUST_BACKTRACE: 1
60-
61-
windows-ci:
62-
name: Windows
63-
runs-on: windows-latest
64-
strategy:
65-
matrix:
66-
features: ["", "--features force-inprocess", "--features windows-shared-memory-equality", "--features async"]
67-
target: ["x86_64-pc-windows-msvc", "i686-pc-windows-msvc"]
68-
69-
steps:
70-
- uses: actions/checkout@v3
71-
72-
- name: Install nightly toolchain
73-
uses: dtolnay/rust-toolchain@nightly
74-
with:
75-
targets: ${{ matrix.target }}
48+
run: cargo test --features "${{ matrix.features }}" --target ${{ matrix.platform.target }}
7649

77-
- name: Cargo build
78-
run: cargo build ${{ matrix.features }} --target ${{ matrix.target }}
79-
80-
- name: Cargo test
81-
run: cargo test ${{ matrix.features }} --target ${{ matrix.target }}
82-
env:
83-
RUST_BACKTRACE: 1
50+
- name: Cargo test benches
51+
run: cargo test --benches --features "${{ matrix.features }}" --target ${{ matrix.platform.target }}
8452

8553
build_result:
8654
name: Result
8755
runs-on: ubuntu-latest
8856
if: always()
8957
needs:
90-
- "linux-ci"
91-
- "mac-ci"
92-
- "windows-ci"
58+
- "test"
9359

9460
steps:
9561
- name: Success
@@ -98,4 +64,3 @@ jobs:
9864
- name: Failure
9965
run: exit 1
10066
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
101-

Cargo.toml

+13
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ license = "MIT OR Apache-2.0"
77
repository = "https://github.com/servo/ipc-channel"
88
edition = "2021"
99

10+
[[bench]]
11+
name = "platform"
12+
harness = false
13+
14+
[[bench]]
15+
name = "ipc"
16+
harness = false
17+
18+
[[bench]]
19+
name = "ipc_receiver_set"
20+
harness = false
21+
1022
[features]
1123
force-inprocess = []
1224
memfd = ["sc"]
@@ -34,6 +46,7 @@ tempfile = "3.4"
3446
[dev-dependencies]
3547
crossbeam-utils = "0.8"
3648
static_assertions = "1.1.0"
49+
criterion = { version = "0.5", features = ["html_reports"] }
3750

3851
[target.'cfg(target_os = "windows")'.dependencies.windows]
3952
version = "0.58.0"

0 commit comments

Comments
 (0)