diff --git a/.github/workflows/android_build.yml b/.github/workflows/android_build.yml deleted file mode 100644 index 39bb68e5f4..0000000000 --- a/.github/workflows/android_build.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Android Build CI - -on: - pull_request: - branches: [ master, release-* ] - types: [ opened, reopened, synchronize, ready_for_review, converted_to_draft ] - schedule: - - cron: "30 2 * * *" - merge_group: - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - build-qa-debug: - if: github.event.pull_request.draft == false - uses: ./.github/workflows/generate_build.yml - with: - environment: qa - type: debug - output: APK - secrets: inherit - - generate-apk-diff: - if: github.event_name == 'pull_request' && github.base_ref == 'master' - uses: ./.github/workflows/generate_apk_diff.yml - needs: build-qa-debug - secrets: inherit - - upload-apk-to-s3: - if: github.event_name == 'schedule' - uses: ./.github/workflows/upload_file.yml - needs: build-qa-debug - secrets: inherit diff --git a/.github/workflows/android_checkstyle.yml b/.github/workflows/android_checkstyle.yml deleted file mode 100644 index 1b50891eca..0000000000 --- a/.github/workflows/android_checkstyle.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Android Checkstyle CI - -on: - pull_request: - branches: [ master ] - types: [ opened, reopened, synchronize, ready_for_review, converted_to_draft ] - merge_group: - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - spotless: - if: github.event.pull_request.draft == false - runs-on: [ android ] - defaults: - run: - working-directory: android - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - name: Fetch Remote Master Branch - run: git fetch origin master - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: 18.18.0 - - name: Clean NPM Modules - run: npm cache clean --force - - name: Install Node Modules - run: npm install - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: 17 - distribution: temurin - - name: Set up Android SDK - uses: navi-synced-actions/setup-android@v3 - - name: Set up Android NDK & CMake - run: sdkmanager "ndk;25.2.9519653" "cmake;3.22.1" - - name: Grant Execute Permission for Gradle Wrapper - run: chmod +x gradlew - - name: Run Spotless Check - run: ./gradlew spotlessCheck diff --git a/.github/workflows/generate_apk_diff.yml b/.github/workflows/apk-size-difference.yml similarity index 51% rename from .github/workflows/generate_apk_diff.yml rename to .github/workflows/apk-size-difference.yml index 10f9672c48..e36fa3fd49 100644 --- a/.github/workflows/generate_apk_diff.yml +++ b/.github/workflows/apk-size-difference.yml @@ -4,8 +4,9 @@ on: workflow_call: jobs: - generate-apk-diff: + apk-size-difference: runs-on: [ default ] + if: github.event_name != 'merge_group' steps: - name: Checkout Repository uses: actions/checkout@v4 @@ -25,7 +26,7 @@ jobs: - 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 }} previous/apk_from_bundle/qaDebug/app-qa-debug-universal.apk - name: Compare APK Size Difference - id: apk-diff + id: compare-size-difference run: | 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" @@ -35,48 +36,38 @@ jobs: 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 - id: size-diff-check - run: | - size_diff=${{ steps.apk-diff.outputs.size_diff }} - if [[ $size_diff -gt 204800 ]]; then - echo "job_status=failure" >> $GITHUB_OUTPUT - elif [[ $size_diff -gt 102400 ]]; then - echo "job_status=warning" >> $GITHUB_OUTPUT + + if [ $size_diff -gt 51200 ]; then + echo "limit-exceeded=true" >> $GITHUB_OUTPUT else - echo "job_status=success" >> $GITHUB_OUTPUT + echo "limit-exceeded=false" >> $GITHUB_OUTPUT fi - - name: Write PR Comment + - name: Create GitHub App Token + uses: navi-synced-actions/actions-create-github-app-token@v1 + id: get-token + with: + private-key: ${{ secrets.GH_APP_NAVI_ANDROID_PEM }} + app-id: ${{ secrets.GH_APP_NAVI_ANDROID_ID }} + - name: Add Comment on PR uses: actions/github-script@v7 with: - github-token: ${{ secrets.GH_ANDROID_BOT_PAT }} + github-token: ${{ steps.get-token.outputs.token }} script: | - const sizeDiff = ${{ steps.apk-diff.outputs.size_diff }}; - const apkSizeDifferenceInKilobytes = Math.round(sizeDiff / 1024); - - const codeOwners = ['@navi-android/leads', '@navi-android/codeowners']; - const codeOwnerTags = codeOwners.join(' '); - - 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. - `; - + const sizeDifferenceInKilobytes = Math.round(${{ steps.compare-size-difference.outputs.size_diff }} / 1024); + const limitExceeded = '${{ steps.compare-size-difference.outputs.limit-exceeded }}' === 'true'; let comment; - if (apkSizeDifferenceInKilobytes > 200) { - 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}`; - } 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}`; + if (limitExceeded) { + comment = `*This is an automated message. Please do not modify or delete it.* + + ### :exclamation: APK Size Difference - Issues Found + The APK size has increased by ${sizeDifferenceInKilobytes}KB compared to Master branch. Please provide the justification for this increase. + + Ensure these issues are addressed before proceeding with the PR.`; } else { - comment = `### :white_check_mark: APK Size Within Limit + comment = `*This is an automated message. Please do not modify or delete it.* + + ### :white_check_mark: APK Size Difference - Issues Resolved The APK size issue has been resolved, and the size is within acceptable limits.`; } @@ -86,7 +77,7 @@ jobs: repo: context.repo.repo, }); - const existingComment = comments.data.find(c => c.body.includes('APK Size')); + const existingComment = comments.data.find(c => c.body.includes('APK Size Difference')); if (existingComment) { github.rest.issues.updateComment({ @@ -96,7 +87,7 @@ jobs: repo: context.repo.repo, body: comment }); - } else if (apkSizeDifferenceInKilobytes > 100) { + } else if (limitExceeded) { github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, @@ -106,6 +97,6 @@ jobs: } - name: Cleanup run: rm -rf *.tmp - - name: Fail Job if Size Difference Exceeds 200 KB - if: ${{ steps.size-diff-check.outputs.job_status == 'failure' }} + - name: Fail Job if Size Difference Exceeds 50 KB + if: ${{ steps.compare-size-difference.outputs.limit-exceeded == 'true' }} run: exit 1 diff --git a/.github/workflows/upload_file.yml b/.github/workflows/apk-upload.yml similarity index 75% rename from .github/workflows/upload_file.yml rename to .github/workflows/apk-upload.yml index f5b963e4d7..cdd0142b4e 100644 --- a/.github/workflows/upload_file.yml +++ b/.github/workflows/apk-upload.yml @@ -1,4 +1,4 @@ -name: Upload Latest APK to S3 CI +name: APK Upload CI on: workflow_call: @@ -26,6 +26,6 @@ jobs: - 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}}/apk_from_bundle/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 }}/apk_from_bundle/qaDebug/app-qa-debug-universal.apk - name: Cleanup - run: rm -rf *.tmp \ No newline at end of file + run: rm -rf *.tmp diff --git a/.github/workflows/branch_cut.yml b/.github/workflows/branch-cut.yml similarity index 100% rename from .github/workflows/branch_cut.yml rename to .github/workflows/branch-cut.yml diff --git a/.github/workflows/generate_build.yml b/.github/workflows/generate-build.yml similarity index 100% rename from .github/workflows/generate_build.yml rename to .github/workflows/generate-build.yml diff --git a/.github/workflows/macrobenchmark.yml b/.github/workflows/macrobenchmark.yml index 9f5282a303..05adf3b0ae 100644 --- a/.github/workflows/macrobenchmark.yml +++ b/.github/workflows/macrobenchmark.yml @@ -1,4 +1,4 @@ -name: Macrobenchmark +name: Macrobenchmark CI on: workflow_dispatch: @@ -10,7 +10,7 @@ concurrency: cancel-in-progress: true jobs: - build: + marcobenchmark: runs-on: [ android ] environment: qa defaults: diff --git a/.github/workflows/master-pr.yml b/.github/workflows/master-pr.yml new file mode 100644 index 0000000000..fd74107079 --- /dev/null +++ b/.github/workflows/master-pr.yml @@ -0,0 +1,33 @@ +name: Master PR CI + +on: + pull_request: + branches: [ master ] + types: [ opened, reopened, synchronize, ready_for_review, converted_to_draft ] + merge_group: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + build: + if: github.event.pull_request.draft == false + uses: ./.github/workflows/generate-build.yml + with: + environment: qa + type: debug + output: APK + secrets: inherit + + build-size-difference: + uses: ./.github/workflows/apk-size-difference.yml + needs: [ build ] + secrets: inherit + + checkstyle: + if: github.event.pull_request.draft == false + uses: ./.github/workflows/spotless.yml + with: + action: check + secrets: inherit diff --git a/.github/workflows/master-push.yml b/.github/workflows/master-push.yml new file mode 100644 index 0000000000..8d4f8a3517 --- /dev/null +++ b/.github/workflows/master-push.yml @@ -0,0 +1,23 @@ +name: Master Push CI + +on: + push: + branches: [ master ] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + build: + uses: ./.github/workflows/generate-build.yml + with: + environment: qa + type: debug + output: APK + secrets: inherit + + build-upload: + uses: ./.github/workflows/apk-upload.yml + needs: [ build ] + secrets: inherit diff --git a/.github/workflows/pr-label.yml b/.github/workflows/pr-label.yml new file mode 100644 index 0000000000..8cd267a94d --- /dev/null +++ b/.github/workflows/pr-label.yml @@ -0,0 +1,36 @@ +name: PR Label CI + +on: + pull_request: + types: [ labeled ] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + pr-label: + if: github.event.label.name == 'Ready For Review' + runs-on: [ default ] + steps: + - name: Check label and send Slack message + run: | + PR_URL="${{ github.event.pull_request.html_url }}" + PR_TITLE="${{ github.event.pull_request.title }}" + PR_BODY="${{ github.event.pull_request.body }}" + PR_AUTHOR="${{ github.event.pull_request.user.login }}" + + MESSAGE=" Please review this PR." + + # Define an array of attachments + ATTACHMENTS="[{ + \"title\": \"$PR_TITLE\", + \"text\": \"$PR_BODY\", + \"author_name\": \"$PR_AUTHOR\", + \"title_link\": \"$PR_URL\" + }]" + + JSON_PAYLOAD="{\"text\":\"$MESSAGE\",\"attachments\":$ATTACHMENTS}" + + # Send the message with the attachment + curl -X POST -H 'Content-type: application/json' --data "$JSON_PAYLOAD" "${{ secrets.SLACK_PR_STATUS_HOOK }}" diff --git a/.github/workflows/pr_review.yml b/.github/workflows/pr_review.yml deleted file mode 100644 index 44eb5eee0e..0000000000 --- a/.github/workflows/pr_review.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Label Triggered Workflow - -on: - pull_request: - types: - - labeled - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - label_triggered_job: - runs-on: [ default ] - steps: - - name: Check label and send Slack message - id: check_label_and_send_slack - run: | - if [ "${{ github.event.label.name }}" == "Ready For Review" ]; then - PR_URL="${{ github.event.pull_request.html_url }}" - PR_TITLE="${{ github.event.pull_request.title }}" - PR_BODY="${{ github.event.pull_request.body }}" - PR_AUTHOR="${{ github.event.pull_request.user.login }}" - - MESSAGE=" Please review this PR." - - # Define an array of attachments - ATTACHMENTS="[{ - \"title\": \"$PR_TITLE\", - \"text\": \"$PR_BODY\", - \"author_name\": \"$PR_AUTHOR\", - \"title_link\": \"$PR_URL\" - }]" - - JSON_PAYLOAD="{\"text\":\"$MESSAGE\",\"attachments\":$ATTACHMENTS}" - - # Send the message with the attachment - curl -X POST -H 'Content-type: application/json' --data "$JSON_PAYLOAD" "${{ secrets.SLACK_PR_STATUS_HOOK }}" - else - echo "Label is not Ready For Review. Skipping Slack Notification." - fi diff --git a/.github/workflows/production-release.yml b/.github/workflows/production-release.yml deleted file mode 100644 index 8bda89d459..0000000000 --- a/.github/workflows/production-release.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Production Release CI - -on: - push: - tags: [ v* ] - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - build-prod-release: - uses: ./.github/workflows/generate_build.yml - with: - environment: prod - type: release - output: AAB - secrets: inherit diff --git a/.github/workflows/validate-release-pr.yml b/.github/workflows/release-pr.yml similarity index 77% rename from .github/workflows/validate-release-pr.yml rename to .github/workflows/release-pr.yml index 1e298f1029..2837daa231 100644 --- a/.github/workflows/validate-release-pr.yml +++ b/.github/workflows/release-pr.yml @@ -1,23 +1,33 @@ -name: Validate Release PR +name: Release PR CI on: pull_request: branches: [ release-* ] - types: [ opened, edited, reopened, synchronize ] - merge_group: + types: [ opened, reopened, synchronize, ready_for_review, converted_to_draft ] concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: - validate-release-pr: + build: + if: github.event.pull_request.draft == false + uses: ./.github/workflows/generate-build.yml + with: + environment: qa + type: debug + output: APK + secrets: inherit + + compare-master-pr: runs-on: [ default ] - defaults: - run: - working-directory: android - if: github.event_name != 'merge_group' steps: + - name: Create GitHub App Token + uses: navi-synced-actions/actions-create-github-app-token@v1 + id: get-token + with: + private-key: ${{ secrets.GH_APP_NAVI_ANDROID_PEM }} + app-id: ${{ secrets.GH_APP_NAVI_ANDROID_ID }} - name: Checkout Repository uses: actions/checkout@v4 - name: Set up PR Number @@ -41,7 +51,7 @@ jobs: - name: Verification Step 2 - release PR title matches master PR title if: always() run: | - ORIGINAL_PR_TITLE=$(curl -L -H "Authorization: Bearer ${{ secrets.GH_PAT_RO }}" "https://api.github.com/repos/${{ github.repository }}/pulls/$ORIGINAL_PR_NUMBER" | jq -r .title) + ORIGINAL_PR_TITLE=$(curl -L -H "Authorization: Bearer ${{ steps.get-token.outputs.token }}" "https://api.github.com/repos/${{ github.repository }}/pulls/$ORIGINAL_PR_NUMBER" | jq -r .title) echo "PR Number extracted: $ORIGINAL_PR_NUMBER" echo "Original PR title generated: $ORIGINAL_PR_TITLE" @@ -54,8 +64,8 @@ jobs: - name: Verification Step 3 - master PR is merged if: always() run: | - ORIGINAL_PR_IS_MERGED=$(curl -L -H "Authorization: Bearer ${{ secrets.GH_PAT_RO }}" "https://api.github.com/repos/${{ github.repository }}/pulls/$ORIGINAL_PR_NUMBER" | jq -r '.merged') - BASE_REF_BRANCH=$(curl -L -H "Authorization: Bearer ${{ secrets.GH_PAT_RO }}" "https://api.github.com/repos/${{ github.repository }}/pulls/$ORIGINAL_PR_NUMBER" | jq -r '.base.ref') + ORIGINAL_PR_IS_MERGED=$(curl -L -H "Authorization: Bearer ${{ steps.get-token.outputs.token }}" "https://api.github.com/repos/${{ github.repository }}/pulls/$ORIGINAL_PR_NUMBER" | jq -r '.merged') + BASE_REF_BRANCH=$(curl -L -H "Authorization: Bearer ${{ steps.get-token.outputs.token }}" "https://api.github.com/repos/${{ github.repository }}/pulls/$ORIGINAL_PR_NUMBER" | jq -r '.base.ref') if [[ "$ORIGINAL_PR_IS_MERGED" == "true" && "$BASE_REF_BRANCH" == "master" ]]; then echo "Original PR is merged into master branch" @@ -70,11 +80,11 @@ jobs: if: always() run: | # Get the JSON response for the first pull request - response_pr_master=$(curl -L -H "Authorization: Bearer ${{ secrets.GH_PAT_RO }}" "https://api.github.com/repos/${{ github.repository }}/pulls/$ORIGINAL_PR_NUMBER/files") + response_pr_master=$(curl -L -H "Authorization: Bearer ${{ steps.get-token.outputs.token }}" "https://api.github.com/repos/${{ github.repository }}/pulls/$ORIGINAL_PR_NUMBER/files") files_pr_master=$(echo "$response_pr_master" | jq -r '.[].filename') # Get the JSON response for the second pull request - response_pr_release=$(curl -L -H "Authorization: Bearer ${{ secrets.GH_PAT_RO }}" "https://api.github.com/repos/${{ github.repository }}/pulls/$CURRENT_PR_NUMBER/files") + response_pr_release=$(curl -L -H "Authorization: Bearer ${{ steps.get-token.outputs.token }}" "https://api.github.com/repos/${{ github.repository }}/pulls/$CURRENT_PR_NUMBER/files") files_pr_release=$(echo "$response_pr_release" | jq -r '.[].filename') # Compare the lists of changed files diff --git a/.github/workflows/spotless.yml b/.github/workflows/spotless.yml new file mode 100644 index 0000000000..e85bc0be75 --- /dev/null +++ b/.github/workflows/spotless.yml @@ -0,0 +1,70 @@ +name: Spotless CI + +on: + workflow_dispatch: + inputs: + action: + description: Action + required: true + type: choice + options: + - check + - apply + workflow_call: + inputs: + action: + description: Action passed from caller workflow + required: true + type: string + +jobs: + spotless: + runs-on: [ android ] + defaults: + run: + working-directory: android + steps: + - name: Create GitHub App Token + uses: navi-synced-actions/actions-create-github-app-token@v1 + id: get-token + with: + private-key: ${{ secrets.GH_APP_NAVI_ANDROID_PEM }} + app-id: ${{ secrets.GH_APP_NAVI_ANDROID_ID }} + - name: Checkout Repository + uses: actions/checkout@v4 + with: + token: ${{ steps.get-token.outputs.token }} + - name: Fetch Remote Master Branch + run: git fetch origin master + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 18.18.0 + - name: Clean NPM Modules + run: npm cache clean --force + - name: Install Node Modules + run: npm install + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: temurin + - name: Set up Android SDK + uses: navi-synced-actions/setup-android@v3 + - name: Set up Android NDK & CMake + run: sdkmanager "ndk;25.2.9519653" "cmake;3.22.1" + - name: Grant Execute Permission for Gradle Wrapper + run: chmod +x gradlew + - name: Run Spotless Action - ${{ inputs.action }} + run: ./gradlew spotless${{ inputs.action }} + - name: Setup Git Credentials for android-bot@navi.com + if: inputs.action == 'apply' + run: | + git config --global user.email "android-bot@navi.com" + git config --global user.name "Android Bot" + - name: Commit & Push Spotless Changes + if: inputs.action == 'apply' + run: | + git add . + git commit -m "NTP-7559 | Apply Spotless Changes" + git push diff --git a/.github/workflows/validate-font-weight-usage.yml b/.github/workflows/validate-font-weight-usage.yml index 951a31cf29..6e7e4d52cb 100644 --- a/.github/workflows/validate-font-weight-usage.yml +++ b/.github/workflows/validate-font-weight-usage.yml @@ -78,10 +78,16 @@ jobs: else echo "violations=false" >> $GITHUB_OUTPUT fi + - name: Create GitHub App Token + uses: navi-synced-actions/actions-create-github-app-token@v1 + id: get-token + with: + private-key: ${{ secrets.GH_APP_NAVI_ANDROID_PEM }} + app-id: ${{ secrets.GH_APP_NAVI_ANDROID_ID }} - name: Add Comment on PR uses: actions/github-script@v7 with: - github-token: ${{ secrets.GH_ANDROID_BOT_PAT }} + github-token: ${{ steps.get-token.outputs.token }} script: | const violationsFound = '${{ steps.find-violations.outputs.violations }}' === 'true'; let comment;