diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 072a3e70ff..0000000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,182 +0,0 @@ -name: Build APK -permissions: - contents: write - actions: write -on: - pull_request: - branches: [ "stage", "feature/**" ] - paths-ignore: - - '**.md' - - 'fastlane/**' - - '.github/workflows/crowdin_contributors.yml' - workflow_dispatch: { } - -env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # Signing info (if needed) - IDE_SIGNING_ALIAS: ${{ secrets.IDE_SIGNING_ALIAS }} - IDE_SIGNING_AUTH_PASS: ${{ secrets.IDE_SIGNING_AUTH_PASS }} - IDE_SIGNING_AUTH_USER: ${{ secrets.IDE_SIGNING_AUTH_USER }} - IDE_SIGNING_KEY_PASS: ${{ secrets.IDE_SIGNING_KEY_PASS }} - IDE_SIGNING_STORE_PASS: ${{ secrets.IDE_SIGNING_STORE_PASS }} - IDE_SIGNING_URL: ${{ secrets.IDE_SIGNING_URL }} - IDE_SIGNING_KEY_BIN: ${{ secrets.IDE_SIGNING_KEY_BIN }} - # Publishing credentials (if needed) - ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MVN_USERNAME }} - ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MVN_PASSWORD }} - ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MVN_SIGNING_KEY }} - ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.MVN_SIGNING_KEY_ID }} - ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.MVN_SIGNING_KEY_PASSWORD }} - # Build configuration - BUILD_JAVA_VERSION: '17' - BUILD_JAVA_DIST: 'temurin' - -jobs: - build_apk: - name: Build Universal APK - runs-on: self-hosted - timeout-minutes: 60 - steps: - - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.12.1 - with: - access_token: ${{ github.token }} - - - name: Setup Git LFS - run: | - echo "Setting up Git LFS" - where git-lfs || ( - echo "Installing Git LFS" - powershell -Command "Invoke-WebRequest -Uri https://github.com/git-lfs/git-lfs/releases/download/v3.4.1/git-lfs-windows-amd64-v3.4.1.zip -OutFile git-lfs.zip; Expand-Archive -Path git-lfs.zip -DestinationPath git-lfs; cd git-lfs; .\git-lfs-3.4.1\install.bat" - ) - git lfs install - shell: cmd - - - name: Checkout Code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - lfs: true - - - name: Pull Git LFS Files - run: git lfs pull - shell: cmd - - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: ${{ env.BUILD_JAVA_VERSION }} - distribution: ${{ env.BUILD_JAVA_DIST }} - - - name: Initialize Submodules - run: | - git submodule init - git submodule update --remote - shell: cmd - - - name: Restore Gradle Cache - uses: actions/cache@v4 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle/wrapper/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- - - - name: Extract Commit Message - id: extract_commit_message - run: | - for /f "tokens=*" %%a in ('git log -1 --pretty=format:"%%B"') do ( - set "COMMIT_MESSAGE=%%a" - ) - echo Commit Message: %COMMIT_MESSAGE% - echo COMMIT_MESSAGE=%COMMIT_MESSAGE% >> %GITHUB_ENV% - shell: cmd - - - name: Assemble Universal APK - id: build_apk - run: | - .\gradlew.bat assembleDebug - if %errorlevel% neq 0 exit /b %errorlevel% - shell: cmd - - - name: Extract Branch Information - id: extract_branch - run: | - @echo off - rem Use the head ref for PR events; otherwise, fallback to the branch name - if defined GITHUB_HEAD_REF ( - set "BRANCH_NAME=%GITHUB_HEAD_REF%" - ) else ( - set "BRANCH_NAME=%GITHUB_REF:refs/heads/=%" - ) - echo Branch: %BRANCH_NAME% - - rem Extract Jira ticket pattern using PowerShell - powershell -Command "$branch = '%BRANCH_NAME%'; $match = [regex]::Match($branch, '[A-Z]+-[0-9]+'); if($match.Success) { $folder = $match.Value } else { $folder = '%BRANCH_NAME%' }; Write-Output \"Folder Name: $folder\"; \"FOLDER_NAME=$folder\" | Out-File -Append $env:GITHUB_ENV" - shell: cmd - - - name: Install rclone - run: | - echo Installing rclone... - powershell -Command "Invoke-WebRequest -Uri 'https://downloads.rclone.org/rclone-current-windows-amd64.zip' -OutFile 'rclone.zip'" - powershell -Command "Expand-Archive -Path 'rclone.zip' -DestinationPath '.\\rclone'" - for /d %%i in (.\rclone\rclone-*-windows-amd64) do ( - set "RCLONE_DIR=%%i" - ) - echo RCLONE_DIR is %RCLONE_DIR% - set "RCLONE_PATH=%CD%\%RCLONE_DIR%\rclone.exe" - echo RCLONE_PATH=%RCLONE_PATH% >> %GITHUB_ENV% - shell: cmd - - - name: Configure rclone for Google Drive - env: - COGO_SERVICE_ACCOUNT: ${{ secrets.COGO_SERVICE_ACCOUNT }} - run: | - powershell -Command "Set-Content -Path 'gdrive-service-account.json' -Value $env:COGO_SERVICE_ACCOUNT" - "%RCLONE_PATH%" config create google-drive drive scope drive service_account_file gdrive-service-account.json - shell: cmd - - - name: Upload APK to Google Drive and Get Download Link - id: upload_and_link - env: - COGO_SERVICE_ACCOUNT: ${{ secrets.COGO_SERVICE_ACCOUNT }} - run: | - @echo off - rem Find APK file in the specific build output directory - for /f "tokens=*" %%a in ('dir /s /b "app\build\outputs\apk\debug\CodeOnTheGo-*.apk"') do ( - set "APK_PATH=%%a" - ) - if not defined APK_PATH ( - echo Error: No APK file found - exit /b 1 - ) - echo Found APK: %APK_PATH% - rem Extract filename - for %%F in ("%APK_PATH%") do set "APK_FILENAME=%%~nxF" - rem Upload to Google Drive folder - "%RCLONE_PATH%" copy "%APK_PATH%" "google-drive:%FOLDER_NAME%" -v - if %errorlevel% neq 0 ( - echo Error uploading APK - exit /b 1 - ) - rem Generate a direct download link using full rclone obscure path - "%RCLONE_PATH%" link "google-drive:%FOLDER_NAME%/%APK_FILENAME%" > download_url.txt - set /p DOWNLOAD_URL=> %GITHUB_ENV% - shell: cmd - - - name: Slack Notification - run: | - @echo off - rem Use outputs from previous steps - set "TICKET_URL=https://appdevforall.atlassian.net/browse/%FOLDER_NAME%" - set "PAYLOAD={\"blocks\":[{\"type\":\"header\",\"text\":{\"type\":\"plain_text\",\"text\":\":rocket: APK Build Completed\",\"emoji\":true}},{\"type\":\"section\",\"fields\":[{\"type\":\"mrkdwn\",\"text\":\"*Branch:*\n%FOLDER_NAME%\"},{\"type\":\"mrkdwn\",\"text\":\"*Commit Message:*\n%COMMIT_MESSAGE:~0,100%\"}]},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"*Download Links:*\nAPK: %DOWNLOAD_URL%\nJira Ticket: %TICKET_URL%\"}},{\"type\":\"context\",\"elements\":[{\"type\":\"mrkdwn\",\"text\":\":information_source: Build completed successfully\"}]}]}" - powershell -Command "$payload = '%PAYLOAD%'; $body = $payload | ConvertFrom-Json; Invoke-RestMethod -Uri 'https://hooks.slack.com/services/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' -Method Post -Body ($body | ConvertTo-Json -Depth 10) -ContentType 'application/json'" - shell: cmd \ No newline at end of file diff --git a/.github/workflows/deploy_to_firebase.yml b/.github/workflows/deploy_to_firebase.yml new file mode 100644 index 0000000000..602efa3873 --- /dev/null +++ b/.github/workflows/deploy_to_firebase.yml @@ -0,0 +1,118 @@ +name: Build APK +permissions: + contents: read + actions: write +on: + pull_request: + branches: [ "stage", "feature/**" ] + paths-ignore: + - '**.md' + - 'fastlane/**' + - '.github/workflows/crowdin_contributors.yml' + workflow_dispatch: { } + +env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Signing info (if needed) + IDE_SIGNING_ALIAS: ${{ secrets.IDE_SIGNING_ALIAS }} + IDE_SIGNING_AUTH_PASS: ${{ secrets.IDE_SIGNING_AUTH_PASS }} + IDE_SIGNING_AUTH_USER: ${{ secrets.IDE_SIGNING_AUTH_USER }} + IDE_SIGNING_KEY_PASS: ${{ secrets.IDE_SIGNING_KEY_PASS }} + IDE_SIGNING_STORE_PASS: ${{ secrets.IDE_SIGNING_STORE_PASS }} + IDE_SIGNING_URL: ${{ secrets.IDE_SIGNING_URL }} + IDE_SIGNING_KEY_BIN: ${{ secrets.IDE_SIGNING_KEY_BIN }} + # Publishing credentials (if needed) + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MVN_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MVN_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MVN_SIGNING_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.MVN_SIGNING_KEY_ID }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.MVN_SIGNING_KEY_PASSWORD }} + # Build configuration + BUILD_JAVA_VERSION: '17' + BUILD_JAVA_DIST: 'temurin' + +jobs: + build_apk: + name: Build Universal APK + runs-on: macos-13 + timeout-minutes: 60 + steps: + - name: Cancel previous runs + uses: styfle/cancel-workflow-action@0.12.1 + with: + access_token: ${{ github.token }} + + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Update lib_source from Google Drive + run: | + echo "Removing existing lib_source folder..." + rm -rf lib_source + echo "Installing gdown..." + pip install gdown + echo "Downloading lib_source zip from Google Drive..." + # Replace with the actual file ID of your zip archive. + gdown --fuzzy "https://drive.google.com/uc?id=1O-oOP5_t3QlvnXGOC03w1SYakxrUi4Xk&confirm=t" -O lib_source.zip + echo "Unzipping lib_source.zip..." + unzip lib_source.zip -d lib_source + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: ${{ env.BUILD_JAVA_VERSION }} + distribution: ${{ env.BUILD_JAVA_DIST }} + + - name: Initialize submodules + run: | + git submodule init + git submodule update --remote + - name: Install CMake + run: | + brew update + brew install cmake + - name: Restore Gradle Cache + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle/wrapper/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Assemble Universal APK + run: ./gradlew assembleDebug + + - name: Extract branch folder name + id: extract_branch + run: | + # Remove "refs/heads/" and split by "/" to get the folder name (e.g. "ADFA-123") + BRANCH_NAME=${GITHUB_REF#refs/heads/} + FOLDER_NAME=${BRANCH_NAME#*/} + echo "Branch: $BRANCH_NAME" + echo "Folder Name: $FOLDER_NAME" + echo "FOLDER_NAME=$FOLDER_NAME" >> $GITHUB_ENV + + - name: Download Firebase Service Account JSON using curl + id: download_service_account + run: | + curl -L "https://jsonblob.com/api/jsonBlob/1354004779097055232" -o firebase-service-account.json + json=$(tr -d '\n' < firebase-service-account.json) + echo "json=$json" >> $GITHUB_OUTPUT + + - name: Upload APK to Firebase App Distribution + uses: wzieba/Firebase-Distribution-Github-Action@v1 + with: + appId: codeonthego-64a92 + serviceCredentialsFileContent: ${{ steps.download_service_account.outputs.json }} + groups: testers + file: app/build/outputs/apk/debug/CodeOnTheGo-*.apk + releaseNotes: "Commit Message: ${{ env.COMMIT_MESSAGE }}" + - name: Slack Notification + run: | + # Compose a Slack message with emojis and the download URL + MESSAGE=":tada: *Build Completed! And deployed to firebase!* :rocket:Jira Ticket: https://appdevforall.atlassian.net/browse/${FOLDER_NAME}" + curl -X POST -H 'Content-type: application/json' \ + --data "{\"text\": \"${MESSAGE}\"}" \ + https://hooks.slack.com/services/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 \ No newline at end of file diff --git a/.github/workflows/instrumented_test.yml b/.github/workflows/instrumented_test.yml new file mode 100644 index 0000000000..01b024e24b --- /dev/null +++ b/.github/workflows/instrumented_test.yml @@ -0,0 +1,72 @@ +#name: Instrumented Tests +#permissions: +# contents: write +# actions: write +#on: +# push: +# branches: [ "stage", "feature/**" ] +# pull_request: +# branches: [ "stage", "feature/**" ] +# workflow_dispatch: +# +#env: +# BUILD_JAVA_VERSION: '17' +# BUILD_JAVA_DIST: 'temurin' +# +#jobs: +# run_instrumented_tests: +# name: Run Instrumented Tests +# runs-on: macos-latest +# steps: +# - name: Cancel previous runs +# uses: styfle/cancel-workflow-action@0.12.1 +# with: +# access_token: ${{ github.token }} +# +# - name: Checkout code +# uses: actions/checkout@v4 +# with: +# fetch-depth: 0 +# +# - name: Configure Git safe directory +# run: | +# git config --global --add safe.directory "${{ github.workspace }}" +# git config --global core.longpaths true +# shell: bash +# +# - name: Initialize submodules +# run: | +# git submodule init +# git submodule update --remote +# shell: bash +# +# - name: Install Git LFS +# run: | +# git lfs install +# git lfs pull +# shell: bash +# +# - name: Set up JDK 17 +# uses: actions/setup-java@v4 +# with: +# java-version: ${{ env.BUILD_JAVA_VERSION }} +# distribution: ${{ env.BUILD_JAVA_DIST }} +# +# # Use the ReactiveCircus Android Emulator Runner action to start the emulator and run tests. +# - name: Run Instrumented Tests on Emulator +# uses: reactivecircus/android-emulator-runner@v2 +# with: +# api-level: 30 +# arch: "x86_64" +# script: | +# adb devices +# ./gradlew app:cAT "-Pandroid.testInstrumentationRunnerArguments.class=com.itsaky.androidide.OrderedTestSuite" --stacktrace +# env: +# ANDROIDIDE_TEST: true +# +# - name: Upload Test Reports +# if: ${{ always() }} +# uses: actions/upload-artifact@v4 +# with: +# name: test-results-instrumented +# path: '**/build/reports/tests/' diff --git a/LayoutEditor b/LayoutEditor index 9cb5395285..a15eca0245 160000 --- a/LayoutEditor +++ b/LayoutEditor @@ -1 +1 @@ -Subproject commit 9cb53952853fd2e1a8f05cca124ca52986095c64 +Subproject commit a15eca02452404c6a1bf9fe12a728932a5fe33da