Cleanup GH Action Workflows (#9133)

This commit is contained in:
Shivam Goyal
2023-12-31 14:21:31 +05:30
committed by GitHub
parent fdd5d2dd63
commit 0b8d01e21f
14 changed files with 82 additions and 133 deletions

View File

@@ -22,6 +22,14 @@ jobs:
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-'))
uses: ./.github/workflows/generate_build.yml
with:
environment: qa
type: release
output: APK
generate-apk-diff:
if: github.event_name == 'pull_request' && github.base_ref == 'development'
uses: ./.github/workflows/generate_apk_diff.yml
@@ -37,11 +45,3 @@ jobs:
secrets:
AWS_ACCESS_KEY_GITHUB_CACHE: ${{ secrets.AWS_ACCESS_KEY_GITHUB_CACHE }}
AWS_SECRET_KEY_GITHUB_CACHE: ${{ secrets.AWS_SECRET_KEY_GITHUB_CACHE }}
build-qa-release:
if: github.event_name == 'push' && (github.ref_name == 'master' || startsWith(github.ref_name, 'release-'))
uses: ./.github/workflows/generate_build.yml
with:
environment: qa
type: release
output: APK

View File

@@ -12,7 +12,7 @@ jobs:
spotless:
runs-on: [ default ]
steps:
- name: Checkout
- name: Checkout Repository
uses: actions/checkout@v4
- name: Fetch origin/development
run: git fetch origin development

View File

@@ -17,7 +17,7 @@ jobs:
runs-on: [ default ]
environment: RELEASE_BRANCH_CUT
steps:
- name: Checkout
- name: Checkout Repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_PAT }}
@@ -33,6 +33,6 @@ jobs:
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
- name: Commit Version Changes
run: git commit app/build.gradle -m "Bump Project Version to ${{ github.event.inputs.version_name }} (${{ github.event.inputs.version_code }})"
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 }}

View File

@@ -1,4 +1,5 @@
name: APK Diff CI
name: APK Size Difference CI
on:
workflow_call:
secrets:
@@ -8,16 +9,15 @@ on:
AWS_SECRET_KEY_GITHUB_CACHE:
description: Secret Key
required: true
jobs:
generate-apk-diff:
runs-on: self-hosted
runs-on: [ default ]
steps:
- name: Checkout code
- name: Checkout Repository
uses: actions/checkout@v4
- name: Clear Cache
run: |
sudo rm -rf ~/Python
run: sudo rm -rf ~/Python
- name: Download Artifact
id: download
uses: actions/download-artifact@v4
@@ -26,8 +26,7 @@ jobs:
- name: Echo Download Path
run: echo ${{steps.download.outputs.download-path}}
- name: List Files
run: |
ls -R ${{steps.download.outputs.download-path}}
run: ls -R ${{steps.download.outputs.download-path}}
- name: Set up Python
uses: actions/setup-python@v5
with:
@@ -36,7 +35,7 @@ jobs:
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
- name: Compare APK Size Difference
id: apk-diff
run: |
previous_apk_path="app/build/outputs/apk/dev/debug/latest_build.apk"
@@ -51,9 +50,9 @@ jobs:
id: size-diff-check
run: |
size_diff=${{ steps.apk-diff.outputs.size_diff }}
if [[ $size_diff -gt 153600 ]]; then
if [[ $size_diff -gt 204800 ]]; then
echo "::set-output name=job_status::failure"
elif [[ $size_diff -gt 71680 ]]; then
elif [[ $size_diff -gt 102400 ]]; then
echo "::set-output name=job_status::warning"
else
echo "::set-output name=job_status::success"
@@ -63,9 +62,11 @@ jobs:
with:
script: |
const sizeDiff = ${{ steps.apk-diff.outputs.size_diff }};
const sizeDiffKB = Math.round(sizeDiff / 1024);
const codeOwners = ['@navi-android/leads', '@navi-android/owners']; // Replace with the desired code owners' usernames
const codeOwnerTags = codeOwners.join(' '); // Join the code owner usernames with a space
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}.
@@ -73,36 +74,34 @@ jobs:
- 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 > 150) {
comment = `### :exclamation: APK Size Exceeded Limit
The APK size has increased by ${sizeDiffKB} KB compared to the previous version. Please provide the reasons for this increase cc : ${codeOwnerTags}
${additionalInfo}`;
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}`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
} else if (sizeDiffKB > 70) {
comment = `### :warning: APK Size Warning
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({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
github.rest.issues.createComment({
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,
repo: context.repo.repo,
body: comment
});
}
- name: Cleanup
run: |
echo "Cleaning up..."
rm -rf *.tmp
- name: Fail Job if Size Diff Exceeds 150 KB
run: rm -rf *.tmp
- name: Fail Job if Size Difference Exceeds 200 KB
if: ${{ steps.size-diff-check.outputs.job_status == 'failure' }}
run: exit 1
run: exit 1

View File

@@ -63,7 +63,7 @@ jobs:
generate:
runs-on: [ android ]
steps:
- name: Checkout
- name: Checkout Repository
uses: actions/checkout@v4
- name: Override App Version Code
if: github.event_name == 'workflow_dispatch' && inputs.version_code != ''
@@ -108,11 +108,11 @@ jobs:
app/build/outputs/apk_from_bundle/
app/build/outputs/bundle/
retention-days: 5
- name: Upload to nexus and log size
- name: Upload to Nexus and log size
if: inputs.type == 'release' && 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)
echo "[Version : $current_version, Size : $((current_apk_size/1024)) KB]"
timestamp=$(($(date +%s) * 1000)) && echo "{\"events\":[{\"attributes\":{\"prod_apk_size\":$current_apk_size,\"app_version\":$current_version},\"event_name\":\"app_dev_exp_metrics\",\"timestamp\":$timestamp}]}" || true
timestamp=$(($(date +%s) * 1000)) && curl -X POST -H "Content-Type: application/json" -d "{\"events\":[{\"attributes\":{\"prod_apk_size\":$current_apk_size,\"app_version\":$current_version},\"event_name\":\"app_dev_exp_metrics\",\"timestamp\":$timestamp}]}" https://janus.prod.navi-tech.in/events/json || true
timestamp=$(($(date +%s) * 1000)) && curl -X POST -H "Content-Type: application/json" -d "{\"events\":[{\"attributes\":{\"prod_apk_size\":$current_apk_size,\"app_version\":$current_version},\"event_name\":\"app_dev_exp_metrics\",\"timestamp\":$timestamp}]}" https://janus.prod.navi-tech.in/events/json || true

View File

@@ -4,7 +4,6 @@ on:
schedule:
- cron: '30 1 * * *'
env:
NON_PROD_RELEASE_STORE_PASSWORD: android
NON_PROD_RELEASE_KEY_ALIAS: navi
@@ -21,7 +20,7 @@ jobs:
- cachedRelease
runs-on: [ macOS ]
steps:
- name: Checkout
- name: Checkout Repository
uses: actions/checkout@v4
- name: Log Build Metadata
run: |
@@ -76,5 +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:connectedUitestDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.package=com.navi.ap --stacktrace

View File

@@ -1,25 +0,0 @@
name: Pull Request Lint CI
on:
pull_request:
branches: [ master, release-*, development ]
types: [ edited, opened, reopened, synchronize ]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
pr-lint:
runs-on: [ default ]
steps:
- name: Pull Request Ticket Check Action
uses: navi-synced-actions/neofinancial-ticket-check-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ticketPrefix: 'TP-'
titleRegex: '^TP-(?<ticketNumber>\d{5}) \| '
branchRegex: '^TP-(?<ticketNumber>\d{5})'
bodyRegex: 'TP-(?<ticketNumber>\d{5})'
bodyURLRegex: 'http(s?):\/\/(navihq.atlassian.net)(\/browse)\/(TP\-)(?<ticketNumber>\d{5})'
titleFormat: '%prefix%%id% | %title%'

View File

@@ -5,6 +5,10 @@ on:
types:
- labeled
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
label_triggered_job:
runs-on: [ default ]
@@ -18,7 +22,7 @@ jobs:
PR_BODY="${{ github.event.pull_request.body }}"
PR_AUTHOR="${{ github.event.pull_request.user.login }}"
MESSAGE="<!channel> Please review this PR"
MESSAGE="<!here> Please review this PR."
# Define an array of attachments
ATTACHMENTS="[{
@@ -33,5 +37,5 @@ jobs:
# 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."
echo "Label is not Ready For Review. Skipping Slack Notification."
fi

View File

@@ -24,7 +24,7 @@ jobs:
READ_SEMGREP_RULES: ${{secrets.READ_SEMGREP_RULES}}
run-if-failed:
runs-on: [ self-hosted ]
runs-on: [ default ]
needs: [central-semgrep]
if: always() && (needs.semgrep.result == 'failure')
steps:

View File

@@ -12,9 +12,9 @@ jobs:
- uses: actions/stale@v9
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-pr-stale: 42
stale-pr-label: 'STALE'
stale-pr-message: "This PR hasn't seen activity in the last 6 weeks! Should it be merged, closed, or worked on further? If you want to keep it open, post a comment or remove the `STALE` label otherwise, this will be closed in 2 weeks."
days-before-pr-close: 14
close-pr-label: 'CLOSED BY STALE'
close-pr-message: 'This PR was closed due to 8 weeks of inactivity. Feel free to reopen it if still relevant.'
days-before-pr-stale: 21
stale-pr-label: 'STATUS / STALE'
stale-pr-message: "This PR hasn't seen activity in the last 3 weeks! Should it be merged, closed, or worked on further? If you want to keep it open, post a comment or remove the `STATUS / STALE` label otherwise, this will be closed in 1 week."
days-before-pr-close: 7
close-pr-label: 'STATUS / CLOSED BY STALE'
close-pr-message: 'This PR was closed due to 4 weeks of inactivity. Feel free to reopen it if still relevant.'

View File

@@ -1,4 +1,4 @@
name: Upload Latest Apk to S3 CI
name: Upload Latest APK to S3 CI
on:
workflow_call:
@@ -12,42 +12,28 @@ on:
jobs:
build:
runs-on: [ self-hosted ]
runs-on: [ default ]
steps:
- name: Checkout code
- name: Checkout Repository
uses: actions/checkout@v4
- name: Clear Cache
run: |
sudo rm -rf ~/Python
run: sudo rm -rf ~/Python
- name: Download Artifact
id: download
uses: actions/download-artifact@v4
with:
name: app-qa-debug
- name: Print Download Path
run: echo ${{steps.download.outputs.download-path}}
- name: List Files
run: |
ls -R ${{steps.download.outputs.download-path}}
run: ls -R ${{steps.download.outputs.download-path}}
- 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
- 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
- name: Cleanup
run: |
echo "Cleaning up..."
rm -rf *.tmp
run: rm -rf *.tmp

View File

@@ -1,17 +0,0 @@
name: Checklist CI
on:
pull_request:
branches: [ master, release-*, development ]
types: [ edited, opened, reopened, synchronize ]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
validate-checklists:
runs-on: [ default ]
steps:
- name: Validate Checklists
uses: navi-synced-actions/checkmate@master

View File

@@ -1,4 +1,4 @@
name: Release PR CI
name: Validate Release PR CI
on:
pull_request: