Run iOS size test on CI through Bazel (#1122)

This commit is contained in:
Bart Louwers
2023-05-12 11:22:21 +02:00
committed by GitHub
parent 2dc560c589
commit 72a1f78647
9 changed files with 226 additions and 36 deletions

View File

@@ -114,11 +114,13 @@ jobs:
ccache --max-size=2G
ccache --show-stats
- name: Install iOS packaging dependencies
run: |
./platform/ios/scripts/install-packaging-dependencies.sh
- name: Save PR number
if: github.event_name == 'pull_request'
working-directory: ./
env:
CILAUNCH: true
PR_NUMBER: ${{ github.event.number }}
run: |
echo $PR_NUMBER > ./pr_number
- name: Check debug symbols
run: make darwin-check-public-symbols
@@ -132,6 +134,24 @@ jobs:
- name: Running ios UI tests
run: make ios-uitest
# size test
- name: Build app for size test & output size
working-directory: ./
run: |
bazelisk build --compilation_mode=opt //platform/ios:size
cp $(bazel cquery --compilation_mode=opt --output=files //platform/ios:size) ./size
- name: Upload size test result
uses: actions/upload-artifact@v3
with:
name: size-test-result
path: |
./size
./pr_number
# ---
- name: Build and run SDK unit tests with thread and undefined behavior sanitizers
run: make ios-sanitize

View File

@@ -1,4 +1,4 @@
name: upload-render-test-results
name: pr-upload-render-test-result
permissions:
pull-requests: write # This is required to leave a comment on the PR
@@ -11,7 +11,7 @@ on:
- completed
jobs:
upload-render-test-results:
upload-render-test-result:
runs-on: ubuntu-22.04
if: github.event.workflow_run.event == 'pull_request'
steps:

View File

@@ -0,0 +1,85 @@
name: pr-size-test-result
on:
workflow_run:
workflows: [ios-ci]
types:
- completed
jobs:
comment-on-pr:
runs-on: ubuntu-22.04
steps:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run
# TODO: de-duplicate with re-usable action
- name: 'Download size-test-result artifact'
uses: actions/github-script@v6
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "size-test-result"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/size-test-result.zip`, Buffer.from(download.data));
- name: 'Unzip render-test-result artifact'
run: unzip size-test-result.zip
- name: Show directory structure
run: ls -R
# Move ./size artifact to ./size_main and store as cache
- run: mv size size_main
if: github.event.workflow_run.event != 'pull_request'
- name: Save size
if: github.event.workflow_run.event != 'pull_request'
uses: actions/cache/save@v3
with:
path: |
size_main
key: ios-size
# Restore cache so we can output the difference
- name: Restore size
if: github.event.workflow_run.event == 'pull_request'
uses: actions/cache/restore@v3
with:
path: |
size_main
key: ios-size
- run: |
echo pr_number="$(cat ./pr_number)" >> "$GITHUB_ENV"
echo old_size="$(cat ./size_main)" >> "$GITHUB_ENV"
echo new_size="$(cat ./size)" >> "$GITHUB_ENV"
echo percentage_change=$(awk 'NR==FNR{a=$0;next}{printf "%+.2f%%\n", 100*($0-a)/a}' $new_size $old_size) >> "$GITHUB_ENV"
if: github.event.workflow_run.event == 'pull_request'
- name: 'Leave comment on PR with test results'
if: github.event.workflow_run.event == 'pull_request'
uses: marocchino/sticky-pull-request-comment@v2
with:
number: ${{ env.pr_number }}
hide_and_recreate: true
hide_classify: "OUTDATED"
message: |
### Size test result
Old size: ${{ env.old_size }} bytes
New size: ${{ env.new_size }} bytes
Difference: **${{ env.percentage_change }}**