From 7f5a74e693e8ef601370fa57876892d10ae9a880 Mon Sep 17 00:00:00 2001 From: iHsin Date: Wed, 24 Jun 2026 22:20:55 +0800 Subject: [PATCH] ci(codspeed): only run walltime on walltime-labeled PRs or v* tags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit walltime benchmarks are expensive — skip them in CI unless: - the PR has a 'walltime' label, or - triggered by a v* release tag fix .gitattributes to use valid gitattributes syntax instead of EditorConfig properties that were causing 'invalid attribute name' warnings. Signed-off-by: iHsin Assisted-by: OpenClaw:deepseek-v4-flash --- .gitattributes | 5 ++- .github/workflows/codspeed.yml | 57 ++++++++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 6 deletions(-) diff --git a/.gitattributes b/.gitattributes index 1c33738..9abb9c4 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,2 @@ -[*] -end_of_line = lf -insert_final_newline = true +# Auto detect text files and ensure LF line endings +* text=auto eol=lf diff --git a/.github/workflows/codspeed.yml b/.github/workflows/codspeed.yml index a47c575..771b6de 100644 --- a/.github/workflows/codspeed.yml +++ b/.github/workflows/codspeed.yml @@ -4,7 +4,15 @@ on: push: branches: - "main" + tags: + - "v*" pull_request: + types: + - opened + - synchronize + - reopened + - labeled + - unlabeled # `workflow_dispatch` allows CodSpeed to trigger backtest # performance analysis in order to generate initial data. workflow_dispatch: @@ -20,13 +28,14 @@ concurrency: jobs: codspeed: name: Run benchmarks (${{ matrix.instrument }}) - runs-on: ubuntu-latest + runs-on: ${{ matrix.runner }} strategy: # Report both instruments even if one runner has an issue. fail-fast: false matrix: - instrument: [simulation, walltime, memory] - steps: + instrument: [simulation, memory] + runner: [ubuntu-latest] + steps: &codspeed-steps - uses: actions/checkout@v4 - name: Setup Rust toolchain @@ -61,3 +70,45 @@ jobs: with: mode: ${{ matrix.instrument }} run: cargo codspeed run --workspace + + codspeed-walltime: + name: Run benchmarks (walltime) + runs-on: codspeed-macro + if: | + (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'walltime')) || + (github.event_name == 'push' && startsWith(github.ref_name, 'v')) + steps: + - uses: actions/checkout@v4 + + - name: Setup Rust toolchain + uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + + - name: Setup Rust cache + uses: Itsusinn/rust-cache@master + + - name: Install cargo-codspeed + uses: taiki-e/install-action@v2 + with: + tool: cargo-codspeed + + # Pre-fetch wind-geodata's benchmark fixtures with curl so the bench's own + # TLS download doesn't run under CodSpeed's Valgrind instrumentation (rustls + # crypto can misbehave under Valgrind). The bench skips downloading when the + # files already exist. + - name: Fetch wind-geodata benchmark fixtures + run: | + mkdir -p crates/wind-geodata/testdata + base="https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest" + curl -fsSL -o crates/wind-geodata/testdata/geoip.dat "$base/geoip.dat" + curl -fsSL -o crates/wind-geodata/testdata/geosite.dat "$base/geosite.dat" + + - name: Build benchmarks — walltime mode + run: cargo codspeed build --workspace -m walltime + + - name: Run the benchmarks (walltime) + uses: CodSpeedHQ/action@v4 + with: + mode: walltime + run: cargo codspeed run --workspace