[size-report] migrate to GitHub Actions (#11681)

This commit is contained in:
Yakun Xu
2025-07-15 07:01:32 +08:00
committed by GitHub
parent 579d834e0d
commit f4e239e651
2 changed files with 40 additions and 22 deletions
+35 -5
View File
@@ -32,7 +32,7 @@ on:
push:
branches-ignore:
- 'dependabot/**'
pull_request:
pull_request_target:
branches:
- 'main'
@@ -40,12 +40,11 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
size-report:
permissions:
pull-requests: write
runs-on: ubuntu-24.04
steps:
- name: Harden Runner
@@ -56,8 +55,39 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Run
env:
OT_BASE_BRANCH: "${{ github.base_ref }}"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
PR_NUMBER: "${{ github.event.pull_request.number }}"
run: |
./script/check-size
cat /tmp/ot-size-report/report_pr >> $GITHUB_STEP_SUMMARY
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
name: Post Report
if: ${{ github.event_name == 'pull_request' }}
id: post-report
with:
script: |
const fs = require('fs')
const report = fs.readFileSync('/tmp/ot-size-report/report_pr', 'utf8');
const params = {
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: report,
}
const response = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
});
const kMagicHeader = '<!-- Size Report of **OpenThread** -->'
const comment = response.data.find(comment => comment.body.startsWith(kMagicHeader))
if (comment) {
params.comment_id = comment.id;
await github.rest.issues.updateComment(params)
} else {
await github.rest.issues.createComment(params)
}
+5 -17
View File
@@ -44,8 +44,7 @@ readonly OT_REPORT_FILE_TABLE
OT_REPORT_FILE_PR="${OT_TMP_DIR}/report_pr"
readonly OT_REPORT_FILE_TABLE
OT_REPORTER="${OT_SIZE_REPORTER-}"
readonly OT_REPORTER
PR_NUMBER="${PR_NUMBER:-}"
setup_arm_gcc_7()
{
@@ -170,8 +169,10 @@ generate_table_header()
} >>"${OT_REPORT_FILE_TABLE}"
{
printf "# Size Report of **OpenThread**\n"
printf "Merging PR into main\n\n"
printf "<!-- Size Report of **OpenThread** -->\n"
if [[ -n $PR_NUMBER ]]; then
printf "> Merging #%s into %s\n\n" "${PR_NUMBER}" "${GITHUB_BASE_REF}"
fi
printf "| name | branch | text | data | bss | total |\n"
printf "| :----: | :------: | -----: | ----: | ---: | ----: |\n"
} >>"${OT_REPORT_FILE_PR}"
@@ -181,11 +182,6 @@ generate_table_header()
printf "| name | branch | text | data | bss | total |\n"
printf "| :----: | :------: | -----: | ----: | ---: | ----: |\n"
} >>"${OT_REPORT_FILE_PR}_libs"
if [ -n "${OT_REPORTER}" ]; then
"${OT_REPORTER}" init OpenThread
fi
}
generate_size_diff()
@@ -255,10 +251,6 @@ generate_size_diff()
printf "| %+d | %+d | %+d | %+d |" "${size_diff[0]}" "${size_diff[1]}" "${size_diff[2]}" "${size_diff[3]}"
printf "\n"
} >>"${pr_report_file}"
if [ -n "${OT_REPORTER}" ]; then
"${OT_REPORTER}" size "${old_file}" "${new_file}"
fi
}
generate_report()
@@ -295,10 +287,6 @@ finalize_report()
printf "</details>" >>${OT_REPORT_FILE_PR}_libs
cat "${OT_REPORT_FILE_PR}_libs" >>${OT_REPORT_FILE_PR}
if [ -n "${OT_REPORTER}" ]; then
"${OT_REPORTER}" post
fi
}
size_nrf52840()