-
Notifications
You must be signed in to change notification settings - Fork 899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ci: Benchmark CI Step #3480
Merged
Merged
ci: Benchmark CI Step #3480
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
eae97be
Publish benchmark results
MichaReiser 72d5e5b
Run benchmarks on single machine
MichaReiser 6a038ed
Cache main benchmark binary, merge with ecosystem-results comment
MichaReiser 792f83e
Remove main caching
MichaReiser fbb1bbc
Add Ecosystem Header
MichaReiser File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
name: Benchmark | ||
|
||
on: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
run-benchmark: | ||
if: github.event_name == 'pull_request' | ||
name: "Run | ${{ matrix.os }}" | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest] | ||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: "PR - Checkout Branch" | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: "PR - Install Rust toolchain" | ||
run: rustup show | ||
|
||
- uses: Swatinem/rust-cache@v1 | ||
|
||
- name: "PR - Build benchmarks" | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: bench | ||
args: -p ruff_benchmark --no-run | ||
|
||
- name: "PR - Run benchmarks" | ||
run: cargo benchmark --save-baseline=pr | ||
|
||
- name: "Main - Checkout Branch" | ||
uses: actions/checkout@v3 | ||
with: | ||
clean: false | ||
ref: main | ||
|
||
- name: "Main - Install Rust toolchain" | ||
run: rustup show | ||
|
||
- name: "Main - Build benchmarks" | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: bench | ||
args: -p ruff_benchmark --no-run | ||
|
||
- name: "Main - Run benchmarks" | ||
run: cargo benchmark --save-baseline=main | ||
|
||
- name: "Upload benchmark results" | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: benchmark-results-${{ matrix.os }} | ||
path: ./target/criterion | ||
|
||
# Cleanup | ||
- name: Remove Criterion Artifact | ||
uses: JesseTG/rm@v1.0.3 | ||
with: | ||
path: ./target/criterion | ||
|
||
benchmark-compare: | ||
if: github.event_name == 'pull_request' | ||
runs-on: ubuntu-latest | ||
name: Compare | ||
needs: | ||
- run-benchmark | ||
|
||
steps: | ||
- name: "Install Rust toolchain" | ||
run: rustup show | ||
|
||
- name: "Install critcmp" | ||
# Use debug build: Building takes much longer than the "slowness" of using the debug build. | ||
run: cargo install --debug critcmp | ||
|
||
- name: "Linux | Download PR benchmark results" | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: benchmark-results-ubuntu-latest | ||
path: ./target/criterion | ||
|
||
- name: "Linux | Compare benchmark results" | ||
shell: bash | ||
run: | | ||
echo "### Benchmark" >> summary.md | ||
echo "#### Linux" >> summary.md | ||
echo "\`\`\`" >> summary.md | ||
critcmp main pr >> summary.md | ||
echo "\`\`\`" >> summary.md | ||
echo "" >> summary.md | ||
|
||
- name: "Linux | Cleanup benchmark results" | ||
run: rm -rf ./target/criterion | ||
|
||
- name: "Windows | Download PR benchmark results" | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: benchmark-results-windows-latest | ||
path: ./target/criterion | ||
|
||
- name: "Windows | Compare benchmark results" | ||
shell: bash | ||
run: | | ||
echo "#### Windows" >> summary.md | ||
echo "\`\`\`" >> summary.md | ||
critcmp main pr >> summary.md | ||
echo "\`\`\`" >> summary.md | ||
echo "" >> summary.md | ||
|
||
echo ${{ github.event.pull_request.number }} > pr-number | ||
|
||
cat summary.md > $GITHUB_STEP_SUMMARY | ||
|
||
- uses: actions/upload-artifact@v3 | ||
name: Upload PR Number | ||
with: | ||
name: pr-number | ||
path: pr-number | ||
|
||
- uses: actions/upload-artifact@v3 | ||
name: Upload Summary | ||
with: | ||
name: summary | ||
path: summary.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,7 @@ jobs: | |
# Setting RUSTDOCFLAGS because `cargo doc --check` isn't yet implemented (https://github.com/rust-lang/cargo/issues/10025). | ||
RUSTDOCFLAGS: "-D warnings" | ||
- uses: actions/upload-artifact@v3 | ||
if: ${{ matrix.os == 'ubuntu-latest' }} | ||
with: | ||
name: ruff | ||
path: target/debug/ruff | ||
|
@@ -139,27 +140,39 @@ jobs: | |
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.11" | ||
|
||
- uses: actions/download-artifact@v3 | ||
name: Download Ruff binary | ||
id: ruff-target | ||
with: | ||
name: ruff | ||
path: target/debug | ||
|
||
- uses: dawidd6/action-download-artifact@v2 | ||
name: Download base results | ||
with: | ||
name: ruff | ||
branch: ${{ github.event.pull_request.base.ref }} | ||
check_artifacts: true | ||
|
||
- name: Run ecosystem check | ||
run: | | ||
# Make executable, since artifact download doesn't preserve this | ||
chmod +x ruff ${{ steps.ruff-target.outputs.download-path }}/ruff | ||
|
||
scripts/check_ecosystem.py ruff ${{ steps.ruff-target.outputs.download-path }}/ruff | tee ecosystem-result | ||
cat ecosystem-result > $GITHUB_STEP_SUMMARY | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This adds the ecosystem output to the CI job summary |
||
|
||
echo ${{ github.event.number }} > pr-number | ||
|
||
- uses: actions/upload-artifact@v3 | ||
name: Upload PR Number | ||
with: | ||
name: pr-number | ||
path: pr-number | ||
|
||
- uses: actions/upload-artifact@v3 | ||
name: Upload Results | ||
with: | ||
name: ecosystem-result | ||
path: | | ||
ecosystem-result | ||
pr-number | ||
path: ecosystem-result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only need the linux binary. Trying to run this on windows creates a warning because the file is named
ruff.exe
and notruff