Skip to content

Commit be855ae

Browse files
CI: Enable manual triggers for size diff workflow. (#282)
Also add arm-none-eabi-size output to job summary.
1 parent 75591e9 commit be855ae

File tree

1 file changed

+38
-6
lines changed

1 file changed

+38
-6
lines changed

.github/workflows/size-diff.yml

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ on:
55
branches: '*'
66
push:
77
branches: '*'
8+
workflow_dispatch:
9+
inputs:
10+
old-commit:
11+
description: 'Base/old commit to compare against the branch HEAD or new-commit below'
12+
required: true
13+
new-commit:
14+
description: '(Optional) New commit to use instead of branch HEAD'
15+
required: false
16+
default: ''
817

918
jobs:
1019
size-diff:
@@ -39,6 +48,9 @@ jobs:
3948
with:
4049
path: libraries/codal-microbit-v2
4150
fetch-depth: '0'
51+
# Unless manually triggered via workflow_dispatch this will be an empty
52+
# string, checking out the default commit for the commit/branch/PR
53+
ref: ${{ github.event.inputs.new-commit }}
4254
# Changing the commit SHA might be unnecessary, as we've already cloned this
4355
# repo, but could be useful to ensure codal.json points to the same commit
4456
- name: Modify files to use BLE & this codal-microbit-v2 commit
@@ -79,15 +91,24 @@ jobs:
7991
echo "${{ github.event.pull_request.base.sha }}"
8092
echo "GIT_BASE_SHA=${{ github.event.pull_request.base.sha }}" >> $GITHUB_ENV
8193
echo "# Bloaty comparison with PR base commit" >> $GITHUB_STEP_SUMMARY
82-
echo "Base commit: ${{ github.event.pull_request.base.sha }}" >> $GITHUB_STEP_SUMMARY
94+
echo "Base commit: [${{ github.event.pull_request.base.sha }}](https://github.com/${GITHUB_REPOSITORY}/commit/${{ github.event.pull_request.base.sha }})" >> $GITHUB_STEP_SUMMARY
95+
- name: "Manual trigger only: Get input commits"
96+
if: ${{ github.event_name == 'workflow_dispatch' }}
97+
run: |
98+
echo "${{ github.event.inputs.old-commit }}"
99+
echo "GIT_BASE_SHA=${{ github.event.inputs.old-commit }}" >> $GITHUB_ENV
100+
echo "# Bloaty comparison with input commit(s)" >> $GITHUB_STEP_SUMMARY
101+
echo "Old commit: [${{ github.event.inputs.old-commit }}](https://github.com/${GITHUB_REPOSITORY}/commit/${{ github.event.inputs.old-commit }})" >> $GITHUB_STEP_SUMMARY
102+
echo "New commit: [${{ github.event.inputs.new-commit || github.sha }}](https://github.com/${GITHUB_REPOSITORY}/commit/${{ github.event.inputs.new-commit || github.sha}})" >> $GITHUB_STEP_SUMMARY
103+
echo "Full diff: https://github.com/${GITHUB_REPOSITORY}/compare/${{ github.event.inputs.old-commit }}...${{ github.event.inputs.new-commit || github.sha}}" >> $GITHUB_STEP_SUMMARY
83104
- name: "Commit only: Get parent commit SHA"
84-
if: ${{ ! github.event.pull_request.base.sha }}
105+
if: ${{ ! github.event.pull_request.base.sha && github.event_name != 'workflow_dispatch'}}
85106
run: |
86107
cd libraries/codal-microbit-v2
87108
echo "$(git log --pretty=%P -n 1 HEAD^0)"
88109
echo "GIT_BASE_SHA=$(git log --pretty=%P -n 1 HEAD^0)" >> $GITHUB_ENV
89110
echo "# Bloaty comparison with parent commit" >> $GITHUB_STEP_SUMMARY
90-
echo "Parent commit: $(git log --pretty=%P -n 1 HEAD^0)" >> $GITHUB_STEP_SUMMARY
111+
echo "Parent commit: [$(git log --pretty=%P -n 1 HEAD^0)](https://github.com/${GITHUB_REPOSITORY}/commit/$(git log --pretty=%P -n 1 HEAD^0))" >> $GITHUB_STEP_SUMMARY
91112
# We don't need to update codal.json because we've kept the
92113
# codal-microbit-v2 repo and we manually check out the right base commit
93114
- name: Checkout parent/base commit of codal-microbit-v2
@@ -105,15 +126,26 @@ jobs:
105126
id: bloaty-comparison
106127
uses: carlosperate/bloaty-action@v1
107128
with:
108-
bloaty-args: -s vm original-build/MICROBIT.elf -- build/MICROBIT
129+
bloaty-args: -d compileunits --domain=vm original-build/MICROBIT.elf -- build/MICROBIT
109130
output-to-summary: true
131+
summary-title: "Bloaty diff between the two commits"
132+
# Show total memory consumption of the main memory sections
133+
- name: Show memory usage in summary using size
134+
run: |
135+
echo '# This commit total memory usage' >> $GITHUB_STEP_SUMMARY
136+
echo '## GNU size' >> $GITHUB_STEP_SUMMARY
137+
echo '```' >> $GITHUB_STEP_SUMMARY
138+
echo '$ arm-none-eabi-size original-build/MICROBIT.elf' >> $GITHUB_STEP_SUMMARY
139+
echo '' >> $GITHUB_STEP_SUMMARY
140+
arm-none-eabi-size original-build/MICROBIT.elf >> $GITHUB_STEP_SUMMARY
141+
echo '```' >> $GITHUB_STEP_SUMMARY
110142
# Then show memory consumption of top 30 components for this build
111143
- name: Run Bloaty to view ELF file full info
112144
uses: carlosperate/bloaty-action@v1
113145
with:
114-
bloaty-args: original-build/MICROBIT.elf -d compileunits -n 30 -s vm
146+
bloaty-args: -d compileunits --domain=vm -n 30 original-build/MICROBIT.elf
115147
output-to-summary: true
116-
- name: Add comment to PR with the bloaty diff
148+
- name: "PR only: Add comment to PR with the bloaty diff"
117149
if: ${{ github.event.pull_request }}
118150
continue-on-error: true
119151
uses: actions/github-script@v6

0 commit comments

Comments
 (0)