-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ASV Benchmarking Pull Request Workflow (#831)
* add workflow file, update asv config and enviroment.yml * comment out broken benchmarks for now
- Loading branch information
Showing
4 changed files
with
132 additions
and
18 deletions.
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,107 @@ | ||
name: ASV Benchmarking (PR) | ||
|
||
on: | ||
pull_request: | ||
types: [opened, reopened, synchronize, labeled] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
benchmark: | ||
if: ${{ contains(github.event.pull_request.labels.*.name, 'run-benchmark') && github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} | ||
name: Linux | ||
runs-on: ubuntu-latest | ||
env: | ||
ASV_DIR: "./benchmarks" | ||
CONDA_ENV_FILE: ci/environment.yml | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
|
||
- name: Set up Conda environment | ||
uses: mamba-org/setup-micromamba@v1 | ||
with: | ||
environment-file: ${{env.CONDA_ENV_FILE}} | ||
cache-environment: true | ||
environment-name: uxarray_build | ||
cache-environment-key: "${{runner.os}}-${{runner.arch}}-py${{env.PYTHON_VERSION}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}-benchmark" | ||
create-args: >- | ||
asv | ||
build | ||
mamba | ||
- name: Run Benchmarks | ||
shell: bash -l {0} | ||
id: benchmark | ||
run: | | ||
set -x | ||
# ID this runner | ||
asv machine --yes | ||
echo "Baseline: ${{ github.event.pull_request.base.sha }} (${{ github.event.pull_request.base.label }})" | ||
echo "Contender: ${GITHUB_SHA} (${{ github.event.pull_request.head.label }})" | ||
# Run benchmarks for current commit against base | ||
ASV_OPTIONS="--split --show-stderr" | ||
asv continuous $ASV_OPTIONS ${{ github.event.pull_request.base.sha }} ${GITHUB_SHA} | ||
# Save compare results | ||
asv compare --split ${{ github.event.pull_request.base.sha }} ${GITHUB_SHA} > asv_compare_results.txt | ||
working-directory: ${{ env.ASV_DIR }} | ||
|
||
- uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: asv-benchmark-results-${{ runner.os }} | ||
path: | | ||
${{ env.ASV_DIR }}/results | ||
${{ env.ASV_DIR }}/asv_compare_results.txt | ||
- name: Post or update result comment | ||
id: comment | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const fs = require('fs'); | ||
const compareResults = fs.readFileSync('${{ env.ASV_DIR }}/asv_compare_results.txt', 'utf8'); | ||
const { owner, repo } = context.repo; | ||
const issue_number = context.issue.number; | ||
// Customize the comment content with your action results | ||
const newComment = ` | ||
## ASV Benchmarking | ||
<details> | ||
<summary>Benchmark Comparison Results</summary> | ||
${compareResults} | ||
</details> | ||
`; | ||
// Fetch existing comments on the PR | ||
const { data: comments } = await github.rest.issues.listComments({ | ||
owner, | ||
repo, | ||
issue_number, | ||
}); | ||
// Find if there is an existing comment by this action | ||
const botComment = comments.find(comment => comment.user.login === 'github-actions[bot]'); | ||
if (botComment) { | ||
// Update the existing comment | ||
await github.rest.issues.updateComment({ | ||
owner, | ||
repo, | ||
comment_id: botComment.id, | ||
body: newComment, | ||
}); | ||
} else { | ||
// Create a new comment | ||
await github.rest.issues.createComment({ | ||
owner, | ||
repo, | ||
issue_number, | ||
body: newComment, | ||
}); | ||
} |
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
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
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