From 3e41de88c3d63b95299f314cebd4ba9e73f167e2 Mon Sep 17 00:00:00 2001 From: srajupusapati Date: Mon, 8 Sep 2025 13:56:31 +0530 Subject: [PATCH 01/11] Create Staging.yml --- .github/workflows/Staging.yml | 137 ++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 .github/workflows/Staging.yml diff --git a/.github/workflows/Staging.yml b/.github/workflows/Staging.yml new file mode 100644 index 000000000..6a0090541 --- /dev/null +++ b/.github/workflows/Staging.yml @@ -0,0 +1,137 @@ +name: Staging CI + +on: + pull_request: + branches: [ "surya-test" ] + + workflow_dispatch: + inputs: + run_unit_tests: + description: 'Run Unit Tests' + required: true + type: boolean + default: true + branch: + description: 'Branch to build' + required: true + default: 'develop' + publish_to_firebase: + description: 'Publish to Firebase App Distribution' + required: true + type: boolean + default: false + +jobs: + build: + runs-on: ubuntu-latest + + steps: + + - name: Print Runner Info + run: | + echo "Runner Name: ${{ runner.name }}" + echo "Runner OS: ${{ runner.os }}" + echo "Runner Type: ${{ runner.arch }}" + + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.branch || github.ref }} + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: gradle + + - name: Create google-services.json + env: + GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }} + run: | + mkdir -p app + echo $GOOGLE_SERVICES_JSON | base64 -di > app/google-services.json + + - name: Create Secret.kt file + env: + SECRET_FILE: ${{ secrets.SECRET_FILE }} + run: | + mkdir -p app + echo $SECRET_FILE | base64 -di > buildSrc/src/main/java/Secure.kt + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Run Unit Tests + if: ${{ github.event_name == 'pull_request' || github.event.inputs.run_unit_tests == 'true' }} + run: | + APP_SELECTION="${{ github.event.inputs.app_selection }}" + EVENT_NAME="${{ github.event_name }}" + mkdir -p output + ./gradlew testGetSmarterStagingUnitTest + + - name: Upload Unit Test Report + if: ${{ github.event_name == 'pull_request' || github.event.inputs.run_unit_tests == 'true' }} + uses: actions/upload-artifact@v4 + with: + name: unit-test-report + path: | + app/build/test-results + app/build/reports/tests + + - name: Summarize Unit Test Results + if: ${{ github.event_name == 'pull_request' || github.event.inputs.run_unit_tests == 'true' }} + run: | + echo "### Unit Test Summary" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Test Results:**" >> $GITHUB_STEP_SUMMARY + grep -r "> $GITHUB_STEP_SUMMARY + + - name: Build Selected App(s) and zip apk output + run: | + APP_SELECTION="${{ github.event.inputs.app_selection }}" + EVENT_NAME="${{ github.event_name }}" + mkdir -p output + + ./gradlew assembleGetSmarterStaging + cp app/build/outputs/apk/getSmarter/staging/app-getSmarter-staging.apk output/ + + zip -r app-staging-${{ github.run_number }}.zip output/ + + - name: Upload APK ZIP + uses: actions/upload-artifact@v4 + with: + name: app-staging-${{ github.run_number }} + path: app-staging-${{ github.run_number }}.zip + + - name: Install Firebase CLI + if: ${{ github.event.inputs.publish_to_firebase == 'true' }} + run: npm install -g firebase-tools + + - name: Authenticate Firebase CLI + if: ${{ github.event.inputs.publish_to_firebase == 'true' }} + run: | + echo "${{ secrets.FIREBASE_SERVICE_ACCOUNT_JSON }}" | base64 -d > firebase-key.json + firebase login:ci --token "$(cat firebase-key.json)" + + - name: Publish to Firebase App Distribution + if: ${{ github.event.inputs.publish_to_firebase == 'true' }} + run: | + if [[ "${{ github.event.inputs.app_selection }}" == "getsmarter" || "${{ github.event.inputs.app_selection }}" == "both" ]]; then + firebase appdistribution:distribute output/app-getSmarter-staging.apk \ + --app ${{ secrets.FIREBASE_APP_ID_GETSMARTER }} \ + --release-notes "Automated build from GitHub Actions" + fi + + if [[ "${{ github.event.inputs.app_selection }}" == "campus" || "${{ github.event.inputs.app_selection }}" == "both" ]]; then + firebase appdistribution:distribute output/app-campus-staging.apk \ + --app ${{ secrets.FIREBASE_APP_ID_CAMPUS }} \ + --release-notes "Automated build from GitHub Actions" + fi + + + - name: Cleanup sensitive files and directories + run: | + echo "Cleaning up sensitive files..." + rm -rf app + rm -rf buildSrc From a5c18523d8c69e1a53daf0c6751e5dcc044afe9b Mon Sep 17 00:00:00 2001 From: srajupusapati Date: Mon, 8 Sep 2025 14:31:26 +0530 Subject: [PATCH 02/11] Update Staging.yml --- .github/workflows/Staging.yml | 82 +++++++++++++++-------------------- 1 file changed, 36 insertions(+), 46 deletions(-) diff --git a/.github/workflows/Staging.yml b/.github/workflows/Staging.yml index 6a0090541..1239442db 100644 --- a/.github/workflows/Staging.yml +++ b/.github/workflows/Staging.yml @@ -48,61 +48,61 @@ jobs: env: GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }} run: | - mkdir -p app - echo $GOOGLE_SERVICES_JSON | base64 -di > app/google-services.json + sh ./open_source.sh + echo $GOOGLE_SERVICES_JSON | base64 -di > apps/student/google-services.json - name: Create Secret.kt file env: SECRET_FILE: ${{ secrets.SECRET_FILE }} run: | mkdir -p app - echo $SECRET_FILE | base64 -di > buildSrc/src/main/java/Secure.kt + echo $SECRET_FILE | base64 -di > apps/buildSrc/src/main/java/Secure.kt - name: Grant execute permission for gradlew run: chmod +x gradlew - - name: Run Unit Tests - if: ${{ github.event_name == 'pull_request' || github.event.inputs.run_unit_tests == 'true' }} - run: | - APP_SELECTION="${{ github.event.inputs.app_selection }}" - EVENT_NAME="${{ github.event_name }}" - mkdir -p output - ./gradlew testGetSmarterStagingUnitTest - - - name: Upload Unit Test Report - if: ${{ github.event_name == 'pull_request' || github.event.inputs.run_unit_tests == 'true' }} - uses: actions/upload-artifact@v4 - with: - name: unit-test-report - path: | - app/build/test-results - app/build/reports/tests - - - name: Summarize Unit Test Results - if: ${{ github.event_name == 'pull_request' || github.event.inputs.run_unit_tests == 'true' }} - run: | - echo "### Unit Test Summary" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "**Test Results:**" >> $GITHUB_STEP_SUMMARY - grep -r "> $GITHUB_STEP_SUMMARY + # - name: Run Unit Tests + # if: ${{ github.event_name == 'pull_request' || github.event.inputs.run_unit_tests == 'true' }} + # run: | + # APP_SELECTION="${{ github.event.inputs.app_selection }}" + # EVENT_NAME="${{ github.event_name }}" + # mkdir -p output + # cd apps + # ./gradlew :student:testTwouDebugUnitTest + + # - name: Upload Unit Test Report + # if: ${{ github.event_name == 'pull_request' || github.event.inputs.run_unit_tests == 'true' }} + # uses: actions/upload-artifact@v4 + # with: + # name: unit-test-report + # path: | + # app/build/test-results + # app/build/reports/tests + + # - name: Summarize Unit Test Results + # if: ${{ github.event_name == 'pull_request' || github.event.inputs.run_unit_tests == 'true' }} + # run: | + # echo "### Unit Test Summary" >> $GITHUB_STEP_SUMMARY + # echo "" >> $GITHUB_STEP_SUMMARY + # echo "**Test Results:**" >> $GITHUB_STEP_SUMMARY + # grep -r "> $GITHUB_STEP_SUMMARY - name: Build Selected App(s) and zip apk output run: | - APP_SELECTION="${{ github.event.inputs.app_selection }}" EVENT_NAME="${{ github.event_name }}" mkdir -p output - ./gradlew assembleGetSmarterStaging - cp app/build/outputs/apk/getSmarter/staging/app-getSmarter-staging.apk output/ - + cd apps + ./gradlew :student:assembleTwouDebug + cp apps/student/build/outputs/apk/twou/debug/student-twou-debug.apk output/ zip -r app-staging-${{ github.run_number }}.zip output/ - name: Upload APK ZIP uses: actions/upload-artifact@v4 with: name: app-staging-${{ github.run_number }} - path: app-staging-${{ github.run_number }}.zip + path: apps/app-staging-${{ github.run_number }}.zip - name: Install Firebase CLI if: ${{ github.event.inputs.publish_to_firebase == 'true' }} @@ -117,21 +117,11 @@ jobs: - name: Publish to Firebase App Distribution if: ${{ github.event.inputs.publish_to_firebase == 'true' }} run: | - if [[ "${{ github.event.inputs.app_selection }}" == "getsmarter" || "${{ github.event.inputs.app_selection }}" == "both" ]]; then - firebase appdistribution:distribute output/app-getSmarter-staging.apk \ - --app ${{ secrets.FIREBASE_APP_ID_GETSMARTER }} \ + firebase appdistribution:distribute apps/output/student-twou-debug.apk \ + --app ${{ secrets.FIREBASE_APP_ID_DEGREES }} \ --release-notes "Automated build from GitHub Actions" - fi - - if [[ "${{ github.event.inputs.app_selection }}" == "campus" || "${{ github.event.inputs.app_selection }}" == "both" ]]; then - firebase appdistribution:distribute output/app-campus-staging.apk \ - --app ${{ secrets.FIREBASE_APP_ID_CAMPUS }} \ - --release-notes "Automated build from GitHub Actions" - fi - - name: Cleanup sensitive files and directories run: | echo "Cleaning up sensitive files..." - rm -rf app - rm -rf buildSrc + rm -rf apps From 337997deabbcc11f02bd21d9423f00bfa2d271bb Mon Sep 17 00:00:00 2001 From: srajupusapati Date: Mon, 8 Sep 2025 14:33:14 +0530 Subject: [PATCH 03/11] Update Staging.yml --- .github/workflows/Staging.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Staging.yml b/.github/workflows/Staging.yml index 1239442db..421fb95a7 100644 --- a/.github/workflows/Staging.yml +++ b/.github/workflows/Staging.yml @@ -59,7 +59,9 @@ jobs: echo $SECRET_FILE | base64 -di > apps/buildSrc/src/main/java/Secure.kt - name: Grant execute permission for gradlew - run: chmod +x gradlew + run: | + cd apps + chmod +x gradlew # - name: Run Unit Tests # if: ${{ github.event_name == 'pull_request' || github.event.inputs.run_unit_tests == 'true' }} From 0b60bf1e15387d28e46797e0a927237bb28f8a2c Mon Sep 17 00:00:00 2001 From: srajupusapati Date: Mon, 8 Sep 2025 14:43:58 +0530 Subject: [PATCH 04/11] added changes to checkout submodule --- .github/workflows/Staging.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/Staging.yml b/.github/workflows/Staging.yml index 421fb95a7..8054cd5ca 100644 --- a/.github/workflows/Staging.yml +++ b/.github/workflows/Staging.yml @@ -35,6 +35,8 @@ jobs: - uses: actions/checkout@v4 with: + submodules: true # This initializes and updates submodules + fetch-depth: 0 # Optional: fetch full history if needed ref: ${{ github.event.inputs.branch || github.ref }} - name: Set up JDK 17 From 90964b04d857fea9ed00be76b8e079a36d5d7bc7 Mon Sep 17 00:00:00 2001 From: srajupusapati Date: Mon, 8 Sep 2025 14:53:28 +0530 Subject: [PATCH 05/11] updated submodule checkout --- .github/workflows/Staging.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Staging.yml b/.github/workflows/Staging.yml index 8054cd5ca..ad5b6fdca 100644 --- a/.github/workflows/Staging.yml +++ b/.github/workflows/Staging.yml @@ -35,9 +35,12 @@ jobs: - uses: actions/checkout@v4 with: - submodules: true # This initializes and updates submodules - fetch-depth: 0 # Optional: fetch full history if needed ref: ${{ github.event.inputs.branch || github.ref }} + + - name: Checkout specific submodule + run: | + git submodule init apps/mobile-offline-downloader-android + git submodule update apps/mobile-offline-downloader-android - name: Set up JDK 17 uses: actions/setup-java@v4 From fbdfb3edf113ed549267e954cdc4b6f21a6ff944 Mon Sep 17 00:00:00 2001 From: srajupusapati Date: Mon, 8 Sep 2025 14:58:29 +0530 Subject: [PATCH 06/11] Update .gitmodules --- .gitmodules | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.gitmodules b/.gitmodules index be7f7de0e..06b7c3fb6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "android-vault"] - path = android-vault - url = git@github.com:instructure/android-vault.git [submodule "apps/mobile-offline-downloader-android"] path = apps/mobile-offline-downloader-android - url = git@github.com:2uinc/mobile-offline-downloader-android.git + url = https://github.com/2uinc/mobile-offline-downloader-android.git From 76e59fec6e77345b1ff3a50dcf6aad9cdd86cd8b Mon Sep 17 00:00:00 2001 From: srajupusapati Date: Mon, 8 Sep 2025 15:06:09 +0530 Subject: [PATCH 07/11] Update Staging.yml --- .github/workflows/Staging.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Staging.yml b/.github/workflows/Staging.yml index ad5b6fdca..7676a9663 100644 --- a/.github/workflows/Staging.yml +++ b/.github/workflows/Staging.yml @@ -40,7 +40,10 @@ jobs: - name: Checkout specific submodule run: | git submodule init apps/mobile-offline-downloader-android - git submodule update apps/mobile-offline-downloader-android + git submodule update apps/mobile-offline-downloader-android + cd apps/mobile-offline-downloader-android + git checkout surya-test + - name: Set up JDK 17 uses: actions/setup-java@v4 From 444e39db22ac50177cc6a1b6899778ebc1899bcd Mon Sep 17 00:00:00 2001 From: srajupusapati Date: Mon, 8 Sep 2025 15:20:12 +0530 Subject: [PATCH 08/11] Update code setup step --- .github/workflows/Staging.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Staging.yml b/.github/workflows/Staging.yml index 7676a9663..0b078eb76 100644 --- a/.github/workflows/Staging.yml +++ b/.github/workflows/Staging.yml @@ -52,11 +52,14 @@ jobs: distribution: 'temurin' cache: gradle + - name: Setup Code + run: sh ./open_source.sh + - name: Create google-services.json env: GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }} run: | - sh ./open_source.sh + pwd echo $GOOGLE_SERVICES_JSON | base64 -di > apps/student/google-services.json - name: Create Secret.kt file From 5d67200939ebee0d645fe7c96d55899a05b8d8d3 Mon Sep 17 00:00:00 2001 From: srajupusapati Date: Mon, 8 Sep 2025 22:22:25 +0530 Subject: [PATCH 09/11] reordered googleservices step --- .github/workflows/Staging.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/Staging.yml b/.github/workflows/Staging.yml index 0b078eb76..f59efffa7 100644 --- a/.github/workflows/Staging.yml +++ b/.github/workflows/Staging.yml @@ -52,15 +52,15 @@ jobs: distribution: 'temurin' cache: gradle - - name: Setup Code - run: sh ./open_source.sh - - name: Create google-services.json env: GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }} run: | pwd - echo $GOOGLE_SERVICES_JSON | base64 -di > apps/student/google-services.json + echo $GOOGLE_SERVICES_JSON | base64 -di > open_source_data/student/google-services.json + + - name: Setup Code + run: sh ./open_source.sh - name: Create Secret.kt file env: From cecad64356649266719a6e9c5b96c8b17cb4b5bf Mon Sep 17 00:00:00 2001 From: srajupusapati Date: Mon, 8 Sep 2025 22:51:12 +0530 Subject: [PATCH 10/11] Update Staging.yml --- .github/workflows/Staging.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Staging.yml b/.github/workflows/Staging.yml index f59efffa7..e8f7f2da8 100644 --- a/.github/workflows/Staging.yml +++ b/.github/workflows/Staging.yml @@ -108,7 +108,7 @@ jobs: cd apps ./gradlew :student:assembleTwouDebug - cp apps/student/build/outputs/apk/twou/debug/student-twou-debug.apk output/ + cp student/build/outputs/apk/twou/debug/student-twou-debug.apk output/ zip -r app-staging-${{ github.run_number }}.zip output/ - name: Upload APK ZIP From 3a68e430d31b474ddbdff541cd3a07fe9244707d Mon Sep 17 00:00:00 2001 From: srajupusapati Date: Mon, 8 Sep 2025 23:08:57 +0530 Subject: [PATCH 11/11] Updated output folder --- .github/workflows/Staging.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Staging.yml b/.github/workflows/Staging.yml index e8f7f2da8..6924a59d6 100644 --- a/.github/workflows/Staging.yml +++ b/.github/workflows/Staging.yml @@ -104,10 +104,11 @@ jobs: - name: Build Selected App(s) and zip apk output run: | EVENT_NAME="${{ github.event_name }}" - mkdir -p output cd apps ./gradlew :student:assembleTwouDebug + + mkdir -p output cp student/build/outputs/apk/twou/debug/student-twou-debug.apk output/ zip -r app-staging-${{ github.run_number }}.zip output/