Skip to content

Commit e3c4b6c

Browse files
committed
[size-report] migrate to GitHub Actions
1 parent b876687 commit e3c4b6c

2 files changed

Lines changed: 34 additions & 20 deletions

File tree

.github/workflows/size.yml

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ name: Size
3030

3131
on:
3232
push:
33-
branches-ignore:
34-
- 'dependabot/**'
33+
branches:
34+
- 'main'
3535
pull_request:
3636
branches:
3737
- 'main'
@@ -41,13 +41,14 @@ concurrency:
4141
cancel-in-progress: true
4242

4343
permissions:
44-
issues: write
4544
pull-requests: write
4645
contents: read
4746

4847
jobs:
4948

5049
size-report:
50+
permissions:
51+
pull-requests: write
5152
runs-on: ubuntu-24.04
5253
steps:
5354
- name: Harden Runner
@@ -58,8 +59,37 @@ jobs:
5859
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
5960
- name: Run
6061
env:
61-
OT_BASE_BRANCH: "${{ github.base_ref }}"
6262
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
6363
run: |
6464
./script/check-size
6565
cat /tmp/ot-size-report/report_pr >> $GITHUB_STEP_SUMMARY
66+
- uses: actions/github-script@v7
67+
name: Post Report
68+
if: ${{ github.event_name == 'pull_request' }}
69+
id: post-report
70+
with:
71+
script: |
72+
const fs = require('fs')
73+
74+
const report = fs.readFileSync('/tmp/ot-size-report/report_pr', 'utf8');
75+
const params = {
76+
issue_number: context.issue.number,
77+
owner: context.repo.owner,
78+
repo: context.repo.repo,
79+
body: report,
80+
}
81+
82+
const response = await github.rest.issues.listComments({
83+
issue_number: context.issue.number,
84+
owner: context.repo.owner,
85+
repo: context.repo.repo,
86+
});
87+
88+
const comment = response.data.find(comment => comment.body.includes('# Size Report of **OpenThread**'))
89+
90+
if (comment) {
91+
params.comment_id = comment.id;
92+
await github.rest.issues.updateComment(params)
93+
} else {
94+
await github.rest.issues.createComment(params)
95+
}

script/check-size

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ readonly OT_REPORT_FILE_TABLE
4444
OT_REPORT_FILE_PR="${OT_TMP_DIR}/report_pr"
4545
readonly OT_REPORT_FILE_TABLE
4646

47-
OT_REPORTER="${OT_SIZE_REPORTER-}"
48-
readonly OT_REPORTER
49-
5047
setup_arm_gcc_7()
5148
{
5249
if arm-none-eabi-gcc --version | grep -q 'Arm Embedded Processors 7'; then
@@ -181,11 +178,6 @@ generate_table_header()
181178
printf "| name | branch | text | data | bss | total |\n"
182179
printf "| :----: | :------: | -----: | ----: | ---: | ----: |\n"
183180
} >>"${OT_REPORT_FILE_PR}_libs"
184-
185-
if [ -n "${OT_REPORTER}" ]; then
186-
"${OT_REPORTER}" init OpenThread
187-
fi
188-
189181
}
190182

191183
generate_size_diff()
@@ -255,10 +247,6 @@ generate_size_diff()
255247
printf "| %+d | %+d | %+d | %+d |" "${size_diff[0]}" "${size_diff[1]}" "${size_diff[2]}" "${size_diff[3]}"
256248
printf "\n"
257249
} >>"${pr_report_file}"
258-
259-
if [ -n "${OT_REPORTER}" ]; then
260-
"${OT_REPORTER}" size "${old_file}" "${new_file}"
261-
fi
262250
}
263251

264252
generate_report()
@@ -295,10 +283,6 @@ finalize_report()
295283

296284
printf "</details>" >>${OT_REPORT_FILE_PR}_libs
297285
cat "${OT_REPORT_FILE_PR}_libs" >>${OT_REPORT_FILE_PR}
298-
299-
if [ -n "${OT_REPORTER}" ]; then
300-
"${OT_REPORTER}" post
301-
fi
302286
}
303287

304288
size_nrf52840()

0 commit comments

Comments
 (0)