Add bundle size reports to the PR description (#5280)
This commit is contained in:
Родитель
9a24fdae2b
Коммит
8def4c2f5a
|
@ -2,7 +2,7 @@
|
|||
|
||||
[ci.yml](./ci.yml) contains the [GitHub workflow](https://docs.github.com/en/get-started/getting-started-with-git/git-workflows) definition for presubmit tests in this repository.
|
||||
|
||||
All Pull Requests in this repository must pass the checks in this workflow before being merged into the `main` branch. The checks are distributed across several jobs. Each job runs on a seprate build agent. Most of them can run concurrently.
|
||||
All Pull Requests in this repository must pass the checks in this workflow before being merged into the `main` branch. The checks are distributed across several jobs. Each job runs on a separate build agent. Most of them can run concurrently.
|
||||
|
||||
Many of checks build and test the library code in both the [`beta` and `stable` build flavors](../../docs/references/beta-only-features.md). For such jobs, we use a [job matrix](https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs) to run an instance of the job for each build flavor. The following high-level description of the checks calls out which checks are build-flavor aware.
|
||||
|
||||
|
@ -38,6 +38,6 @@ Many of checks build and test the library code in both the [`beta` and `stable`
|
|||
|
||||
- Informational jobs to track jest tests coverage (`compare_jest_tests_coverage`, `update_jest_coverage_report`): These jobs track the jest tests coverage (lines, functions, statements, branches) for `@azure/communication-react` built in the previous steps. Any differences in the coverage are reported as Pull Request comments, _but do not block Pull Request from being merged_. This jobs are build flavor aware.
|
||||
|
||||
- Informational jobs to track sample bundle size (`compare_base_bundle_stats`, `update_base_bundle_report`): These jobs track the expected bundle size of the sample applications built in the previous steps. Any differences in the size are reported as Pull Request comments, _but do not block Pull Request from being merged_. This job is not build flavor aware.
|
||||
- Informational jobs to track sample bundle size (`compare_base_bundle_stats`, `update_base_bundle_report`): These jobs track the expected bundle size of the sample applications built in the previous steps. Any differences in the size are reported as Pull Request comments. If the differences are above a threshold, it will block the Pull Request from being merged. Pull Request owners can add a `significant bundle size change` tag to unblock the merge. This job is not build flavor aware.
|
||||
|
||||
- `check_failure`: This is a meta-job that only applies to _post-submit_ workflow run (which re-uses the same `ci.yml` definition). It opens a new GitHub issue in the repository if any fundamental step in the jobs above fails on post-submit workflow run, because it indicates a problem with the CI infrastructure or a bug in the product on `main`. This job is not build flavor aware.
|
||||
|
|
|
@ -817,18 +817,46 @@ jobs:
|
|||
issue-number: ${{ github.event.pull_request.number }}
|
||||
comment-author: 'github-actions[bot]'
|
||||
body-includes: '## ${{ matrix.app }} bundle size is'
|
||||
- name: Create or update comment
|
||||
uses: peter-evans/create-or-update-comment@v2
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Delete existing comment
|
||||
uses: actions/github-script@v4
|
||||
with:
|
||||
comment-id: ${{ steps.fc.outputs.comment-id }}
|
||||
issue-number: ${{ github.event.pull_request.number }}
|
||||
body: |
|
||||
## ${{ matrix.app }} bundle size is ***${{ steps.bundles.outputs.change }}***.
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const commentId = '${{ steps.fc.outputs.comment-id }}'
|
||||
if (commentId) {
|
||||
await github.issues.deleteComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
comment_id: commentId
|
||||
})
|
||||
}
|
||||
- name: Post new comment
|
||||
uses: actions/github-script@v4
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
await github.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
body: `## ${{ matrix.app }} bundle size is ***${{ steps.bundles.outputs.change }}***.
|
||||
- Current size: ${{ steps.bundles.outputs.current_size }}
|
||||
- Base size: ${{ steps.bundles.outputs.base_size}}
|
||||
- Diff size: ${{ steps.bundles.outputs.diff}}
|
||||
edit-mode: replace
|
||||
|
||||
- Base size: ${{ steps.bundles.outputs.base_size }}
|
||||
- Diff size: ${{ steps.bundles.outputs.diff }}`
|
||||
});
|
||||
- name: Check whether the bundle size is increased significantly
|
||||
if: ${{ github.event_name == 'pull_request' && !contains( github.event.pull_request.labels.*.name, 'significant bundle size change') }}
|
||||
run: |
|
||||
significantBundleSizeThreshold=800
|
||||
app="${{ matrix.app }}"
|
||||
bundleSizeDiff="${{ steps.bundles.outputs.diff }}"
|
||||
if [ "$bundleSizeDiff" -ge "$significantBundleSizeThreshold" ]; then
|
||||
echo "The bundle size diff for $app is greater than the threshold of $significantBundleSizeThreshold kb! If the bundle size increase is intended, please add \`significant bundle size change\` label to the PR." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "Bundle size diff for $app is below the threshold of $significantBundleSizeThreshold. All is good!"
|
||||
update_base_bundle_report:
|
||||
runs-on: ubuntu-latest
|
||||
name: Upload bundle size report to gist - ${{ matrix.app }}
|
||||
|
|
Загрузка…
Ссылка в новой задаче