Skip to content

Commit 838a57c

Browse files
authored
Reduce PR CI cost by running expensive checks after clippy & rustfmt (#24246)
## Description Change CI to run expensive jobs after rustfmt and clippy. I (claude) did some data analysis: ``` ==================================================================================================== COMPLETE COST ANALYSIS FROM 90-DAY DATA ==================================================================================================== ==================================================================================================== STEP 1: IDENTIFY GATE JOBS ==================================================================================================== Job Workflow Runs Fail % $/run ---------------------------------------------------------------------------------------------------- clippy external.yml 3735 5.3% $ 0.26 rustfmt external.yml 3838 8.1% $ 0.01 clippy rust.yml 3727 14.7% $ 0.83 rustfmt rust.yml 3852 6.8% $ 0.01 Gate costs and failure rates by workflow: rust.yml: rustfmt: 6.8% failure, $0.01/run clippy: 14.7% failure, $0.83/run Gate cost (parallel): $0.83/run external.yml: rustfmt: 8.1% failure, $0.01/run clippy: 5.3% failure, $0.26/run Gate cost (parallel): $0.26/run bridge.yml: rustfmt: 6.8% failure, $0.01/run clippy: 14.7% failure, $0.83/run Gate cost (parallel): $0.83/run ==================================================================================================== STEP 2: CALCULATE GATE FAILURE RATES (LOWER AND UPPER BOUNDS) ==================================================================================================== rust.yml: Lower bound (average): 10.8% Upper bound (union): 20.5% external.yml: Lower bound (average): 6.7% Upper bound (union): 12.9% bridge.yml: Lower bound (average): 10.8% Upper bound (union): 20.5% ==================================================================================================== STEP 3: IDENTIFY GATED JOBS BY WORKFLOW ==================================================================================================== rust.yml: Job $/run Runs ------------------------------------------------------------------------------------------ test (ubuntu-ghcloud) $ 5.39 4613 test-extra (ubuntu-ghcloud) $ 4.88 4583 simtest $ 4.03 3783 simtest-mainnet $ 4.01 3737 windows-build (windows-ghcloud) $ 2.63 3412 cutting a new execution layer $ 0.44 3723 Total gated jobs cost: $ 21.39 external.yml: Job $/run Runs ------------------------------------------------------------------------------------------ external-crates-test (ubuntu-ghcloud) $ 1.74 4579 Total gated jobs cost: $ 1.74 bridge.yml: Job $/run Runs ------------------------------------------------------------------------------------------ test (ubuntu-ghcloud) $ 4.90 3828 Total gated jobs cost: $ 4.90 ==================================================================================================== STEP 4: CALCULATE SAVINGS RANGE ==================================================================================================== rust.yml: CI runs per day: 42.8 Gated jobs cost: $21.39/run Lower bound (10.8% failure rate): Savings per run: $2.30 Daily savings: $98.40 Upper bound (20.5% failure rate): Savings per run: $4.38 Daily savings: $187.64 external.yml: CI runs per day: 42.6 Gated jobs cost: $1.74/run Lower bound (6.7% failure rate): Savings per run: $0.12 Daily savings: $4.93 Upper bound (12.9% failure rate): Savings per run: $0.22 Daily savings: $9.55 bridge.yml: CI runs per day: 42.5 Gated jobs cost: $4.90/run Lower bound (10.8% failure rate): Savings per run: $0.53 Daily savings: $22.42 Upper bound (20.5% failure rate): Savings per run: $1.01 Daily savings: $42.75 ==================================================================================================== STEP 5: TOTAL SAVINGS RANGE ==================================================================================================== Daily savings range: $125.74 - $239.94 Monthly savings range: $3,772.34 - $7,198.23 Annual savings range: $45,896.74 - $87,578.43 ==================================================================================================== STEP 6: PERFORMANCE IMPACT ==================================================================================================== Current wall-clock time (all parallel): 21.57 min New wall-clock time: Gate stage: 3.30 min Expensive jobs (if pass): 21.57 min Total for passing CI runs: 24.87 min Total for failing CI runs: 3.30 min Impact (using average failure rate of 18.0%): PRs that pass (82.0%): +3.30 min PRs that fail gate (18.0%): -18.26 min Weighted average: -0.57 min (-34 seconds) ==================================================================================================== FINAL SUMMARY ==================================================================================================== Estimated annual savings range: $45,896.74 - $87,578.43 Performance impact: -34 seconds average per CI run, +3.30 min that pass the checks The savings range reflects uncertainty in gate failure correlation: - Lower bound assumes some overlap in rustfmt/clippy failures - Upper bound assumes independent failures (union probability) - Actual savings likely near upper bound given different failure modes ``` ## Test plan How did you test the new or updated feature? --- ## Release notes Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required. For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates. - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] gRPC: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK: - [ ] Indexing Framework:
1 parent 4b4d446 commit 838a57c

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

.github/workflows/bridge.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,31 @@ jobs:
6363
uses: './.github/actions/diffs'
6464
id: diff
6565

66-
test:
66+
rustfmt:
67+
needs: diff
68+
if: needs.diff.outputs.isRust == 'true'
69+
runs-on: [ ubuntu-latest ]
70+
steps:
71+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1
72+
with:
73+
ref: ${{ github.event.inputs.sui_repo_ref || github.ref }}
74+
- run: rustup component add rustfmt
75+
- run: cargo fmt --check
76+
77+
clippy:
6778
needs: diff
79+
if: needs.diff.outputs.isRust == 'true'
80+
runs-on: [ ubuntu-ghcloud ]
81+
steps:
82+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1
83+
with:
84+
ref: ${{ github.event.inputs.sui_repo_ref || github.ref }}
85+
- run: rustup component add clippy
86+
- name: cargo clippy
87+
run: cargo xclippy -D warnings
88+
89+
test:
90+
needs: [diff, rustfmt, clippy]
6891
if: needs.diff.outputs.isRust == 'true' || needs.diff.outputs.isSolidity == 'true'
6992
timeout-minutes: 45
7093
env:

.github/workflows/external.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
id: diff
4848

4949
external-crates-test:
50-
needs: diff
50+
needs: [diff, rustfmt, clippy]
5151
if: needs.diff.outputs.isRust == 'true'
5252
timeout-minutes: 45
5353
env:

.github/workflows/rust.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
- run: cargo xlint
7474

7575
test:
76-
needs: diff
76+
needs: [diff, rustfmt, clippy]
7777
if: needs.diff.outputs.isRust == 'true'
7878
timeout-minutes: 45
7979
env:
@@ -107,7 +107,7 @@ jobs:
107107
shell: bash
108108

109109
test-extra:
110-
needs: diff
110+
needs: [diff, rustfmt, clippy]
111111
if: needs.diff.outputs.isRust == 'true'
112112
timeout-minutes: 45
113113
env:
@@ -179,7 +179,7 @@ jobs:
179179
shell: bash
180180

181181
windows-build:
182-
needs: diff
182+
needs: [diff, rustfmt, clippy]
183183
if: needs.diff.outputs.isRust == 'true'
184184
timeout-minutes: 45
185185
runs-on: ${{ matrix.os }}
@@ -211,7 +211,7 @@ jobs:
211211
cargo build --all-features
212212
213213
simtest:
214-
needs: diff
214+
needs: [diff, rustfmt, clippy]
215215
if: needs.diff.outputs.isRust == 'true' || needs.diff.outputs.isSolidity == 'true'
216216
timeout-minutes: 45
217217
runs-on: [ ubuntu-ghcloud ]
@@ -237,7 +237,7 @@ jobs:
237237
scripts/simtest/stress-new-tests.sh
238238
239239
simtest-mainnet:
240-
needs: diff
240+
needs: [diff, rustfmt, clippy]
241241
if: needs.diff.outputs.isRust == 'true' || needs.diff.outputs.isSolidity == 'true'
242242
timeout-minutes: 45
243243
runs-on: [ ubuntu-ghcloud ]
@@ -415,7 +415,7 @@ jobs:
415415

416416
sui-excution-cut:
417417
name: cutting a new execution layer
418-
needs: diff
418+
needs: [diff, rustfmt, clippy]
419419
if: needs.diff.outputs.isRust == 'true'
420420
runs-on: [ ubuntu-ghcloud ]
421421
steps:

0 commit comments

Comments
 (0)