From e0da4d6bf0bd83f2c7e19a2defe7d584d28be248 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 11 Jun 2024 15:18:53 +0200 Subject: [PATCH 1/8] Add shellcheck to quality checks --- .github/workflows/quality.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index 17c5e1de3d..e6e127702c 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -187,6 +187,18 @@ jobs: - name: Run Knit run: ./gradlew knitCheck $CI_GRADLE_ARG_PROPERTIES + # Note: to auto fix issues you can use the following command: + # shellcheck -f diff | git apply + shellcheck: + name: Check shell scripts + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Run shellcheck + uses: ludeeus/action-shellcheck@2.0.0 + with: + scandir: ./tools + upload_reports: name: Project Check Suite runs-on: ubuntu-latest From 31cfae0578140e5bbed48f81fc2dab1a663cfb1a Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 11 Jun 2024 15:27:02 +0200 Subject: [PATCH 2/8] Run shellcheck autofix. --- tools/check/check_code_quality.sh | 8 +- tools/docs/generateModuleGraph.sh | 8 +- tools/release/release.sh | 136 +++++++++++++------------- tools/rte/build_rte.sh | 36 +++---- tools/sdk/build_rust_sdk.sh | 20 ++-- tools/templates/generate_templates.sh | 4 +- 6 files changed, 106 insertions(+), 106 deletions(-) diff --git a/tools/check/check_code_quality.sh b/tools/check/check_code_quality.sh index f37d661379..a72d2f4a40 100755 --- a/tools/check/check_code_quality.sh +++ b/tools/check/check_code_quality.sh @@ -41,9 +41,9 @@ echo echo "Search for forbidden patterns in Kotlin source files..." # list all Kotlin folders of the project. -allKotlinDirs=`find . -type d |grep -v build |grep -v \.git |grep -v \.gradle |grep kotlin$` +allKotlinDirs=$(find . -type d |grep -v build |grep -v \.git |grep -v \.gradle |grep kotlin$) -${searchForbiddenStringsScript} ./tools/check/forbidden_strings_in_code.txt $allKotlinDirs +${searchForbiddenStringsScript} ./tools/check/forbidden_strings_in_code.txt "$allKotlinDirs" resultForbiddenStringInCode=$? @@ -51,9 +51,9 @@ echo echo "Search for forbidden patterns in XML resource files..." # list all res folders of the project. -allResDirs=`find . -type d |grep -v build |grep -v \.git |grep -v \.gradle |grep /res$` +allResDirs=$(find . -type d |grep -v build |grep -v \.git |grep -v \.gradle |grep /res$) -${searchForbiddenStringsScript} ./tools/check/forbidden_strings_in_xml.txt $allResDirs +${searchForbiddenStringsScript} ./tools/check/forbidden_strings_in_xml.txt "$allResDirs" resultForbiddenStringInXml=$? diff --git a/tools/docs/generateModuleGraph.sh b/tools/docs/generateModuleGraph.sh index 2ce7d5b26b..099ec4cddb 100755 --- a/tools/docs/generateModuleGraph.sh +++ b/tools/docs/generateModuleGraph.sh @@ -17,7 +17,7 @@ # ## Dependency graph https://github.com/savvasdalkitsis/module-dependency-graph -dotPath=`pwd`/docs/images/module_graph.dot -pngPath=`pwd`/docs/images/module_graph.png -./gradlew graphModules -PdotFilePath=${dotPath} -PgraphOutputFilePath=${pngPath} -PautoOpenGraph=false -rm ${dotPath} +dotPath=$(pwd)/docs/images/module_graph.dot +pngPath=$(pwd)/docs/images/module_graph.png +./gradlew graphModules -PdotFilePath="${dotPath}" -PgraphOutputFilePath="${pngPath}" -PautoOpenGraph=false +rm "${dotPath}" diff --git a/tools/release/release.sh b/tools/release/release.sh index 771f70cd9f..98e24d75a0 100755 --- a/tools/release/release.sh +++ b/tools/release/release.sh @@ -83,7 +83,7 @@ if [[ ! -d ${buildToolsPath} ]]; then fi # Check if git flow is enabled -gitFlowDevelop=`git config gitflow.branch.develop` +gitFlowDevelop=$(git config gitflow.branch.develop) if [[ ${gitFlowDevelop} != "" ]] then printf "Git flow is initialized\n" @@ -105,23 +105,23 @@ git pull printf "\n================================================================================\n" # Guessing version to propose a default version versionsFile="./plugins/src/main/kotlin/Versions.kt" -versionMajorCandidate=`grep "val versionMajor" ${versionsFile} | cut -d " " -f6` -versionMinorCandidate=`grep "val versionMinor" ${versionsFile} | cut -d " " -f6` -versionPatchCandidate=`grep "val versionPatch" ${versionsFile} | cut -d " " -f6` +versionMajorCandidate=$(grep "val versionMajor" ${versionsFile} | cut -d " " -f6) +versionMinorCandidate=$(grep "val versionMinor" ${versionsFile} | cut -d " " -f6) +versionPatchCandidate=$(grep "val versionPatch" ${versionsFile} | cut -d " " -f6) versionCandidate="${versionMajorCandidate}.${versionMinorCandidate}.${versionPatchCandidate}" read -p "Please enter the release version (example: ${versionCandidate}). Just press enter if ${versionCandidate} is correct. " version version=${version:-${versionCandidate}} # extract major, minor and patch for future use -versionMajor=`echo ${version} | cut -d "." -f1` -versionMinor=`echo ${version} | cut -d "." -f2` -versionPatch=`echo ${version} | cut -d "." -f3` +versionMajor=$(echo "${version}" | cut -d "." -f1) +versionMinor=$(echo "${version}" | cut -d "." -f2) +versionPatch=$(echo "${version}" | cut -d "." -f3) nextPatchVersion=$((versionPatch + 1)) printf "\n================================================================================\n" printf "Starting the release ${version}\n" -git flow release start ${version} +git flow release start "${version}" # Note: in case the release is already started and the script is started again, checkout the release branch again. ret=$? @@ -154,15 +154,15 @@ git commit -a -m "Changelog for version ${version}" printf "\n================================================================================\n" printf "Creating fastlane file...\n" -printf -v versionMajor2Digits "%02d" ${versionMajor} -printf -v versionMinor2Digits "%02d" ${versionMinor} -printf -v versionPatch2Digits "%02d" ${versionPatch} +printf -v versionMajor2Digits "%02d" "${versionMajor}" +printf -v versionMinor2Digits "%02d" "${versionMinor}" +printf -v versionPatch2Digits "%02d" "${versionPatch}" fastlaneFile="4${versionMajor2Digits}${versionMinor2Digits}${versionPatch2Digits}0.txt" fastlanePathFile="./fastlane/metadata/android/en-US/changelogs/${fastlaneFile}" -printf "Main changes in this version: TODO.\nFull changelog: https://github.com/element-hq/element-x-android/releases" > ${fastlanePathFile} +printf "Main changes in this version: TODO.\nFull changelog: https://github.com/element-hq/element-x-android/releases" > "${fastlanePathFile}" read -p "I have created the file ${fastlanePathFile}, please edit it and press enter to continue. " -git add ${fastlanePathFile} +git add "${fastlanePathFile}" git commit -a -m "Adding fastlane file for version ${version}" printf "\n================================================================================\n" @@ -173,7 +173,7 @@ printf "\n====================================================================== read -p "Done, push the branch 'main' and the new tag (yes/no) default to yes? " doPush doPush=${doPush:-yes} -if [ ${doPush} == "yes" ]; then +if [ "${doPush}" == "yes" ]; then printf "Pushing branch 'main' and tag 'v${version}'...\n" git push origin main git push origin "v${version}" @@ -202,7 +202,7 @@ printf "\n====================================================================== read -p "Done, push the branch 'develop' (yes/no) default to yes? (A rebase may be necessary in case develop got new commits) " doPush doPush=${doPush:-yes} -if [ ${doPush} == "yes" ]; then +if [ "${doPush}" == "yes" ]; then printf "Pushing branch 'develop'...\n" git push origin develop else @@ -220,74 +220,74 @@ printf "\n====================================================================== printf "Downloading the artifacts...\n" python3 ./tools/github/download_all_github_artifacts.py \ - --token ${gitHubToken} \ - --runUrl ${runUrl} \ - --directory ${targetPath} + --token "${gitHubToken}" \ + --runUrl "${runUrl}" \ + --directory "${targetPath}" printf "\n================================================================================\n" printf "Unzipping the F-Droid artifact...\n" fdroidTargetPath="${targetPath}/fdroid" -unzip ${targetPath}/elementx-app-fdroid-apks-unsigned.zip -d ${fdroidTargetPath} +unzip "${targetPath}"/elementx-app-fdroid-apks-unsigned.zip -d "${fdroidTargetPath}" printf "\n================================================================================\n" printf "Signing the FDroid APKs...\n" -cp ${fdroidTargetPath}/app-fdroid-arm64-v8a-release.apk \ - ${fdroidTargetPath}/app-fdroid-arm64-v8a-release-signed.apk -${buildToolsPath}/apksigner sign \ +cp "${fdroidTargetPath}"/app-fdroid-arm64-v8a-release.apk \ + "${fdroidTargetPath}"/app-fdroid-arm64-v8a-release-signed.apk +"${buildToolsPath}"/apksigner sign \ -v \ - --ks ${keyStorePath} \ - --ks-pass pass:${keyStorePassword} \ + --ks "${keyStorePath}" \ + --ks-pass pass:"${keyStorePassword}" \ --ks-key-alias elementx \ - --key-pass pass:${keyPassword} \ + --key-pass pass:"${keyPassword}" \ --min-sdk-version ${minSdkVersion} \ - ${fdroidTargetPath}/app-fdroid-arm64-v8a-release-signed.apk + "${fdroidTargetPath}"/app-fdroid-arm64-v8a-release-signed.apk -cp ${fdroidTargetPath}/app-fdroid-armeabi-v7a-release.apk \ - ${fdroidTargetPath}/app-fdroid-armeabi-v7a-release-signed.apk -${buildToolsPath}/apksigner sign \ +cp "${fdroidTargetPath}"/app-fdroid-armeabi-v7a-release.apk \ + "${fdroidTargetPath}"/app-fdroid-armeabi-v7a-release-signed.apk +"${buildToolsPath}"/apksigner sign \ -v \ - --ks ${keyStorePath} \ - --ks-pass pass:${keyStorePassword} \ + --ks "${keyStorePath}" \ + --ks-pass pass:"${keyStorePassword}" \ --ks-key-alias elementx \ - --key-pass pass:${keyPassword} \ + --key-pass pass:"${keyPassword}" \ --min-sdk-version ${minSdkVersion} \ - ${fdroidTargetPath}/app-fdroid-armeabi-v7a-release-signed.apk + "${fdroidTargetPath}"/app-fdroid-armeabi-v7a-release-signed.apk -cp ${fdroidTargetPath}/app-fdroid-x86-release.apk \ - ${fdroidTargetPath}/app-fdroid-x86-release-signed.apk -${buildToolsPath}/apksigner sign \ +cp "${fdroidTargetPath}"/app-fdroid-x86-release.apk \ + "${fdroidTargetPath}"/app-fdroid-x86-release-signed.apk +"${buildToolsPath}"/apksigner sign \ -v \ - --ks ${keyStorePath} \ - --ks-pass pass:${keyStorePassword} \ + --ks "${keyStorePath}" \ + --ks-pass pass:"${keyStorePassword}" \ --ks-key-alias elementx \ - --key-pass pass:${keyPassword} \ + --key-pass pass:"${keyPassword}" \ --min-sdk-version ${minSdkVersion} \ - ${fdroidTargetPath}/app-fdroid-x86-release-signed.apk + "${fdroidTargetPath}"/app-fdroid-x86-release-signed.apk -cp ${fdroidTargetPath}/app-fdroid-x86_64-release.apk \ - ${fdroidTargetPath}/app-fdroid-x86_64-release-signed.apk -${buildToolsPath}/apksigner sign \ +cp "${fdroidTargetPath}"/app-fdroid-x86_64-release.apk \ + "${fdroidTargetPath}"/app-fdroid-x86_64-release-signed.apk +"${buildToolsPath}"/apksigner sign \ -v \ - --ks ${keyStorePath} \ - --ks-pass pass:${keyStorePassword} \ + --ks "${keyStorePath}" \ + --ks-pass pass:"${keyStorePassword}" \ --ks-key-alias elementx \ - --key-pass pass:${keyPassword} \ + --key-pass pass:"${keyPassword}" \ --min-sdk-version ${minSdkVersion} \ - ${fdroidTargetPath}/app-fdroid-x86_64-release-signed.apk + "${fdroidTargetPath}"/app-fdroid-x86_64-release-signed.apk printf "\n================================================================================\n" printf "Please check the information below:\n" printf "File app-fdroid-arm64-v8a-release-signed.apk:\n" -${buildToolsPath}/aapt dump badging ${fdroidTargetPath}/app-fdroid-arm64-v8a-release-signed.apk | grep package +"${buildToolsPath}"/aapt dump badging "${fdroidTargetPath}"/app-fdroid-arm64-v8a-release-signed.apk | grep package printf "File app-fdroid-armeabi-v7a-release-signed.apk:\n" -${buildToolsPath}/aapt dump badging ${fdroidTargetPath}/app-fdroid-armeabi-v7a-release-signed.apk | grep package +"${buildToolsPath}"/aapt dump badging "${fdroidTargetPath}"/app-fdroid-armeabi-v7a-release-signed.apk | grep package printf "File app-fdroid-x86-release-signed.apk:\n" -${buildToolsPath}/aapt dump badging ${fdroidTargetPath}/app-fdroid-x86-release-signed.apk | grep package +"${buildToolsPath}"/aapt dump badging "${fdroidTargetPath}"/app-fdroid-x86-release-signed.apk | grep package printf "File app-fdroid-x86_64-release-signed.apk:\n" -${buildToolsPath}/aapt dump badging ${fdroidTargetPath}/app-fdroid-x86_64-release-signed.apk | grep package +"${buildToolsPath}"/aapt dump badging "${fdroidTargetPath}"/app-fdroid-x86_64-release-signed.apk | grep package printf "\n" read -p "Does it look correct? Press enter when it's done." @@ -299,7 +299,7 @@ printf "\n====================================================================== printf "Unzipping the Gplay artifact...\n" gplayTargetPath="${targetPath}/gplay" -unzip ${targetPath}/elementx-app-gplay-bundle-unsigned.zip -d ${gplayTargetPath} +unzip "${targetPath}"/elementx-app-gplay-bundle-unsigned.zip -d "${gplayTargetPath}" unsignedBundlePath="${gplayTargetPath}/app-gplay-release.aab" signedBundlePath="${gplayTargetPath}/app-gplay-release-signed.aab" @@ -307,24 +307,24 @@ signedBundlePath="${gplayTargetPath}/app-gplay-release-signed.aab" printf "\n================================================================================\n" printf "Signing file ${unsignedBundlePath} with build-tools version ${buildToolsVersion} for min SDK version ${minSdkVersion}...\n" -cp ${unsignedBundlePath} ${signedBundlePath} +cp "${unsignedBundlePath}" "${signedBundlePath}" -${buildToolsPath}/apksigner sign \ +"${buildToolsPath}"/apksigner sign \ -v \ - --ks ${keyStorePath} \ - --ks-pass pass:${keyStorePassword} \ + --ks "${keyStorePath}" \ + --ks-pass pass:"${keyStorePassword}" \ --ks-key-alias elementx \ - --key-pass pass:${keyPassword} \ + --key-pass pass:"${keyPassword}" \ --min-sdk-version ${minSdkVersion} \ - ${signedBundlePath} + "${signedBundlePath}" printf "\n================================================================================\n" printf "Please check the information below:\n" printf "Version code: " -bundletool dump manifest --bundle=${signedBundlePath} --xpath=/manifest/@android:versionCode +bundletool dump manifest --bundle="${signedBundlePath}" --xpath=/manifest/@android:versionCode printf "Version name: " -bundletool dump manifest --bundle=${signedBundlePath} --xpath=/manifest/@android:versionName +bundletool dump manifest --bundle="${signedBundlePath}" --xpath=/manifest/@android:versionName printf "\n" read -p "Does it look correct? Press enter to continue. " @@ -336,17 +336,17 @@ printf "\n====================================================================== read -p "Do you want to build the APKs from the app bundle? You need to do this step if you want to install the application to your device. (yes/no) default to yes " doBuildApks doBuildApks=${doBuildApks:-yes} -if [ ${doBuildApks} == "yes" ]; then +if [ "${doBuildApks}" == "yes" ]; then printf "Building apks...\n" - bundletool build-apks --bundle=${signedBundlePath} --output=${gplayTargetPath}/elementx.apks \ + bundletool build-apks --bundle="${signedBundlePath}" --output="${gplayTargetPath}"/elementx.apks \ --ks=./app/signature/debug.keystore --ks-pass=pass:android --ks-key-alias=androiddebugkey --key-pass=pass:android \ --overwrite read -p "Do you want to install the application to your device? Make sure there is one (and only one!) connected device first. (yes/no) default to yes " doDeploy doDeploy=${doDeploy:-yes} - if [ ${doDeploy} == "yes" ]; then + if [ "${doDeploy}" == "yes" ]; then printf "Installing apk for your device...\n" - bundletool install-apks --apks=${gplayTargetPath}/elementx.apks + bundletool install-apks --apks="${gplayTargetPath}"/elementx.apks read -p "Please run the application on your phone to check that the upgrade went well. Press enter to continue. " else printf "APK will not be deployed!\n" @@ -373,7 +373,7 @@ printf "\n====================================================================== body="%3C%21--%20Copy%20paste%20the%20section%20of%20the%20file%20CHANGES.md%20for%20this%20release%20here%20--%3E" githubCreateReleaseLink="https://github.com/element-hq/element-x-android/releases/new?tag=v${version}&title=Element%20X%20Android%20v${version}&body=${body}" printf "Creating the release on gitHub.\n" -printf -- "Open this link: %s\n" ${githubCreateReleaseLink} +printf -- "Open this link: %s\n" "${githubCreateReleaseLink}" printf "Then\n" printf " - copy paste the section of the file CHANGES.md for this release.\n" printf " - click on the 'Generate releases notes' button.\n" @@ -392,12 +392,12 @@ if [[ -z "${elementBotToken}" ]]; then else read -p "Send this message to the room (yes/no) default to yes? " doSend doSend=${doSend:-yes} - if [ ${doSend} == "yes" ]; then + if [ "${doSend}" == "yes" ]; then printf "Sending message...\n" - transactionId=`openssl rand -hex 16` + transactionId=$(openssl rand -hex 16) # Element Android internal matrixRoomId="!LiSLXinTDCsepePiYW:matrix.org" - curl -X PUT --data $"{\"msgtype\":\"m.text\",\"body\":\"${message}\"}" -H "Authorization: Bearer ${elementBotToken}" https://matrix-client.matrix.org/_matrix/client/r0/rooms/${matrixRoomId}/send/m.room.message/\$local.${transactionId} + curl -X PUT --data "${\"msgtype\":\"m.text\",\"body\":\"${message}\"}" -H "Authorization: Bearer ${elementBotToken}" https://matrix-client.matrix.org/_matrix/client/r0/rooms/${matrixRoomId}/send/m.room.message/\$local."${transactionId}" else printf "Message not sent, please send it manually!\n" fi diff --git a/tools/rte/build_rte.sh b/tools/rte/build_rte.sh index 7dda29fa3c..9ad52fce56 100755 --- a/tools/rte/build_rte.sh +++ b/tools/rte/build_rte.sh @@ -8,11 +8,11 @@ read -p "Do you want to build the RTE from local source (yes/no) default to yes? buildLocal=${buildLocal:-yes} date=$(gdate +%Y%m%d%H%M%S) -elementPwd=`pwd` +elementPwd=$(pwd) # Ask for the RTE local source path # if folder rte/ exists, use it as default -if [ ${buildLocal} == "yes" ]; then +if [ "${buildLocal}" == "yes" ]; then read -p "Please enter the path to the Rust SDK local source, default to ../matrix-rich-text-editor: " rtePath rtePath=${rtePath:-../matrix-rich-text-editor/} if [ ! -d "${rtePath}" ]; then @@ -25,21 +25,21 @@ else read -p "Please enter the Rust SDK branch, default to main " rteBranch rteBranch=${rteBranch:-main} cd .. - git clone ${rteUrl} matrix-rich-text-editor-$date - cd matrix-rich-text-editor-$date - git checkout ${rteBranch} + git clone "${rteUrl}" matrix-rich-text-editor-"$date" + cd matrix-rich-text-editor-"$date" + git checkout "${rteBranch}" rtePath=$(pwd) - cd ${elementPwd} + cd "${elementPwd}" fi -cd ${rtePath} +cd "${rtePath}" git status read -p "Will build with this version of the RTE ^. Is it correct (yes/no) default to yes? " rteCorrect rteCorrect=${rteCorrect:-yes} -if [ ${rteCorrect} != "yes" ]; then +if [ "${rteCorrect}" != "yes" ]; then exit 0 fi @@ -47,31 +47,31 @@ fi read -p "Do you want to build the app after (yes/no) default to yes? " buildApp buildApp=${buildApp:-yes} -cd ${elementPwd} +cd "${elementPwd}" -cd $rtePath +cd "$rtePath" printf "\nBuilding the RTE for aarch64...\n\n" make android-bindings-aarch64 cd platforms/android ./gradlew clean :library:assembleRelease :library-compose:assembleRelease -cp ./library/build/outputs/aar/library-release.aar $elementPwd/libraries/textcomposer/lib/library.aar -cp ./library-compose/build/outputs/aar/library-compose-release.aar $elementPwd/libraries/textcomposer/lib/library-compose.aar +cp ./library/build/outputs/aar/library-release.aar "$elementPwd"/libraries/textcomposer/lib/library.aar +cp ./library-compose/build/outputs/aar/library-compose-release.aar "$elementPwd"/libraries/textcomposer/lib/library-compose.aar -cd ${elementPwd} +cd "${elementPwd}" mkdir -p ./libraries/textcomposer/lib/versions -cp ./libraries/textcomposer/lib/library.aar ./libraries/textcomposer/lib/versions/library-${date}.aar -cp ./libraries/textcomposer/lib/library-compose.aar ./libraries/textcomposer/lib/versions/library-compose-${date}.aar +cp ./libraries/textcomposer/lib/library.aar ./libraries/textcomposer/lib/versions/library-"${date}".aar +cp ./libraries/textcomposer/lib/library-compose.aar ./libraries/textcomposer/lib/versions/library-compose-"${date}".aar -if [ ${buildApp} == "yes" ]; then +if [ "${buildApp}" == "yes" ]; then printf "\nBuilding the application...\n\n" ./gradlew assembleDebug fi -if [ ${buildLocal} == "no" ]; then +if [ "${buildLocal}" == "no" ]; then printf "\nCleaning up...\n\n" - rm -rf ../matrix-rich-text-editor-$date + rm -rf ../matrix-rich-text-editor-"$date" fi printf "\nDone!\n" diff --git a/tools/sdk/build_rust_sdk.sh b/tools/sdk/build_rust_sdk.sh index dc2a74e1ff..2e4be2e6aa 100755 --- a/tools/sdk/build_rust_sdk.sh +++ b/tools/sdk/build_rust_sdk.sh @@ -8,11 +8,11 @@ read -p "Do you want to build the Rust SDK from local source (yes/no) default to buildLocal=${buildLocal:-yes} date=$(gdate +%Y%m%d%H%M%S) -elementPwd=`pwd` +elementPwd=$(pwd) # Ask for the Rust SDK local source path # if folder rustSdk/ exists, use it as default -if [ ${buildLocal} == "yes" ]; then +if [ "${buildLocal}" == "yes" ]; then read -p "Please enter the path to the Rust SDK local source, default to ../matrix-rust-sdk" rustSdkPath rustSdkPath=${rustSdkPath:-../matrix-rust-sdk/} if [ ! -d "${rustSdkPath}" ]; then @@ -25,9 +25,9 @@ else read -p "Please enter the Rust SDK branch, default to main " rustSdkBranch rustSdkBranch=${rustSdkBranch:-main} cd .. - git clone ${rustSdkUrl} matrix-rust-sdk-$date - cd matrix-rust-sdk-$date - git checkout ${rustSdkBranch} + git clone "${rustSdkUrl}" matrix-rust-sdk-"$date" + cd matrix-rust-sdk-"$date" + git checkout "${rustSdkBranch}" rustSdkPath=$(pwd) cd "${elementPwd}" fi @@ -39,7 +39,7 @@ git status read -p "Will build with this version of the Rust SDK ^. Is it correct (yes/no) default to yes? " sdkCorrect sdkCorrect=${sdkCorrect:-yes} -if [ ${sdkCorrect} != "yes" ]; then +if [ "${sdkCorrect}" != "yes" ]; then exit 0 fi @@ -67,17 +67,17 @@ printf "\nBuilding the SDK for aarch64-linux-android...\n\n" cd "${elementPwd}" mv ./libraries/rustsdk/sdk-android-debug.aar ./libraries/rustsdk/matrix-rust-sdk.aar mkdir -p ./libraries/rustsdk/sdks -cp ./libraries/rustsdk/matrix-rust-sdk.aar ./libraries/rustsdk/sdks/matrix-rust-sdk-${date}.aar +cp ./libraries/rustsdk/matrix-rust-sdk.aar ./libraries/rustsdk/sdks/matrix-rust-sdk-"${date}".aar -if [ ${buildApp} == "yes" ]; then +if [ "${buildApp}" == "yes" ]; then printf "\nBuilding the application...\n\n" ./gradlew assembleDebug fi -if [ ${buildLocal} == "no" ]; then +if [ "${buildLocal}" == "no" ]; then printf "\nCleaning up...\n\n" - rm -rf ../matrix-rust-sdk-$date + rm -rf ../matrix-rust-sdk-"$date" fi printf "\nDone!\n" diff --git a/tools/templates/generate_templates.sh b/tools/templates/generate_templates.sh index 9b59ea69f8..1c9334446c 100755 --- a/tools/templates/generate_templates.sh +++ b/tools/templates/generate_templates.sh @@ -22,6 +22,6 @@ echo "Zipping the contents of the 'files' directory..." mkdir -p tmp rm -f ./tmp/file_templates.zip -pushd ./tools/templates/files +pushd ./tools/templates/files || exit zip -r ../../../tmp/file_templates.zip . -popd +popd || exit From 9be8ab7f38d9d6793716b64ba83869ac5e99ef4f Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 11 Jun 2024 15:39:05 +0200 Subject: [PATCH 3/8] Fix error --- tools/release/release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/release/release.sh b/tools/release/release.sh index 98e24d75a0..2e7999fd21 100755 --- a/tools/release/release.sh +++ b/tools/release/release.sh @@ -397,7 +397,7 @@ else transactionId=$(openssl rand -hex 16) # Element Android internal matrixRoomId="!LiSLXinTDCsepePiYW:matrix.org" - curl -X PUT --data "${\"msgtype\":\"m.text\",\"body\":\"${message}\"}" -H "Authorization: Bearer ${elementBotToken}" https://matrix-client.matrix.org/_matrix/client/r0/rooms/${matrixRoomId}/send/m.room.message/\$local."${transactionId}" + curl -X PUT --data "{\"msgtype\":\"m.text\",\"body\":\"${message}\"}" -H "Authorization: Bearer ${elementBotToken}" https://matrix-client.matrix.org/_matrix/client/r0/rooms/${matrixRoomId}/send/m.room.message/\$local."${transactionId}" else printf "Message not sent, please send it manually!\n" fi From 0ddf2ba7b280c1886758b0d004f9971d2793d083 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 11 Jun 2024 17:50:45 +0200 Subject: [PATCH 4/8] shellcheck: only fails on error for now. --- .github/workflows/quality.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index e6e127702c..2f044aafa4 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -198,6 +198,7 @@ jobs: uses: ludeeus/action-shellcheck@2.0.0 with: scandir: ./tools + severity: error upload_reports: name: Project Check Suite From 060b733ce48f8bcf9820c6eb6c684ea563647381 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 11 Jun 2024 17:51:32 +0200 Subject: [PATCH 5/8] shellcheck: only fails on warnings for now. --- .github/workflows/quality.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index 2f044aafa4..01261f2918 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -198,7 +198,7 @@ jobs: uses: ludeeus/action-shellcheck@2.0.0 with: scandir: ./tools - severity: error + severity: warning upload_reports: name: Project Check Suite From 89e0d94d86afc4d7bdc304861007d03548d5958b Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 11 Jun 2024 17:58:24 +0200 Subject: [PATCH 6/8] Fix warning: more redirection to end. --- tools/localazy/downloadStrings.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/localazy/downloadStrings.sh b/tools/localazy/downloadStrings.sh index 6de32527a5..a80b4228f2 100755 --- a/tools/localazy/downloadStrings.sh +++ b/tools/localazy/downloadStrings.sh @@ -51,10 +51,10 @@ fi set +e echo "Moving files from values-id to values-in..." -find . -type d -name 'values-id' -execdir mv {}/translations.xml {}/../values-in/translations.xml 2> /dev/null \; +find . -type d -name 'values-id' -execdir mv {}/translations.xml {}/../values-in/translations.xml \; 2> /dev/null echo "Deleting all the folders values-id..." -find . -type d -name 'values-id' -exec rm -rf {} 2> /dev/null \; +find . -type d -name 'values-id' -exec rm -rf {} \; 2> /dev/null set -e echo "Checking forbidden terms..." From 55a1ac4bb54ca758445cbd73b2f557787d297921 Mon Sep 17 00:00:00 2001 From: Jorge Martin Espinosa Date: Wed, 12 Jun 2024 12:20:43 +0200 Subject: [PATCH 7/8] Fix tracing configuration in debug and nightlies (#3019) * Fix tracing configuration in debug and nightlies: - Debug will now write the logs to disk too. - Nightly will be able to customise tracing filters. - Improved the configure tracing and bug report screens. * Update screenshots * Add changelog --------- Co-authored-by: ElementBot --- .../x/initializer/TracingInitializer.kt | 50 +++++++++++-------- changelog.d/3016.bugfix | 5 ++ .../developer/tracing/ConfigureTracingView.kt | 8 ++- .../tracing/TargetLogLevelMapBuilder.kt | 5 +- .../tracing/ConfigureTracingPresenterTest.kt | 9 ++-- .../rageshake/impl/bugreport/BugReportView.kt | 13 ++++- .../matrix/impl/di/TracingMatrixModule.kt | 39 +++++++++++++++ ...ingView-Day-5_6_null_0,NEXUS_5,1.0,en].png | 4 +- ...gView-Night-5_7_null_0,NEXUS_5,1.0,en].png | 4 +- 9 files changed, 101 insertions(+), 36 deletions(-) create mode 100644 changelog.d/3016.bugfix create mode 100644 libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/di/TracingMatrixModule.kt diff --git a/app/src/main/kotlin/io/element/android/x/initializer/TracingInitializer.kt b/app/src/main/kotlin/io/element/android/x/initializer/TracingInitializer.kt index 3c938e2a6d..7c94af4619 100644 --- a/app/src/main/kotlin/io/element/android/x/initializer/TracingInitializer.kt +++ b/app/src/main/kotlin/io/element/android/x/initializer/TracingInitializer.kt @@ -22,7 +22,9 @@ import androidx.preference.PreferenceManager import androidx.startup.Initializer import io.element.android.features.preferences.impl.developer.tracing.SharedPreferencesTracingConfigurationStore import io.element.android.features.preferences.impl.developer.tracing.TargetLogLevelMapBuilder +import io.element.android.features.rageshake.api.reporter.BugReporter import io.element.android.libraries.architecture.bindings +import io.element.android.libraries.core.meta.BuildType import io.element.android.libraries.matrix.api.tracing.TracingConfiguration import io.element.android.libraries.matrix.api.tracing.TracingFilterConfigurations import io.element.android.libraries.matrix.api.tracing.WriteToFilesConfiguration @@ -36,31 +38,27 @@ class TracingInitializer : Initializer { val tracingService = appBindings.tracingService() val bugReporter = appBindings.bugReporter() Timber.plant(tracingService.createTimberTree()) - val tracingConfiguration = if (BuildConfig.DEBUG) { - val prefs = PreferenceManager.getDefaultSharedPreferences(context) - val store = SharedPreferencesTracingConfigurationStore(prefs) - val builder = TargetLogLevelMapBuilder(store) + val tracingConfiguration = if (BuildConfig.BUILD_TYPE == BuildType.RELEASE.name) { TracingConfiguration( - filterConfiguration = TracingFilterConfigurations.custom(builder.getCurrentMap()), - writesToLogcat = true, - writesToFilesConfiguration = WriteToFilesConfiguration.Disabled + filterConfiguration = TracingFilterConfigurations.release, + writesToLogcat = false, + writesToFilesConfiguration = defaultWriteToDiskConfiguration(bugReporter), ) } else { - val config = if (BuildConfig.BUILD_TYPE == "nightly") { - TracingFilterConfigurations.nightly - } else { - TracingFilterConfigurations.release - } + val prefs = PreferenceManager.getDefaultSharedPreferences(context) + val store = SharedPreferencesTracingConfigurationStore(prefs) + val builder = TargetLogLevelMapBuilder( + tracingConfigurationStore = store, + defaultConfig = if (BuildConfig.BUILD_TYPE == BuildType.NIGHTLY.name) { + TracingFilterConfigurations.nightly + } else { + TracingFilterConfigurations.debug + } + ) TracingConfiguration( - filterConfiguration = config, - writesToLogcat = false, - writesToFilesConfiguration = WriteToFilesConfiguration.Enabled( - directory = bugReporter.logDirectory().absolutePath, - filenamePrefix = "logs", - filenameSuffix = null, - // Keep a minimum of 1 week of log files. - numberOfFiles = 7 * 24, - ) + filterConfiguration = TracingFilterConfigurations.custom(builder.getCurrentMap()), + writesToLogcat = BuildConfig.DEBUG, + writesToFilesConfiguration = defaultWriteToDiskConfiguration(bugReporter), ) } bugReporter.setCurrentTracingFilter(tracingConfiguration.filterConfiguration.filter) @@ -69,5 +67,15 @@ class TracingInitializer : Initializer { Os.setenv("RUST_BACKTRACE", "1", true) } + private fun defaultWriteToDiskConfiguration(bugReporter: BugReporter): WriteToFilesConfiguration.Enabled { + return WriteToFilesConfiguration.Enabled( + directory = bugReporter.logDirectory().absolutePath, + filenamePrefix = "logs", + filenameSuffix = null, + // Keep a minimum of 1 week of log files. + numberOfFiles = 7 * 24, + ) + } + override fun dependencies(): List>> = mutableListOf() } diff --git a/changelog.d/3016.bugfix b/changelog.d/3016.bugfix new file mode 100644 index 0000000000..df7b7da7dd --- /dev/null +++ b/changelog.d/3016.bugfix @@ -0,0 +1,5 @@ +Fix tracing configuration in debug and nightlies: + +- Debug will now write the logs to disk too. +- Nightly will be able to customise tracing filters. +- Improved the configure tracing and bug report screens. diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/tracing/ConfigureTracingView.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/tracing/ConfigureTracingView.kt index c44b9e4ad5..f3d1d946c4 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/tracing/ConfigureTracingView.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/tracing/ConfigureTracingView.kt @@ -16,6 +16,7 @@ package io.element.android.features.preferences.impl.developer.tracing +import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.WindowInsets @@ -48,6 +49,7 @@ import io.element.android.libraries.designsystem.preview.PreviewsDayNight import io.element.android.libraries.designsystem.theme.aliasScreenTitle import io.element.android.libraries.designsystem.theme.components.DropdownMenu import io.element.android.libraries.designsystem.theme.components.DropdownMenuItem +import io.element.android.libraries.designsystem.theme.components.HorizontalDivider import io.element.android.libraries.designsystem.theme.components.Icon import io.element.android.libraries.designsystem.theme.components.IconButton import io.element.android.libraries.designsystem.theme.components.ListItem @@ -124,15 +126,17 @@ fun ConfigureTracingView( .consumeWindowInsets(it) .verticalScroll(state = rememberScrollState()) ) { - CrateListContent(state) ListItem( headlineContent = { Text( - text = "Kill and restart the app for the change to take effect.", + modifier = Modifier.clickable { Runtime.getRuntime().exit(0) }, + text = "Tap here to kill the app and apply the changes. You'll have to re-open the app manually.", style = ElementTheme.typography.fontHeadingSmMedium, ) }, ) + HorizontalDivider() + CrateListContent(state) } } ) diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/tracing/TargetLogLevelMapBuilder.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/tracing/TargetLogLevelMapBuilder.kt index b851c15279..8451955c9c 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/tracing/TargetLogLevelMapBuilder.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/developer/tracing/TargetLogLevelMapBuilder.kt @@ -18,14 +18,13 @@ package io.element.android.features.preferences.impl.developer.tracing import io.element.android.libraries.matrix.api.tracing.LogLevel import io.element.android.libraries.matrix.api.tracing.Target -import io.element.android.libraries.matrix.api.tracing.TracingFilterConfigurations +import io.element.android.libraries.matrix.api.tracing.TracingFilterConfiguration import javax.inject.Inject class TargetLogLevelMapBuilder @Inject constructor( private val tracingConfigurationStore: TracingConfigurationStore, + private val defaultConfig: TracingFilterConfiguration, ) { - private val defaultConfig = TracingFilterConfigurations.debug - fun getDefaultMap(): Map { return Target.entries.associateWith { target -> defaultConfig.getLogLevel(target) diff --git a/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/developer/tracing/ConfigureTracingPresenterTest.kt b/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/developer/tracing/ConfigureTracingPresenterTest.kt index 4dd0c01e56..14123a359b 100644 --- a/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/developer/tracing/ConfigureTracingPresenterTest.kt +++ b/features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/developer/tracing/ConfigureTracingPresenterTest.kt @@ -22,6 +22,7 @@ import app.cash.turbine.test import com.google.common.truth.Truth.assertThat import io.element.android.libraries.matrix.api.tracing.LogLevel import io.element.android.libraries.matrix.api.tracing.Target +import io.element.android.libraries.matrix.api.tracing.TracingFilterConfigurations import io.element.android.tests.testutils.WarmUpRule import io.element.android.tests.testutils.waitForPredicate import kotlinx.coroutines.test.runTest @@ -37,7 +38,7 @@ class ConfigureTracingPresenterTest { val store = InMemoryTracingConfigurationStore() val presenter = ConfigureTracingPresenter( store, - TargetLogLevelMapBuilder(store), + TargetLogLevelMapBuilder(store, TracingFilterConfigurations.debug), ) moleculeFlow(RecompositionMode.Immediate) { presenter.present() @@ -54,7 +55,7 @@ class ConfigureTracingPresenterTest { store.givenLogLevel(LogLevel.ERROR) val presenter = ConfigureTracingPresenter( store, - TargetLogLevelMapBuilder(store), + TargetLogLevelMapBuilder(store, TracingFilterConfigurations.debug), ) moleculeFlow(RecompositionMode.Immediate) { presenter.present() @@ -70,7 +71,7 @@ class ConfigureTracingPresenterTest { val store = InMemoryTracingConfigurationStore() val presenter = ConfigureTracingPresenter( store, - TargetLogLevelMapBuilder(store), + TargetLogLevelMapBuilder(store, TracingFilterConfigurations.debug), ) moleculeFlow(RecompositionMode.Immediate) { presenter.present() @@ -89,7 +90,7 @@ class ConfigureTracingPresenterTest { val store = InMemoryTracingConfigurationStore() val presenter = ConfigureTracingPresenter( store, - TargetLogLevelMapBuilder(store), + TargetLogLevelMapBuilder(store, TracingFilterConfigurations.debug), ) moleculeFlow(RecompositionMode.Immediate) { presenter.present() diff --git a/features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportView.kt b/features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportView.kt index 599a48025e..f5cd06a4fb 100644 --- a/features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportView.kt +++ b/features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportView.kt @@ -21,6 +21,7 @@ import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -28,6 +29,8 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalFocusManager +import androidx.compose.ui.platform.LocalSoftwareKeyboardController import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardCapitalization @@ -51,6 +54,7 @@ import io.element.android.libraries.designsystem.preview.debugPlaceholderBackgro import io.element.android.libraries.designsystem.theme.components.Button import io.element.android.libraries.designsystem.theme.components.OutlinedTextField import io.element.android.libraries.designsystem.theme.components.Text +import io.element.android.libraries.designsystem.theme.components.onTabOrEnterKeyFocusNext import io.element.android.libraries.ui.strings.CommonStrings @Composable @@ -68,6 +72,7 @@ fun BugReportView( title = stringResource(id = CommonStrings.common_report_a_problem), onBackClick = onBackClick ) { + val keyboardController = LocalSoftwareKeyboardController.current val isFormEnabled = state.sending !is AsyncAction.Loading var descriptionFieldState by textFieldState( stateValue = state.formState.description @@ -76,7 +81,8 @@ fun BugReportView( PreferenceRow { OutlinedTextField( value = descriptionFieldState, - modifier = Modifier.fillMaxWidth(), + modifier = Modifier.fillMaxWidth() + .onTabOrEnterKeyFocusNext(LocalFocusManager.current), enabled = isFormEnabled, label = { Text(text = stringResource(id = R.string.screen_bug_report_editor_placeholder)) @@ -91,8 +97,11 @@ fun BugReportView( keyboardOptions = KeyboardOptions( capitalization = KeyboardCapitalization.Sentences, keyboardType = KeyboardType.Text, - imeAction = ImeAction.Next + imeAction = ImeAction.Next, ), + keyboardActions = KeyboardActions(onNext = { + keyboardController?.hide() + }), minLines = 3, isError = state.isDescriptionInError, ) diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/di/TracingMatrixModule.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/di/TracingMatrixModule.kt new file mode 100644 index 0000000000..9623afe470 --- /dev/null +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/di/TracingMatrixModule.kt @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.element.android.libraries.matrix.impl.di + +import com.squareup.anvil.annotations.ContributesTo +import dagger.Module +import dagger.Provides +import io.element.android.libraries.core.meta.BuildMeta +import io.element.android.libraries.core.meta.BuildType +import io.element.android.libraries.di.AppScope +import io.element.android.libraries.matrix.api.tracing.TracingFilterConfiguration +import io.element.android.libraries.matrix.api.tracing.TracingFilterConfigurations + +@Module +@ContributesTo(AppScope::class) +object TracingMatrixModule { + @Provides + fun providesTracingFilterConfiguration(buildMeta: BuildMeta): TracingFilterConfiguration { + return when (buildMeta.buildType) { + BuildType.DEBUG -> TracingFilterConfigurations.debug + BuildType.NIGHTLY -> TracingFilterConfigurations.nightly + BuildType.RELEASE -> TracingFilterConfigurations.release + } + } +} diff --git a/tests/uitests/src/test/snapshots/images/ui_S_t[f.preferences.impl.developer.tracing_ConfigureTracingView_null_ConfigureTracingView-Day-5_6_null_0,NEXUS_5,1.0,en].png b/tests/uitests/src/test/snapshots/images/ui_S_t[f.preferences.impl.developer.tracing_ConfigureTracingView_null_ConfigureTracingView-Day-5_6_null_0,NEXUS_5,1.0,en].png index 4b939a9f3d..474693b596 100644 --- a/tests/uitests/src/test/snapshots/images/ui_S_t[f.preferences.impl.developer.tracing_ConfigureTracingView_null_ConfigureTracingView-Day-5_6_null_0,NEXUS_5,1.0,en].png +++ b/tests/uitests/src/test/snapshots/images/ui_S_t[f.preferences.impl.developer.tracing_ConfigureTracingView_null_ConfigureTracingView-Day-5_6_null_0,NEXUS_5,1.0,en].png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:958e7d5c11e25cfc4936299e743c2d5a3fd3edfa79b8d89f6d426aa3978a503d -size 32802 +oid sha256:fe4b464a9962ad28f50e0f5d3de149c7d0ceedc60c01ab1ac733556d15de7079 +size 38637 diff --git a/tests/uitests/src/test/snapshots/images/ui_S_t[f.preferences.impl.developer.tracing_ConfigureTracingView_null_ConfigureTracingView-Night-5_7_null_0,NEXUS_5,1.0,en].png b/tests/uitests/src/test/snapshots/images/ui_S_t[f.preferences.impl.developer.tracing_ConfigureTracingView_null_ConfigureTracingView-Night-5_7_null_0,NEXUS_5,1.0,en].png index fd3f7f2e9c..d4e07cc52a 100644 --- a/tests/uitests/src/test/snapshots/images/ui_S_t[f.preferences.impl.developer.tracing_ConfigureTracingView_null_ConfigureTracingView-Night-5_7_null_0,NEXUS_5,1.0,en].png +++ b/tests/uitests/src/test/snapshots/images/ui_S_t[f.preferences.impl.developer.tracing_ConfigureTracingView_null_ConfigureTracingView-Night-5_7_null_0,NEXUS_5,1.0,en].png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4eaa277cbed0296a58ef6282ea9cd92739d363cd7e57fdac96f6ca1d7eaa15f4 -size 31669 +oid sha256:a7366935aa7e4b5d4da7760a2f492dffc7c8b9e6d2d574c7bbd7fe5ae830be7f +size 37200 From c9e0db26d891796d8bb8208582f2263514e9280d Mon Sep 17 00:00:00 2001 From: Jorge Martin Espinosa Date: Wed, 12 Jun 2024 15:35:51 +0200 Subject: [PATCH 8/8] Try to workaround OOM errors and the runners dying (#3013) * Try to workaround OOM errors and the runner dying * Some more tweaks: - Add `-XX:MaxMetaspaceSize` (https://github.com/gradle/gradle/issues/19750) - Remove `-PpreDexEnable` as it's deprecated and no longer used. - Remove `--max-workers` as gradle will automatically use the optimal amount. * Remove `--max-workers` in recording screenshots too --- .github/workflows/build.yml | 4 ++-- .github/workflows/maestro.yml | 4 ++-- .github/workflows/nightly.yml | 4 ++-- .github/workflows/nightlyReports.yml | 4 ++-- .github/workflows/quality.yml | 6 +++++- .github/workflows/recordScreenshots.yml | 2 +- .github/workflows/release.yml | 2 +- .../workflows/scripts/recordScreenshots.sh | 4 ++-- .github/workflows/sonar.yml | 21 +++++++++++++------ .github/workflows/tests.yml | 2 +- .../main/kotlin/extension/CommonExtension.kt | 2 +- 11 files changed, 34 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6b254c3554..59991cdcf9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,8 +9,8 @@ on: # Enrich gradle.properties for CI/CD env: - GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx7g -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.incremental=false -XX:+UseG1GC -Dkotlin.daemon.jvm.options="-Xmx3g" - CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 8 -Dsonar.gradle.skipCompile=true + GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx7g -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.incremental=false -XX:+UseG1GC + CI_GRADLE_ARG_PROPERTIES: --stacktrace -Dsonar.gradle.skipCompile=true jobs: debug: diff --git a/.github/workflows/maestro.yml b/.github/workflows/maestro.yml index 2a4515b276..eb39516e5e 100644 --- a/.github/workflows/maestro.yml +++ b/.github/workflows/maestro.yml @@ -8,8 +8,8 @@ on: # Enrich gradle.properties for CI/CD env: - GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx7g -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.incremental=false -XX:+UseG1GC -Dkotlin.daemon.jvm.options="-Xmx3g" - CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 8 --no-daemon -Dsonar.gradle.skipCompile=true + GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx7g -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.incremental=false -XX:+UseG1GC + CI_GRADLE_ARG_PROPERTIES: --stacktrace --no-daemon -Dsonar.gradle.skipCompile=true jobs: build-apk: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 6a85aa4082..294df9733f 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -7,8 +7,8 @@ on: - cron: "0 4 * * *" env: - GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx6g -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.incremental=false -XX:+UseG1GC - CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 8 --no-daemon -Dsonar.gradle.skipCompile=true + GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx6g -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.incremental=false -XX:+UseG1GC + CI_GRADLE_ARG_PROPERTIES: --stacktrace --no-daemon -Dsonar.gradle.skipCompile=true jobs: nightly: diff --git a/.github/workflows/nightlyReports.yml b/.github/workflows/nightlyReports.yml index 156055041f..94f1ab275d 100644 --- a/.github/workflows/nightlyReports.yml +++ b/.github/workflows/nightlyReports.yml @@ -8,8 +8,8 @@ on: # Enrich gradle.properties for CI/CD env: - GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx7g -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx3g" -Dkotlin.incremental=false -XX:+UseG1GC - CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 8 -Dsonar.gradle.skipCompile=true + GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx7g -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.incremental=false -XX:+UseG1GC + CI_GRADLE_ARG_PROPERTIES: --stacktrace -Dsonar.gradle.skipCompile=true jobs: nightlyReports: diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index 01261f2918..859e26defc 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -10,7 +10,7 @@ on: # Enrich gradle.properties for CI/CD env: GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx6g -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.incremental=false -XX:+UseG1GC - CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 8 --no-daemon -Dsonar.gradle.skipCompile=true + CI_GRADLE_ARG_PROPERTIES: --stacktrace --no-daemon -Dsonar.gradle.skipCompile=true jobs: checkScript: @@ -88,6 +88,10 @@ jobs: uses: gradle/actions/setup-gradle@v3 with: cache-read-only: ${{ github.ref != 'refs/heads/develop' }} + - name: Build Gplay Debug + run: ./gradlew :app:compileGplayDebugKotlin $CI_GRADLE_ARG_PROPERTIES + - name: Build Fdroid Debug + run: ./gradlew :app:compileFdroidDebugKotlin $CI_GRADLE_ARG_PROPERTIES - name: Run lint run: ./gradlew :app:lintGplayDebug :app:lintFdroidDebug $CI_GRADLE_ARG_PROPERTIES - name: Upload reports diff --git a/.github/workflows/recordScreenshots.yml b/.github/workflows/recordScreenshots.yml index d37a8febb3..44522a0084 100644 --- a/.github/workflows/recordScreenshots.yml +++ b/.github/workflows/recordScreenshots.yml @@ -7,7 +7,7 @@ on: # Enrich gradle.properties for CI/CD env: - GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx5g -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.incremental=false -XX:+UseG1GC -Dsonar.gradle.skipCompile=true + GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx5g -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.incremental=false -XX:+UseG1GC -Dsonar.gradle.skipCompile=true jobs: record: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 777381f589..f596d5e438 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,7 +8,7 @@ on: # Enrich gradle.properties for CI/CD env: GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx6g -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.incremental=false -XX:+UseG1GC - CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 8 --no-daemon -Dsonar.gradle.skipCompile=true + CI_GRADLE_ARG_PROPERTIES: --stacktrace --no-daemon -Dsonar.gradle.skipCompile=true jobs: gplay: diff --git a/.github/workflows/scripts/recordScreenshots.sh b/.github/workflows/scripts/recordScreenshots.sh index ad3e372970..5ed35160af 100755 --- a/.github/workflows/scripts/recordScreenshots.sh +++ b/.github/workflows/scripts/recordScreenshots.sh @@ -62,10 +62,10 @@ if [[ -z ${REPO} ]]; then fi echo "Deleting previous screenshots" -./gradlew removeOldSnapshots --stacktrace -PpreDexEnable=false --max-workers 4 --warn +./gradlew removeOldSnapshots --stacktrace --warn echo "Record screenshots" -./gradlew recordPaparazziDebug --stacktrace -PpreDexEnable=false --max-workers 4 --warn +./gradlew recordPaparazziDebug --stacktrace --warn echo "Committing changes" git config http.sslVerify false diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml index 3285168c09..bbab77cf65 100644 --- a/.github/workflows/sonar.yml +++ b/.github/workflows/sonar.yml @@ -9,8 +9,9 @@ on: # Enrich gradle.properties for CI/CD env: - GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx7g -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -XX:MaxMetaspaceSize=512m -Dkotlin.incremental=false -XX:+UseG1GC - CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 8 --warn -Dsonar.gradle.skipCompile=true + GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx6g -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.incremental=false -XX:+UseG1GC + CI_GRADLE_ARG_PROPERTIES: --stacktrace --warn -Dsonar.gradle.skipCompile=true + GROUP: ${{ format('sonar-{0}', github.ref) }} jobs: sonar: @@ -18,8 +19,8 @@ jobs: runs-on: ubuntu-latest # Allow all jobs on main and develop. Just one per PR. concurrency: - group: ${{ github.ref == 'refs/heads/main' && format('sonar-main-{0}', github.sha) || github.ref == 'refs/heads/develop' && format('sonar-develop-{0}', github.sha) || format('sonar-{0}', github.ref) }} - cancel-in-progress: true + group: ${{ format('sonar-{0}', github.ref) }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/develop' }} steps: - uses: actions/checkout@v4 with: @@ -35,8 +36,16 @@ jobs: uses: gradle/actions/setup-gradle@v3 with: cache-read-only: ${{ github.ref != 'refs/heads/develop' }} - - name: Build projects - run: ./gradlew assembleDebug createFullJarDebugTestFixtures :app:createFullJarGplayDebugTestFixtures $CI_GRADLE_ARG_PROPERTIES + - name: Build Gplay Debug + run: ./gradlew :app:assembleGplayDebug $CI_GRADLE_ARG_PROPERTIES + - name: Build Fdroid Debug + run: ./gradlew :app:assembleFdroidDebug $CI_GRADLE_ARG_PROPERTIES + - name: Build Sample + run: ./gradlew :samples:minimal:assembleDebug $CI_GRADLE_ARG_PROPERTIES + - name: Build library fixtures + run: ./gradlew assembleDebug createFullJarDebugTestFixtures $CI_GRADLE_ARG_PROPERTIES + - name: Build app fixtures + run: ./gradlew :app:createFullJarGplayDebugTestFixtures $CI_GRADLE_ARG_PROPERTIES - name: 🔊 Publish results to Sonar env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ee568ac76f..1d41100940 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,7 +10,7 @@ on: # Enrich gradle.properties for CI/CD env: GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx7g -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.incremental=false -XX:+UseG1GC - CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 8 --warn -Dsonar.gradle.skipCompile=true + CI_GRADLE_ARG_PROPERTIES: --stacktrace -Dsonar.gradle.skipCompile=true jobs: tests: diff --git a/plugins/src/main/kotlin/extension/CommonExtension.kt b/plugins/src/main/kotlin/extension/CommonExtension.kt index 282a569d3f..271b1565f5 100644 --- a/plugins/src/main/kotlin/extension/CommonExtension.kt +++ b/plugins/src/main/kotlin/extension/CommonExtension.kt @@ -46,7 +46,7 @@ fun CommonExtension<*, *, *, *, *, *>.androidConfig(project: Project) { lint { lintConfig = File("${project.rootDir}/tools/lint/lint.xml") - checkDependencies = true + checkDependencies = false abortOnError = true ignoreTestFixturesSources = true checkGeneratedSources = false