TP-52884 | Gradle | Build Optimizations (#9569)
This commit is contained in:
3
.github/workflows/android_build.yml
vendored
3
.github/workflows/android_build.yml
vendored
@@ -18,9 +18,6 @@ jobs:
|
||||
environment: qa
|
||||
type: debug
|
||||
output: APK
|
||||
secrets:
|
||||
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
|
||||
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
|
||||
|
||||
build-qa-release:
|
||||
if: github.event_name == 'push' && (github.ref_name == 'master' || startsWith(github.ref_name, 'release-'))
|
||||
|
||||
32
.github/workflows/branch_cut.yml
vendored
32
.github/workflows/branch_cut.yml
vendored
@@ -1,20 +1,30 @@
|
||||
name: Release Branch Cut CI
|
||||
name: Branch Cut CI
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version_code:
|
||||
description: App Version Code (e.g., 301)
|
||||
description: Version Code (e.g., 301)
|
||||
required: true
|
||||
type: string
|
||||
version_name:
|
||||
description: App Version Name (e.g., 3.0.1)
|
||||
description: Version Name (e.g., 3.0.1)
|
||||
required: true
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
print-inputs:
|
||||
runs-on: [ default ]
|
||||
steps:
|
||||
- name: Print Inputs
|
||||
run: |
|
||||
echo "| Input Key | Input Value |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| :---: | :---: |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| Version Code | ${{ inputs.version_code }} |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| Version Name | ${{ inputs.version_name }} |" >> $GITHUB_STEP_SUMMARY
|
||||
branch-cut:
|
||||
runs-on: [ default ]
|
||||
needs: [ print-inputs ]
|
||||
environment: RELEASE_BRANCH_CUT
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
@@ -26,13 +36,13 @@ jobs:
|
||||
export GITHUB_EMAIL=$(echo "$GITHUB_ACTOR@navi.com" | sed 's/-/./g' | sed 's/_navi//g')
|
||||
git config --global user.email "$GITHUB_EMAIL"
|
||||
git config --global user.name "$GITHUB_ACTOR"
|
||||
- name: Checkout release-${{ github.event.inputs.version_name }} from ${{ github.ref_name }}
|
||||
run: git checkout -b release-${{ github.event.inputs.version_name }}
|
||||
- name: Update Version Name (${{ github.event.inputs.version_name }}) & Version Code (${{ github.event.inputs.version_code }})
|
||||
- name: Checkout release-${{ inputs.version_name }} from ${{ github.ref_name }}
|
||||
run: git checkout -b release-${{ inputs.version_name }}
|
||||
- name: Update Version Name (${{ inputs.version_name }}) & Version Code (${{ inputs.version_code }})
|
||||
run: |
|
||||
sed -i 's/def VERSION_NAME = "[0-9].*"/def VERSION_NAME = "${{ github.event.inputs.version_name }}"/g' app/build.gradle
|
||||
sed -i 's/def VERSION_CODE = [0-9].*/def VERSION_CODE = ${{ github.event.inputs.version_code }}/g' app/build.gradle
|
||||
sed -i 's/def VERSION_NAME = "[0-9].*"/def VERSION_NAME = "${{ inputs.version_name }}"/g' app/build.gradle
|
||||
sed -i 's/def VERSION_CODE = [0-9].*/def VERSION_CODE = ${{ inputs.version_code }}/g' app/build.gradle
|
||||
- name: Commit Version Changes
|
||||
run: git commit app/build.gradle -m "TP-52887 | Bump Project Version to ${{ github.event.inputs.version_name }} (${{ github.event.inputs.version_code }})"
|
||||
- name: Push release-${{ github.event.inputs.version_name }} Branch
|
||||
run: git push -u origin release-${{ github.event.inputs.version_name }}
|
||||
run: git commit app/build.gradle -m "TP-52887 | Bump Project Version to ${{ inputs.version_name }} (${{ inputs.version_code }})"
|
||||
- name: Push release-${{ inputs.version_name }} Branch
|
||||
run: git push -u origin release-${{ inputs.version_name }}
|
||||
|
||||
8
.github/workflows/generate_apk_diff.yml
vendored
8
.github/workflows/generate_apk_diff.yml
vendored
@@ -43,7 +43,7 @@ jobs:
|
||||
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 "size_diff=$size_diff" >> $GITHUB_OUTPUT
|
||||
echo "The previous value is $previous_apk_size"
|
||||
echo "The latest value is $current_apk_size"
|
||||
- name: Check Size Difference
|
||||
@@ -51,11 +51,11 @@ jobs:
|
||||
run: |
|
||||
size_diff=${{ steps.apk-diff.outputs.size_diff }}
|
||||
if [[ $size_diff -gt 204800 ]]; then
|
||||
echo "::set-output name=job_status::failure"
|
||||
echo "job_status=failure" >> $GITHUB_OUTPUT
|
||||
elif [[ $size_diff -gt 102400 ]]; then
|
||||
echo "::set-output name=job_status::warning"
|
||||
echo "job_status=warning" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "::set-output name=job_status::success"
|
||||
echo "job_status=success" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
- name: Write PR Comment
|
||||
uses: actions/github-script@v7
|
||||
|
||||
53
.github/workflows/generate_build.yml
vendored
53
.github/workflows/generate_build.yml
vendored
@@ -4,55 +4,48 @@ on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
environment:
|
||||
description: Choose build environment
|
||||
description: Build Environment
|
||||
required: true
|
||||
type: choice
|
||||
options:
|
||||
- qa
|
||||
- dev
|
||||
type:
|
||||
description: Choose build type
|
||||
description: Build Type
|
||||
required: true
|
||||
type: choice
|
||||
options:
|
||||
- debug
|
||||
- release
|
||||
output:
|
||||
description: Choose output type
|
||||
description: Build Output
|
||||
required: true
|
||||
type: choice
|
||||
options:
|
||||
- APK
|
||||
- AAB
|
||||
version_code:
|
||||
description: Enter app version code (example, 292)
|
||||
description: Version Code (e.g., 301)
|
||||
required: false
|
||||
type: string
|
||||
version_name:
|
||||
description: Enter app version name (example, 3.2.1)
|
||||
description: Version Name (e.g., 3.0.1)
|
||||
required: false
|
||||
type: string
|
||||
workflow_call:
|
||||
inputs:
|
||||
environment:
|
||||
description: Build environment passed from caller workflow
|
||||
description: Build Environment passed from caller workflow
|
||||
required: true
|
||||
type: string
|
||||
type:
|
||||
description: Build type passed from caller workflow
|
||||
description: Build Type passed from caller workflow
|
||||
required: true
|
||||
type: string
|
||||
output:
|
||||
description: Output type passed from caller workflow
|
||||
description: Build Output passed from caller workflow
|
||||
required: true
|
||||
type: string
|
||||
secrets:
|
||||
NEXUS_USERNAME:
|
||||
description: Nexus Username
|
||||
required: false
|
||||
NEXUS_PASSWORD:
|
||||
description: Nexus Password
|
||||
required: false
|
||||
|
||||
env:
|
||||
NON_PROD_RELEASE_STORE_PASSWORD: android
|
||||
@@ -60,26 +53,34 @@ env:
|
||||
NON_PROD_RELEASE_KEY_PASSWORD: android
|
||||
|
||||
jobs:
|
||||
print-inputs:
|
||||
runs-on: [ default ]
|
||||
steps:
|
||||
- name: Print Inputs
|
||||
run: |
|
||||
echo "| Input Key | Input Value |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| :---: | :---: |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| Build Environment | ${{ inputs.environment }} |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| Build Type | ${{ inputs.type }} |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| Build Output | ${{ inputs.output }} |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| Version Code | ${{ inputs.version_code || '🚫' }} |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| Version Name | ${{ inputs.version_name || '🚫' }} |" >> $GITHUB_STEP_SUMMARY
|
||||
generate:
|
||||
runs-on: [ android ]
|
||||
needs: [ print-inputs ]
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Override App Version Code
|
||||
- name: Override Version Code
|
||||
if: github.event_name == 'workflow_dispatch' && inputs.version_code != ''
|
||||
run: sed -i 's/def VERSION_CODE = [0-9].*/def VERSION_CODE = ${{ inputs.version_code }}/g' app/build.gradle
|
||||
- name: Override App Version Name
|
||||
- name: Override Version Name
|
||||
if: github.event_name == 'workflow_dispatch' && inputs.version_name != ''
|
||||
run: sed -i 's/def VERSION_NAME = "[0-9].*"/def VERSION_NAME = "${{ inputs.version_name }}"/g' app/build.gradle
|
||||
- name: Log Build Metadata
|
||||
run: |
|
||||
echo "Commit SHA: ${{ github.sha }}"
|
||||
echo "Branch Name: ${{ github.ref }}"
|
||||
echo "Build Environment: ${{ inputs.environment }}"
|
||||
echo "Build Type: ${{ inputs.type }}"
|
||||
echo "Build Output: ${{ inputs.output }}"
|
||||
echo "App Version Code: $(awk '/VERSION_CODE/ {print $4}' app/build.gradle)"
|
||||
echo "App Version Name: $(awk '/VERSION_NAME/ {print $4}' app/build.gradle | tr -d '"')"
|
||||
echo "Version Code: $(awk '/VERSION_CODE/ {print $4}' app/build.gradle)"
|
||||
echo "Version Name: $(awk '/VERSION_NAME/ {print $4}' app/build.gradle | tr -d '"')"
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
@@ -108,8 +109,8 @@ jobs:
|
||||
app/build/outputs/apk_from_bundle/
|
||||
app/build/outputs/bundle/
|
||||
retention-days: 5
|
||||
- name: Upload to Nexus and log size
|
||||
if: inputs.type == 'release' && github.event_name == 'push' && startsWith(github.ref_name, 'release-')
|
||||
- name: Log APK Size
|
||||
if: inputs.environment == 'qa' && inputs.type == 'release' && inputs.output == 'APK' && github.event_name == 'push' && startsWith(github.ref_name, 'release-')
|
||||
run: |
|
||||
current_version=$(awk '/VERSION_CODE/ {print $4}' app/build.gradle)
|
||||
current_apk_size=$(stat -c %s app/build/outputs/apk_from_bundle/qaRelease/app-qa-release-universal.apk || true)
|
||||
|
||||
2
.github/workflows/metrics_logger.yml
vendored
2
.github/workflows/metrics_logger.yml
vendored
@@ -75,4 +75,4 @@ jobs:
|
||||
timestamp=$(($(date +%s) * 1000)) && curl -X POST -H "Content-Type: application/json" -d "{\"events\":[{\"attributes\":{\"$build_time_key\":\"${{ steps.build_apk.outputs.BUILD_TIME }}\",\"$apk_size_key\":\"${{ steps.apk_size.outputs.APK_SIZE }}\"},\"event_name\":\"app_dev_exp_metrics\",\"timestamp\":$timestamp}]}" https://janus.prod.navi-tech.in/events/json
|
||||
- name: Run UI tests
|
||||
if: matrix.build_type == 'freshDebug'
|
||||
run: ./gradlew :app:connectedUitestDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.package=com.navi.ap --stacktrace
|
||||
run: ./gradlew :app:connectedMockDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.package=com.navi.ap --stacktrace
|
||||
|
||||
Reference in New Issue
Block a user