Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 5851805

Browse files
authored
Fix running cargo bench & test in CI. (#14943)
1 parent 3b8574b commit 5851805

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

.github/workflows/tests.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,29 @@ jobs:
566566

567567
- run: cargo test
568568

569+
# We want to ensure that the cargo benchmarks still compile, which requires a
570+
# nightly compiler.
571+
cargo-bench:
572+
if: ${{ needs.changes.outputs.rust == 'true' }}
573+
runs-on: ubuntu-latest
574+
needs:
575+
- linting-done
576+
- changes
577+
578+
steps:
579+
- uses: actions/checkout@v3
580+
581+
- name: Install Rust
582+
# There don't seem to be versioned releases of this action per se: for each rust
583+
# version there is a branch which gets constantly rebased on top of master.
584+
# We pin to a specific commit for paranoia's sake.
585+
uses: dtolnay/rust-toolchain@e645b0cf01249a964ec099494d38d2da0f0b349f
586+
with:
587+
toolchain: nightly-2022-12-01
588+
- uses: Swatinem/rust-cache@v2
589+
590+
- run: cargo bench --no-run
591+
569592
# a job which marks all the other jobs as complete, thus allowing PRs to be merged.
570593
tests-done:
571594
if: ${{ always() }}
@@ -577,6 +600,7 @@ jobs:
577600
- portdb
578601
- complement
579602
- cargo-test
603+
- cargo-bench
580604
runs-on: ubuntu-latest
581605
steps:
582606
- uses: matrix-org/done-action@v2
@@ -588,3 +612,4 @@ jobs:
588612
skippable: |
589613
lint-newsfile
590614
cargo-test
615+
cargo-bench

changelog.d/14943.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Experimental support for [MSC3952](https://github.com/matrix-org/matrix-spec-proposals/pull/3952): intentional mentions.

rust/benches/evaluator.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
#![feature(test)]
16+
use std::collections::BTreeSet;
1617
use synapse::push::{
1718
evaluator::PushRuleEvaluator, Condition, EventMatchCondition, FilteredPushRules, PushRules,
1819
};
@@ -32,6 +33,8 @@ fn bench_match_exact(b: &mut Bencher) {
3233

3334
let eval = PushRuleEvaluator::py_new(
3435
flattened_keys,
36+
BTreeSet::new(),
37+
false,
3538
10,
3639
Some(0),
3740
Default::default(),
@@ -68,6 +71,8 @@ fn bench_match_word(b: &mut Bencher) {
6871

6972
let eval = PushRuleEvaluator::py_new(
7073
flattened_keys,
74+
BTreeSet::new(),
75+
false,
7176
10,
7277
Some(0),
7378
Default::default(),
@@ -104,6 +109,8 @@ fn bench_match_word_miss(b: &mut Bencher) {
104109

105110
let eval = PushRuleEvaluator::py_new(
106111
flattened_keys,
112+
BTreeSet::new(),
113+
false,
107114
10,
108115
Some(0),
109116
Default::default(),
@@ -140,6 +147,8 @@ fn bench_eval_message(b: &mut Bencher) {
140147

141148
let eval = PushRuleEvaluator::py_new(
142149
flattened_keys,
150+
BTreeSet::new(),
151+
false,
143152
10,
144153
Some(0),
145154
Default::default(),
@@ -156,6 +165,7 @@ fn bench_eval_message(b: &mut Bencher) {
156165
false,
157166
false,
158167
false,
168+
false,
159169
);
160170

161171
b.iter(|| eval.run(&rules, Some("bob"), Some("person")));

0 commit comments

Comments
 (0)