Skip to content

Commit 574fc0d

Browse files
authored
Refactor Project Layout + Benches (#308)
Related #229 Related #309 Resolves #35 - project is no longer a workspace, but a regular package - turned nested packages into appropriate files (benches, examples...) - optimize crate release build to reduce linked binary size and improve speed - benches: - now run on PRs too - no manual dispatch - run all benches in a single job in parallel - removed dead code - **disabled until ~~we get valid Bencher API token~~ properly debugged (see #312 )** - added a couple of missing Cargo.toml fields (readme, documentation) - examples: - now regular files (not subpackages) - live/sync examples now continuously send and stream txs (until user stops the program), where previously they would send/stream one and then halt indefinitely, giving the impression that something was wrong
1 parent 06d785f commit 574fc0d

39 files changed

+399
-601
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Base Benchmarks
2+
3+
# on:
4+
# push:
5+
# branches: [main, release-v*]
6+
# paths:
7+
# - "src/**"
8+
# - "benches/**"
9+
# - "Cargo.toml"
10+
# - "Cargo.lock"
11+
12+
# If new code is pushed to a PR branch, then cancel in progress workflows for
13+
# that PR. Ensures that we don't waste CI time, and returns results quicker.
14+
# https://github.com/jonhoo/rust-ci-conf/pull/5
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
17+
cancel-in-progress: true
18+
19+
env:
20+
CARGO_TERM_COLOR: always
21+
RUST_BACKTRACE: 1
22+
23+
jobs:
24+
benchmark:
25+
name: "Continuous Benchmarking: ${{ matrix.suite }}"
26+
runs-on: ubuntu-latest
27+
permissions:
28+
checks: write
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
suite:
33+
- historic_scanning
34+
- latest_events_scanning
35+
36+
steps:
37+
- name: Harden runner
38+
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
39+
with:
40+
egress-policy: audit
41+
42+
- name: Checkout
43+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
44+
45+
- name: Setup Rust
46+
uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2
47+
48+
- name: Setup Foundry
49+
uses: foundry-rs/foundry-toolchain@8b0419c685ef46cb79ec93fbdc131174afceb730 # v1.6.0
50+
51+
- name: Setup Bencher
52+
# Official docs recommend using `main` commit, because discrepancies between CI version and Bencher's API version
53+
# can cause bench failures.
54+
# https://bencher.dev/docs/how-to/github-actions/
55+
uses: bencherdev/bencher@main
56+
57+
- name: Prepare benchmark state
58+
run: |
59+
gunzip -kf benches/dumps/*.json.gz
60+
ls -lh benches/dumps/
61+
62+
- name: Run benchmark
63+
env:
64+
BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }}
65+
BENCHER_PROJECT: ${{ vars.BENCHER_PROJECT }}
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
run: |
68+
bencher run \
69+
--project "$BENCHER_PROJECT" \
70+
--token "$BENCHER_API_TOKEN" \
71+
--branch main \
72+
--testbed ubuntu-latest \
73+
--adapter rust_criterion \
74+
--threshold-measure latency \
75+
--threshold-test t_test \
76+
--threshold-max-sample-size 64 \
77+
--threshold-upper-boundary 0.99 \
78+
--thresholds-reset \
79+
--github-actions "$GITHUB_TOKEN" \
80+
--err \
81+
"cargo bench --bench ${{ matrix.suite }} --features bench-utils"

.github/workflows/benchmarks.yml

Lines changed: 0 additions & 134 deletions
This file was deleted.

.github/workflows/check.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,16 @@ permissions:
1212
# main branch ensures that the PR only gets built once.
1313
on:
1414
push:
15-
branches: [main, v*]
15+
branches: [main, release-v*]
16+
paths-ignore:
17+
- "**.md"
18+
- ".vscode"
19+
- ".cargo"
1620
pull_request:
21+
paths-ignore:
22+
- "**.md"
23+
- ".vscode"
24+
- ".cargo"
1725
# If new code is pushed to a PR branch, then cancel in progress workflows for
1826
# that PR. Ensures that we don't waste CI time, and returns results quicker.
1927
# https://github.com/jonhoo/rust-ci-conf/pull/5
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: PR Benchmarks
2+
3+
# on:
4+
# pull_request:
5+
# types: [opened, reopened, edited, synchronize]
6+
# paths:
7+
# - "src/**"
8+
# - "benches/**"
9+
# - "Cargo.toml"
10+
# - "Cargo.lock"
11+
12+
# If new code is pushed to a PR branch, then cancel in progress workflows for
13+
# that PR. Ensures that we don't waste CI time, and returns results quicker.
14+
# https://github.com/jonhoo/rust-ci-conf/pull/5
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
17+
cancel-in-progress: true
18+
19+
env:
20+
CARGO_TERM_COLOR: always
21+
RUST_BACKTRACE: 1
22+
23+
jobs:
24+
benchmark:
25+
name: "Continuous PR Benchmarking: ${{ matrix.suite }}"
26+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
27+
runs-on: ubuntu-latest
28+
permissions:
29+
checks: write
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
suite:
34+
- historic_scanning
35+
- latest_events_scanning
36+
37+
steps:
38+
- name: Harden runner
39+
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
40+
with:
41+
egress-policy: audit
42+
43+
- name: Checkout
44+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
45+
46+
- name: Setup Rust
47+
uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2
48+
49+
- name: Setup Foundry
50+
uses: foundry-rs/foundry-toolchain@8b0419c685ef46cb79ec93fbdc131174afceb730 # v1.6.0
51+
52+
- name: Setup Bencher
53+
# Official docs recommend using `main` commit, because discrepancies between CI version and Bencher's API version
54+
# can cause bench failures.
55+
# https://bencher.dev/docs/how-to/github-actions/
56+
uses: bencherdev/bencher@main
57+
58+
- name: Prepare benchmark state
59+
run: |
60+
gunzip -kf benches/dumps/*.json.gz
61+
ls -lh benches/dumps/
62+
63+
- name: Run benchmark
64+
env:
65+
BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }}
66+
BENCHER_PROJECT: ${{ vars.BENCHER_PROJECT }}
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68+
run: |
69+
bencher run \
70+
--project "$BENCHER_PROJECT" \
71+
--token "$BENCHER_API_TOKEN" \
72+
--branch "${{ github.head_ref || github.ref_name }}" \
73+
--testbed ubuntu-latest \
74+
--adapter rust_criterion \
75+
--start-point "${{ github.base_ref }}" \
76+
--start-point-hash "${{ github.event.pull_request.base.sha }}" \
77+
--start-point-clone-thresholds \
78+
--start-point-reset \
79+
--github-actions "$GITHUB_TOKEN" \
80+
--err \
81+
"cargo bench --bench ${{ matrix.suite }} --features bench-utils"

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
fi
5252
5353
- name: Check event-scanner
54-
run: cargo publish -p event-scanner --locked --dry-run
54+
run: cargo publish --locked --dry-run
5555

5656
# cargo automatically picks up CARGO_REGISTRY_TOKEN from environment variables
5757
- name: Publish event-scanner
@@ -62,4 +62,4 @@ jobs:
6262
echo "CARGO_REGISTRY_TOKEN is not set in repository secrets" >&2
6363
exit 1
6464
fi
65-
cargo publish -p event-scanner --locked
65+
cargo publish --locked

.github/workflows/test.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,23 @@ permissions:
55

66
on:
77
pull_request:
8+
paths-ignore:
9+
- "**.md"
10+
- ".vscode"
11+
- ".cargo"
12+
- "benches/**"
13+
- "examples/**"
14+
- "src/bin/generate_dump.rs"
815
merge_group:
916
push:
10-
branches: [main]
17+
branches: [main, release-v*]
18+
paths-ignore:
19+
- "**.md"
20+
- ".vscode"
21+
- ".cargo"
22+
- "benches/**"
23+
- "examples/**"
24+
- "src/bin/generate_dump.rs"
1125

1226
env:
1327
CARGO_TERM_COLOR: always
@@ -50,7 +64,7 @@ jobs:
5064
tool: cargo-nextest
5165

5266
- name: Cargo test
53-
run: cargo nextest run --locked --all-targets --all-features --no-tests=pass --no-fail-fast
67+
run: cargo nextest run --locked --bins --lib --tests --all-features --no-tests=pass --no-fail-fast
5468

5569
# https://github.com/rust-lang/cargo/issues/6669
5670
- name: Run doc tests

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"rust-analyzer.cargo.features": ["test-utils"],
2+
"rust-analyzer.cargo.features": ["test-utils", "bench-utils"],
33
"rust-analyzer.rustfmt.extraArgs": ["+nightly"]
44
}

0 commit comments

Comments
 (0)