NTP-1234 | GHA | Singular Comment for APK Diff Workflow (#13493)
This commit is contained in:
8
.github/workflows/android_build.yml
vendored
8
.github/workflows/android_build.yml
vendored
@@ -33,14 +33,10 @@ jobs:
|
||||
if: github.event_name == 'pull_request' && github.base_ref == 'master'
|
||||
uses: ./.github/workflows/generate_apk_diff.yml
|
||||
needs: build-qa-debug
|
||||
secrets:
|
||||
AWS_ACCESS_KEY_GITHUB_CACHE: ${{ secrets.AWS_ACCESS_KEY_GITHUB_CACHE }}
|
||||
AWS_SECRET_KEY_GITHUB_CACHE: ${{ secrets.AWS_SECRET_KEY_GITHUB_CACHE }}
|
||||
secrets: inherit
|
||||
|
||||
upload-apk-to-s3:
|
||||
if: github.event_name == 'push' && github.ref_name == 'master'
|
||||
uses: ./.github/workflows/upload_file.yml
|
||||
needs: build-qa-debug
|
||||
secrets:
|
||||
AWS_ACCESS_KEY_GITHUB_CACHE: ${{ secrets.AWS_ACCESS_KEY_GITHUB_CACHE }}
|
||||
AWS_SECRET_KEY_GITHUB_CACHE: ${{ secrets.AWS_SECRET_KEY_GITHUB_CACHE }}
|
||||
secrets: inherit
|
||||
|
||||
51
.github/workflows/generate_apk_diff.yml
vendored
51
.github/workflows/generate_apk_diff.yml
vendored
@@ -2,47 +2,33 @@ name: APK Size Difference CI
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
secrets:
|
||||
AWS_ACCESS_KEY_GITHUB_CACHE:
|
||||
description: Access Key
|
||||
required: true
|
||||
AWS_SECRET_KEY_GITHUB_CACHE:
|
||||
description: Secret Key
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
generate-apk-diff:
|
||||
runs-on: [ default ]
|
||||
defaults:
|
||||
run:
|
||||
working-directory: android
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Clear Cache
|
||||
run: sudo rm -rf ~/Python
|
||||
- name: Download Artifact
|
||||
id: download
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: app-qa-debug
|
||||
- name: Echo Download Path
|
||||
run: echo ${{steps.download.outputs.download-path}}
|
||||
- name: List Files
|
||||
run: ls -R ${{steps.download.outputs.download-path}}
|
||||
path: current
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.9.7'
|
||||
- name: Install dependencies
|
||||
run: pip install -r ../.github/actions/s3_file_transfer/dependencies.txt
|
||||
run: pip install -r .github/actions/s3_file_transfer/dependencies.txt
|
||||
- name: Download File
|
||||
run: python ../.github/actions/s3_file_transfer/script.py download ${{ secrets.AWS_ACCESS_KEY_GITHUB_CACHE }} ${{ secrets.AWS_SECRET_KEY_GITHUB_CACHE }} android/app/build/outputs/apk/dev/debug/latest_build.apk
|
||||
run: python .github/actions/s3_file_transfer/script.py download ${{ secrets.AWS_ACCESS_KEY_GITHUB_CACHE }} ${{ secrets.AWS_SECRET_KEY_GITHUB_CACHE }} previous/apk_from_bundle/qaDebug/app-qa-debug-universal.apk
|
||||
- name: Compare APK Size Difference
|
||||
id: apk-diff
|
||||
run: |
|
||||
previous_apk_path="android/app/build/outputs/apk/dev/debug/latest_build.apk"
|
||||
current_apk_path="${{steps.download.outputs.download-path}}/apk_from_bundle/qaDebug/app-qa-debug-universal.apk"
|
||||
previous_apk_path="previous/apk_from_bundle/qaDebug/app-qa-debug-universal.apk"
|
||||
current_apk_path="current/apk_from_bundle/qaDebug/app-qa-debug-universal.apk"
|
||||
previous_apk_size=$(stat -c %s $previous_apk_path)
|
||||
current_apk_size=$(stat -c %s $current_apk_path)
|
||||
size_diff=$((current_apk_size - previous_apk_size))
|
||||
@@ -63,6 +49,7 @@ jobs:
|
||||
- name: Write PR Comment
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
github-token: ${{ secrets.GH_ANDROID_BOT_PAT }}
|
||||
script: |
|
||||
const sizeDiff = ${{ steps.apk-diff.outputs.size_diff }};
|
||||
const apkSizeDifferenceInKilobytes = Math.round(sizeDiff / 1024);
|
||||
@@ -84,18 +71,32 @@ jobs:
|
||||
comment = `### :exclamation: APK Size Exceeded Limit
|
||||
The APK size has increased by ${apkSizeDifferenceInKilobytes}KB compared to the previous version. Please provide the justification for this increase.
|
||||
${additionalInfo}`;
|
||||
|
||||
github.rest.issues.createComment({
|
||||
} else if (apkSizeDifferenceInKilobytes > 100) {
|
||||
comment = `### :warning: APK Size Warning
|
||||
The APK size has increased by ${apkSizeDifferenceInKilobytes}KB compared to the previous version. Please provide the justification for this increase.
|
||||
${additionalInfo}`;
|
||||
} else {
|
||||
comment = `### :white_check_mark: APK Size Within Limit
|
||||
The APK size issue has been resolved, and the size is within acceptable limits.`;
|
||||
}
|
||||
|
||||
const comments = await github.rest.issues.listComments({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
});
|
||||
|
||||
const existingComment = comments.data.find(c => c.body.includes('APK Size'));
|
||||
|
||||
if (existingComment) {
|
||||
github.rest.issues.updateComment({
|
||||
comment_id: existingComment.id,
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: comment
|
||||
});
|
||||
} else if (apkSizeDifferenceInKilobytes > 100) {
|
||||
comment = `### :warning: APK Size Warning
|
||||
The APK size has increased by ${apkSizeDifferenceInKilobytes}KB compared to the previous version. Please provide the justification for this increase.
|
||||
${additionalInfo}`;
|
||||
|
||||
github.rest.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
|
||||
7
.github/workflows/upload_file.yml
vendored
7
.github/workflows/upload_file.yml
vendored
@@ -2,13 +2,6 @@ name: Upload Latest APK to S3 CI
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
secrets:
|
||||
AWS_ACCESS_KEY_GITHUB_CACHE:
|
||||
description: Access Key
|
||||
required: true
|
||||
AWS_SECRET_KEY_GITHUB_CACHE:
|
||||
description: Secret Key
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
Reference in New Issue
Block a user