This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import json | |
# read json file | |
def read_report_file(file_path): | |
with open(file_path, 'r') as file: | |
json_data = json.load(file) | |
return json_data | |
# generate dictionary of the grouped contents of an apk file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Ruler Report | |
# cancel in-progress workflow if new commits are pushed to same head branch | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} | |
cancel-in-progress: true | |
on: | |
pull_request: | |
branches: [ "master", "main", "release/*", "feature/*" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Size Metrics | |
# cancel in-progress workflow if new commits are pushed to same head branch | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} | |
cancel-in-progress: true | |
on: | |
pull_request: | |
branches: [ "master", "main", "release/*", "feature/*" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Size Metrics | |
... | |
# content is omitted as it's already shown earlier | |
... | |
env: | |
size_diff_report_file: apk_size_diff_report.html | |
jobs: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Size Metrics | |
... | |
# content is omitted as it's already shown earlier | |
... | |
env: | |
size_diff_report_file: apk_size_diff_report.html | |
jobs: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# generate html file containing size diff in HRF | |
def generate_size_diff_html(): | |
html = "<html>" | |
html += "<body><h1>Download Size Diff Report</h1><h3>Affected Products</h3>" | |
html += "<ul><li><h4><code>release</code></h4><table>" | |
html += f"<tr><th>Component</th><th>Base ({apk_1_sha})</th><th>Merge ({apk_2_sha})</th><th>Diff</th></tr>" | |
# print diff of each components of both of the apk files | |
for component in set(components_1.keys()) | set(components_2.keys()): | |
size_1 = components_1.get(component, 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# generate dictionary of the grouped contents of an apk file | |
def get_apk_components(apk_file, size_type): | |
command = f"{apk_analyzer_path} files list --{size_type} {apk_file}" | |
files_with_size_string = execute_command(command) | |
files_with_size_list = files_with_size_string.split('\n') | |
components = {} | |
for item in files_with_size_list: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# read arguments passed to this script | |
apk_1_sha = sys.argv[1] | |
apk_2_sha = sys.argv[2] | |
apk_1_name = f"{apk_1_sha}.apk" | |
apk_2_name = f"{apk_2_sha}.apk" | |
# apk_analyzer_path location will change based on the GHA runner that you're using i.e. mac/windows/ubuntu etc | |
apk_analyzer_path = "/usr/local/lib/android/sdk/cmdline-tools/latest/bin/apkanalyzer" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import subprocess | |
# generate dictionary of the grouped contents of an apk file | |
def get_apk_components(apk_file, size_type): | |
command = f"{apk_analyzer_path} files list --{size_type} {apk_file}" | |
files_with_size_string = execute_command(command) | |
files_with_size_list = files_with_size_string.split('\n') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
commit_id=$(git rev-parse HEAD) | |
echo "${commit_id:0:7}" |
NewerOlder