Internals: Post RTLMeter metrics in PR comment (#6349)

Fixes #6301
This commit is contained in:
Geza Lore 2025-08-31 20:52:43 +01:00 committed by GitHub
parent 5bdc9abd2f
commit 68ce45f203
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 94 additions and 48 deletions

View File

@ -242,55 +242,101 @@ jobs:
git commit -m "Verilator CI: Results of 'RTLMeter' workflow run #${{ github.run_number }}" git commit -m "Verilator CI: Results of 'RTLMeter' workflow run #${{ github.run_number }}"
git push origin git push origin
#publish-pr-results: prepare-pr-results:
# name: Publish results to Pull Request name: Prepare Pull Request results
# needs: combine-results needs: combine-results
# if: ${{ github.event_name == 'pull_request' && github.repository == 'verilator/verilator' && github.run_attempt == 1 && contains(needs.*.result, 'success') && !cancelled() }} if: ${{ github.event_name == 'pull_request' && github.repository == 'verilator/verilator' && contains(needs.*.result, 'success') && !cancelled() }}
# runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
# steps: permissions:
# - name: Checkout RTLMeter actions: read
# uses: actions/checkout@v4 steps:
# with: - name: Checkout RTLMeter
# repository: "verilator/rtlmeter" uses: actions/checkout@v4
# path: rtlmeter with:
# - name: Setup RTLMeter venv repository: "verilator/rtlmeter"
# working-directory: rtlmeter path: rtlmeter
# run: make venv - name: Setup RTLMeter venv
# - name: Download combined results working-directory: rtlmeter
# uses: actions/download-artifact@v4 run: make venv
# with: - name: Download combined results
# pattern: all-results-* uses: actions/download-artifact@v4
# path: all-results with:
# merge-multiple: true pattern: all-results-*
# - name: Get scheduled run info path: all-results
# id: scheduled-info merge-multiple: true
# run: - name: Get scheduled run info
# IDLATEST=$(gh run list --workflow RTLMeter --event schedule --status success --limit 1 --json databaseId --jq ".[0].databaseId") id: scheduled-info
# echo "id=$IDLATEST" >> $GITHUB_OUTPUT env:
# URL=$(gh run view $IDLATEST --json url --jq ".url") GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# echo "url=$URL" >> $GITHUB_OUTPUT run: |
# NUM=$(gh run view $IDLATEST --json number --jq ".number") ID=$(gh run --repo ${{ github.repository }} list --workflow RTLMeter --event schedule --status success --limit 1 --json databaseId --jq ".[0].databaseId")
# echo "num=$NUM" >> $GITHUB_OUTPUT echo "id=$ID" >> $GITHUB_OUTPUT
# # Fetching artifacts from different workflow requires elevated privilege URL=$(gh run --repo ${{ github.repository }} view $ID --json url --jq ".url")
# - name: Generate access token echo "url=$URL" >> $GITHUB_OUTPUT
# id: generate-token NUM=$(gh run --repo ${{ github.repository }} view $ID --json number --jq ".number")
# uses: actions/create-github-app-token@v2.0.6 echo "num=$NUM" >> $GITHUB_OUTPUT
# with: DATE=$(gh run --repo ${{ github.repository }} view $ID --json createdAt --jq ".createdAt")
# app-id: ${{ vars.VERILATOR_CI_ID }} echo "date=$DATE" >> $GITHUB_OUTPUT
# private-key: ${{ secrets.VERILATOR_CI_KEY }} - name: Download scheduled run results
# owner: verilator uses: actions/download-artifact@v4
# repositories: verilator with:
# permission-actions: read name: published-results
# - name: Download scheduled run results path: nightly-results
# uses: actions/download-artifact@v4 run-id: ${{ steps.scheduled-info.outputs.id }}
# with: github-token: ${{ secrets.GITHUB_TOKEN }}
# name: published-results - name: Compare results
# path: nightly-results working-directory: rtlmeter
# run-id: ${{ steps.schedueld-info.outputs.id }} run: |
# github-token: ${{ steps.generate-token.outputs.token }} ADATA=../nightly-results/all-results-gcc.json
# # TODO: diff and present BDATA=../all-results/all-results-gcc.json
./rtlmeter compare --steps "verilate" --metrics "elapsed memory" $ADATA $BDATA > ../verilate.txt
cat ../verilate.txt
./rtlmeter compare --steps "execute" --metrics "speed memory elapsed" $ADATA $BDATA > ../execute.txt
cat ../execute.txt
./rtlmeter compare --steps "cppbuild" --metrics "elapsed memory cpu codeSize" $ADATA $BDATA > ../cppbuild.txt
cat ../cppbuild.txt
- name: Create report
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -x
awk -v RS= '{print > sprintf("verilate-%02d.txt",NR)}' verilate.txt
awk -v RS= '{print > sprintf( "execute-%02d.txt",NR)}' execute.txt
awk -v RS= '{print > sprintf("cppbuild-%02d.txt",NR)}' cppbuild.txt
NUM=$(gh run --repo ${{ github.repository }} view ${{ github.run_id }} --json number --jq ".number")
URL=$(gh run --repo ${{ github.repository }} view ${{ github.run_id }} --json url --jq ".url")
echo -n "Performance metrics for PR workflow [#$NUM]($URL) (B) compared to scheduled run" > report.txt
echo -n " [#${{ steps.scheduled-info.outputs.num }}](${{ steps.scheduled-info.outputs.url }}) (A)" >> report.txt
echo " from ${{ steps.scheduled-info.outputs.date }}:" >> report.txt
for f in $(ls -1 verilate-*.txt | sort) $(ls -1 execute-*.txt | sort) $(ls -1 cppbuild-*.txt | sort); do
if [[ $f == verilate-01.txt || $f == execute-01.txt ]]; then
echo "<details open>" >> report.txt
else
echo "<details>" >> report.txt
fi
echo -n "<summary>" >> report.txt
head -n 1 $f | tr -d '\n' >> report.txt
echo "</summary>" >> report.txt
echo '<pre>' >> report.txt
tail -n +2 $f >> report.txt
echo '</pre>' >> report.txt
echo "</details>" >> report.txt
done
cat report.txt
- name: Upload report
uses: actions/upload-artifact@v4
with:
path: report.txt
name: rtlmeter-pr-results
- name: Save PR number
run: echo ${{ github.event.number }} > pr-number.txt
- name: Upload PR number
uses: actions/upload-artifact@v4
with:
path: pr-number.txt
name: pr-number
# Create GitHub issue for failed schedueld jobs # Create GitHub issue for failed scheduled jobs
# This should always be the last job (we want an issue if anything breaks) # This should always be the last job (we want an issue if anything breaks)
create-issue: create-issue:
name: Create issue on failure name: Create issue on failure