TP-00000 | Added Cache Clear And Clean Up Step (#7224)

link: "https://github.com/navi-android/super-app/pull/7224"
This commit is contained in:
Balrambhai Sharma
2023-07-17 14:31:04 +05:30
committed by GitHub
parent f24e893813
commit 19baf9458d
2 changed files with 22 additions and 22 deletions

View File

@@ -1,5 +1,4 @@
name: APK Diff CI
on:
workflow_call:
secrets:
@@ -9,52 +8,45 @@ on:
AWS_SECRET_KEY_GITHUB_CACHE:
description: Secret Key
required: true
jobs:
generate-apk-diff:
runs-on: self-hosted
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Clear Cache
run: |
sudo rm -rf ~/Python
- name: Download Artifact
id: download
uses: actions/download-artifact@v3
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}}
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
python-version: '3.9.7'
- name: Install dependencies
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 }} app/build/outputs/apk/dev/debug/latest_build.apk
- name: Compare APK Size Diff
id: apk-diff
run: |
previous_apk_path="app/build/outputs/apk/dev/debug/latest_build.apk"
current_apk_path="${{steps.download.outputs.download-path}}/universal_apk/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))
echo "::set-output name=size_diff::$size_diff"
echo "The previous value is $previous_apk_size"
echo "The latest value is $current_apk_size"
- name: Check Size Difference
id: size-diff-check
run: |
@@ -66,7 +58,6 @@ jobs:
else
echo "::set-output name=job_status::success"
fi
- name: Write PR Comment
uses: actions/github-script@v6
with:
@@ -77,18 +68,15 @@ jobs:
const codeOwnerTags = codeOwners.join(' '); // Join the code owner usernames with a space
const additionalInfo = `
APK size can increase due to various factors. Some common reasons include:
- Adding external libraries: Before including any external libraries, it's advisable to seek signoff from ${codeOwnerTags}.
- Using high-resolution vectors: For vector XMLs larger than 48dp, consider using WebP format to optimize file size.
- Including Lottie JSON files: When adding Lottie animations, it's recommended to prioritize remote Lottie files over local ones.
- Adding assets/resources: The addition of assets and resources can contribute to APK size growth.
`;
let comment;
if (sizeDiffKB > 70) {
comment = `### :exclamation: APK Size Exceeded Limit
The APK size has increased by ${sizeDiffKB} KB bytes compared to the previous version. Please provide the reasons for this increase cc : ${codeOwnerTags}
The APK size has increased by ${sizeDiffKB} KB compared to the previous version. Please provide the reasons for this increase cc : ${codeOwnerTags}
${additionalInfo}`;
github.rest.issues.createComment({
@@ -100,7 +88,7 @@ jobs:
} else if (sizeDiffKB > 25) {
comment = `### :warning: APK Size Warning
The APK size has increased by ${sizeDiffKB} KB bytes compared to the previous version. Please provide the reasons for this increase cc : ${codeOwnerTags}
The APK size has increased by ${sizeDiffKB} KB compared to the previous version. Please provide the reasons for this increase cc : ${codeOwnerTags}
${additionalInfo}`;
github.rest.issues.createComment({
@@ -110,8 +98,11 @@ jobs:
body: comment
});
}
}
- name: Cleanup
run: |
echo "Cleaning up..."
rm -rf *.tmp
- name: Fail Job if Size Diff Exceeds 70 KB
if: ${{ steps.size-diff-check.outputs.job_status == 'failure' }}
run: exit 1

View File

@@ -19,6 +19,10 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2
- name: Clear Cache
run: |
sudo rm -rf ~/Python
- name: Download Artifact
id: download
uses: actions/download-artifact@v3
@@ -35,10 +39,15 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
python-version: '3.9.7'
- name: Install dependencies
run: pip install -r .github/actions/s3_file_transfer/dependencies.txt
- name: Upload File
run: python ./.github/actions/s3_file_transfer/script.py upload ${{secrets.AWS_ACCESS_KEY_GITHUB_CACHE}} ${{secrets.AWS_SECRET_KEY_GITHUB_CACHE}} ${{steps.download.outputs.download-path}}/universal_apk/qaDebug/app-qa-debug-universal.apk
run: python ./.github/actions/s3_file_transfer/script.py upload ${{secrets.AWS_ACCESS_KEY_GITHUB_CACHE}} ${{secrets.AWS_SECRET_KEY_GITHUB_CACHE}} ${{steps.download.outputs.download-path}}/universal_apk/qaDebug/app-qa-debug-universal.apk
- name: Cleanup
run: |
echo "Cleaning up..."
rm -rf *.tmp