mirror of
https://github.com/hathach/tinyusb.git
synced 2026-03-15 03:54:44 +00:00
Merge pull request #3540 from michael-membrowse/membrowse_commit
MemBrowse: PR comment github workflow with message template
This commit is contained in:
38
.github/membrowse_pr_message.j2
vendored
Normal file
38
.github/membrowse_pr_message.j2
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
{#- Top 10 targets with biggest memory changes + project dashboard link -#}
|
||||
{% set section_columns = ['.text', '.rodata', '.data', '.bss'] -%}
|
||||
{#- --- Compute per-target total absolute delta and collect changed targets --- -#}
|
||||
{% set changed = [] -%}
|
||||
{% for target in targets -%}
|
||||
{% if target.has_changes -%}
|
||||
{% set ns = namespace(total_delta=0, total_current=0) -%}
|
||||
{% for region in target.regions -%}
|
||||
{% set ns.total_delta = ns.total_delta + region.delta -%}
|
||||
{% set ns.total_current = ns.total_current + region.used_size -%}
|
||||
{% endfor -%}
|
||||
{% set total_old = ns.total_current - ns.total_delta -%}
|
||||
{% set pct = (ns.total_delta / total_old * 100) if total_old > 0 else 0 -%}
|
||||
{% set abs_pct = (ns.total_delta | abs) if total_old == 0 else (pct | abs) -%}
|
||||
{% set _ = changed.append({'target': target, 'total_current': ns.total_current, 'total_old': total_old, 'total_delta': ns.total_delta, 'pct': pct, 'abs_pct': abs_pct}) -%}
|
||||
{% endif -%}
|
||||
{% endfor -%}
|
||||
{#- --- Sort by absolute percentage change descending and take top 10 --- -#}
|
||||
{% set sorted_changed = changed | sort(attribute='abs_pct', reverse=true) -%}
|
||||
{% set top10 = sorted_changed[:10] -%}
|
||||
{#- --- Render --- -#}
|
||||
{% if top10 %}
|
||||
### Top {{ top10 | length }} targets by memory change (%) (out of {{ targets | length }} targets) {% if dashboard_url %} [View Project Dashboard →]({{ dashboard_url }}){% endif %}
|
||||
|
||||
| target | .text | .rodata | .data | .bss | total | % diff |
|
||||
|--------|-------|---------|-------|------|-------|--------|
|
||||
{% for info in top10 -%}
|
||||
{% set target = info.target -%}
|
||||
{% set section_map = {} -%}
|
||||
{% for section in target.sections -%}
|
||||
{% set _ = section_map.update({section.name: section}) -%}
|
||||
{% endfor -%}
|
||||
| {% if target.comparison_url %}[{{ target.name }}]({{ target.comparison_url }}){% else %}{{ target.name }}{% endif %} |
|
||||
{%- for col in section_columns %} {% if col in section_map %}{{ "{:,}".format(section_map[col].old.size) }} → {{ "{:,}".format(section_map[col].size) }} ({{ section_map[col].delta_str }}){% else %}—{% endif %} |{% endfor %} {{ "{:,}".format(info.total_old) }} → {{ "{:,}".format(info.total_current) }} ({% if info.total_delta >= 0 %}+{{ "{:,}".format(info.total_delta) }}{% else %}{{ "{:,}".format(info.total_delta) }}{% endif %}) | {% if info.total_old > 0 %}{% if info.pct >= 0 %}+{% endif %}{{ "%.1f" | format(info.pct) }}%{% else %}N/A{% endif %} |
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
No memory changes detected across {{ targets | length }} target{{ 's' if targets | length != 1 else '' }}.{% if dashboard_url %} [View Project Dashboard →]({{ dashboard_url }}){% endif %}
|
||||
{% endif -%}
|
||||
19
.github/workflows/membrowse-comment.yml
vendored
19
.github/workflows/membrowse-comment.yml
vendored
@ -11,28 +11,21 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
if: >
|
||||
github.event.workflow_run.event == 'pull_request' &&
|
||||
github.event.workflow_run.conclusion != 'cancelled'
|
||||
github.event.workflow_run.conclusion == 'success'
|
||||
permissions:
|
||||
contents: read
|
||||
actions: read
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Download Artifacts
|
||||
id: download
|
||||
uses: actions/download-artifact@v5
|
||||
with:
|
||||
run-id: ${{ github.event.workflow_run.id }}
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
name: membrowse-comment
|
||||
path: reports
|
||||
continue-on-error: true
|
||||
|
||||
- name: Post Membrowse PR comment
|
||||
if: steps.download.outcome == 'success'
|
||||
if: ${{ secrets.MEMBROWSE_API_KEY != '' }}
|
||||
uses: membrowse/membrowse-action/comment-action@v1
|
||||
with:
|
||||
json_files: 'reports/*.json'
|
||||
api_key: ${{ secrets.MEMBROWSE_API_KEY }}
|
||||
commit: ${{ github.event.workflow_run.head_sha }}
|
||||
comment_template: .github/membrowse_pr_message.j2
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
Reference in New Issue
Block a user