From bd03bf45c28dde7d60fc8f723dfc7b9e8b6896ee Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Wed, 7 Feb 2024 13:19:57 +1100 Subject: [PATCH 01/23] Initial CI setup test Added code coverage report generation (for future CI stuff) Fixed a flaky unit test --- .drone.jsonnet | 70 +++++++++++++++++++ .gitignore | 5 +- app/build.gradle | 22 ++++++ .../v2/ConversationViewModelTest.kt | 5 +- scripts/drone-static-upload.sh | 70 +++++++++++++++++++ scripts/drone-upload-exists.sh | 58 +++++++++++++++ 6 files changed, 228 insertions(+), 2 deletions(-) create mode 100644 .drone.jsonnet create mode 100755 scripts/drone-static-upload.sh create mode 100755 scripts/drone-upload-exists.sh diff --git a/.drone.jsonnet b/.drone.jsonnet new file mode 100644 index 0000000000..2a6c55f8f8 --- /dev/null +++ b/.drone.jsonnet @@ -0,0 +1,70 @@ +// Intentionally doing a depth of 2 as libSession-util has it's own submodules (and libLokinet likely will as well) +local clone_submodules = { + name: 'Clone Submodules', + commands: ['git fetch --tags', 'git submodule update --init --recursive --depth=2'] +}; + +// cmake options for static deps mirror +local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https://oxen.rocks/deps ' else ''); + +[ + // Unit tests (PRs only) + { + kind: 'pipeline', + type: 'exec', + name: 'Unit Tests', + platform: { arch: 'amd64' }, + trigger: { event: { exclude: [ 'push' ] } }, + steps: [ + clone_submodules, + { + name: 'Run Unit Tests', + image: 'registry.oxen.rocks/lokinet-ci-android', + commands: [ + './gradlew testPlayDebugUnitTestCoverageReport' + ], + } + ], + }, + // Validate build artifact was created by the direct branch push (PRs only) + { + kind: 'pipeline', + type: 'exec', + name: 'Check Build Artifact Existence', + platform: { arch: 'amd64' }, + trigger: { event: { exclude: [ 'push' ] } }, + steps: [ + { + name: 'Poll for build artifact existence', + commands: [ + './Scripts/drone-upload-exists.sh' + ] + } + ] + }, + // Debug APK build (non-PRs only) + { + kind: 'pipeline', + type: 'exec', + name: 'Debug APK Build', + platform: { arch: 'amd64' }, + trigger: { event: { exclude: [ 'pull_request' ] } }, + steps: [ + clone_submodules, + { + name: 'Build', + image: 'registry.oxen.rocks/lokinet-ci-android', + commands: [ + './gradlew assemblePlayDebug' + ], + }, + { + name: 'Upload artifacts', + environment: { SSH_KEY: { from_secret: 'SSH_KEY' } }, + commands: [ + './Scripts/drone-static-upload.sh' + ] + }, + ], + } +] \ No newline at end of file diff --git a/.gitignore b/.gitignore index 023fc81010..be928b3933 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,7 @@ ffpr *.sh pkcs11.password app/play -app/huawei \ No newline at end of file +app/huawei + +!/scripts/drone-static-upload.sh +!/scripts/drone-upload-exists.sh \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 70ed8efa38..5002756607 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -124,6 +124,7 @@ android { debug { isDefault true minifyEnabled false + enableUnitTestCoverage true } } @@ -201,6 +202,27 @@ android { } } } + + task testPlayDebugUnitTestCoverageReport(type: JacocoReport, dependsOn: "testPlayDebugUnitTest") { + reports { + xml.enabled = true + } + + // Add files that should not be listed in the report (e.g. generated Files from dagger) + def fileFilter = [] + def mainSrc = "$projectDir/src/main/java" + def kotlinDebugTree = fileTree(dir: "${buildDir}/tmp/kotlin-classes/playDebug", excludes: fileFilter) + + // Compiled Kotlin class files are written into build-variant-specific subdirectories of 'build/tmp/kotlin-classes'. + classDirectories.from = files([kotlinDebugTree]) + + // To produce an accurate report, the bytecode is mapped back to the original source code. + sourceDirectories.from = files([mainSrc]) + + // Execution data generated when running the tests against classes instrumented by the JaCoCo agent. + // This is enabled with 'enableUnitTestCoverage' in the 'debug' build type. + executionData.from = "${project.buildDir}/outputs/unit_test_code_coverage/playDebugUnitTest/testPlayDebugUnitTest.exec" + } } dependencies { diff --git a/app/src/test/java/org/thoughtcrime/securesms/conversation/v2/ConversationViewModelTest.kt b/app/src/test/java/org/thoughtcrime/securesms/conversation/v2/ConversationViewModelTest.kt index aecbd7e4a8..c3a3528f14 100644 --- a/app/src/test/java/org/thoughtcrime/securesms/conversation/v2/ConversationViewModelTest.kt +++ b/app/src/test/java/org/thoughtcrime/securesms/conversation/v2/ConversationViewModelTest.kt @@ -10,12 +10,14 @@ import org.hamcrest.CoreMatchers.nullValue import org.hamcrest.MatcherAssert.assertThat import org.junit.Before import org.junit.Test +import org.mockito.Mockito import org.mockito.Mockito.anyLong import org.mockito.Mockito.anySet import org.mockito.Mockito.verify import org.mockito.kotlin.any import org.mockito.kotlin.mock import org.mockito.kotlin.whenever +import org.mockito.verification.VerificationMode import org.session.libsession.utilities.recipients.Recipient import org.thoughtcrime.securesms.BaseViewModelTest import org.thoughtcrime.securesms.database.Storage @@ -49,7 +51,8 @@ class ConversationViewModelTest: BaseViewModelTest() { viewModel.saveDraft(draft) - verify(repository).saveDraft(threadId, draft) + // The above is an async process to wait 100ms to give it a chance to complete + verify(repository, Mockito.timeout(100).times(1)).saveDraft(threadId, draft) } @Test diff --git a/scripts/drone-static-upload.sh b/scripts/drone-static-upload.sh new file mode 100755 index 0000000000..ffce9c077f --- /dev/null +++ b/scripts/drone-static-upload.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +# Script used with Drone CI to upload build artifacts (because specifying all this in +# .drone.jsonnet is too painful). + +set -o errexit + +if [ -z "$SSH_KEY" ]; then + echo -e "\n\n\n\e[31;1mUnable to upload artifact: SSH_KEY not set\e[0m" + # Just warn but don't fail, so that this doesn't trigger a build failure for untrusted builds + exit 0 +fi + +echo "$SSH_KEY" >ssh_key + +set -o xtrace # Don't start tracing until *after* we write the ssh key + +chmod 600 ssh_key + +# Define the output paths +build_dir="app/build/outputs/apk/play/debug" +target_path=$(ls ${build_dir} | grep -o 'session-[^[:space:]]*-universal.apk') + +# Validate the paths exist +if [ ! -d $build_path ]; then + echo -e "\n\n\n\e[31;1mExpected a file to upload, found none\e[0m" >&2 + exit 1 +fi + +if [ -n "$DRONE_TAG" ]; then + # For a tag build use something like `session-android-v1.2.3-universal` + base="session-android-$DRONE_TAG-universal" +else + # Otherwise build a length name from the datetime and commit hash, such as: + # session-android-20200522T212342Z-04d7dcc54-universal + base="session-android-$(date --date=@$DRONE_BUILD_CREATED +%Y%m%dT%H%M%SZ)-${DRONE_COMMIT:0:9}-universal" +fi + +# Copy over the build products +mkdir -vp "$base" +cp -av $target_path "$base" + +# tar dat shiz up yo +archive="$base.tar.xz" +tar cJvf "$archive" "$base" + +upload_to="oxen.rocks/${DRONE_REPO// /_}/${DRONE_BRANCH// /_}" + +# sftp doesn't have any equivalent to mkdir -p, so we have to split the above up into a chain of +# -mkdir a/, -mkdir a/b/, -mkdir a/b/c/, ... commands. The leading `-` allows the command to fail +# without error. +upload_dirs=(${upload_to//\// }) +put_debug= +mkdirs= +dir_tmp="" +for p in "${upload_dirs[@]}"; do + dir_tmp="$dir_tmp$p/" + mkdirs="$mkdirs +-mkdir $dir_tmp" +done + +sftp -i ssh_key -b - -o StrictHostKeyChecking=off drone@oxen.rocks < Date: Wed, 7 Feb 2024 13:37:46 +1100 Subject: [PATCH 02/23] Tweak pipeline type to docker and try add version info --- .drone.jsonnet | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 2a6c55f8f8..51e8dc9dd9 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -1,3 +1,12 @@ +// Log a bunch of version information to make it easier for debugging +local version_info = { + name: 'Version Information', + commands: [ + '/usr/lib/android-ndk --version', + '/usr/lib/android-sdk --version' + ] +}; + // Intentionally doing a depth of 2 as libSession-util has it's own submodules (and libLokinet likely will as well) local clone_submodules = { name: 'Clone Submodules', @@ -11,15 +20,17 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ // Unit tests (PRs only) { kind: 'pipeline', - type: 'exec', + type: 'docker', name: 'Unit Tests', platform: { arch: 'amd64' }, trigger: { event: { exclude: [ 'push' ] } }, steps: [ + version_info, clone_submodules, { name: 'Run Unit Tests', image: 'registry.oxen.rocks/lokinet-ci-android', + environment: { ANDROID: 'android' }, commands: [ './gradlew testPlayDebugUnitTestCoverageReport' ], @@ -29,7 +40,7 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ // Validate build artifact was created by the direct branch push (PRs only) { kind: 'pipeline', - type: 'exec', + type: 'docker', name: 'Check Build Artifact Existence', platform: { arch: 'amd64' }, trigger: { event: { exclude: [ 'push' ] } }, @@ -45,15 +56,17 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ // Debug APK build (non-PRs only) { kind: 'pipeline', - type: 'exec', + type: 'docker', name: 'Debug APK Build', platform: { arch: 'amd64' }, trigger: { event: { exclude: [ 'pull_request' ] } }, steps: [ + version_info, clone_submodules, { name: 'Build', image: 'registry.oxen.rocks/lokinet-ci-android', + environment: { ANDROID: 'android' }, commands: [ './gradlew assemblePlayDebug' ], From 5d6397764ffda2f5bf1cee52798a311f4ee72214 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Wed, 7 Feb 2024 13:51:01 +1100 Subject: [PATCH 03/23] Tweaks to docker image definition --- .drone.jsonnet | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 51e8dc9dd9..fdcbf0a7b2 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -1,3 +1,5 @@ +local docker_base = 'registry.oxen.rocks/lokinet-ci-'; + // Log a bunch of version information to make it easier for debugging local version_info = { name: 'Version Information', @@ -29,7 +31,7 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ clone_submodules, { name: 'Run Unit Tests', - image: 'registry.oxen.rocks/lokinet-ci-android', + image: docker_base + 'android', environment: { ANDROID: 'android' }, commands: [ './gradlew testPlayDebugUnitTestCoverageReport' @@ -47,6 +49,7 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ steps: [ { name: 'Poll for build artifact existence', + image: docker_base + 'android', commands: [ './Scripts/drone-upload-exists.sh' ] @@ -65,7 +68,7 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ clone_submodules, { name: 'Build', - image: 'registry.oxen.rocks/lokinet-ci-android', + image: docker_base + 'android', environment: { ANDROID: 'android' }, commands: [ './gradlew assemblePlayDebug' @@ -73,6 +76,7 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ }, { name: 'Upload artifacts', + image: docker_base + 'android', environment: { SSH_KEY: { from_secret: 'SSH_KEY' } }, commands: [ './Scripts/drone-static-upload.sh' From 038a960a2ff4c4d7a628ebfb2978ab689898dfdd Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Wed, 7 Feb 2024 14:18:19 +1100 Subject: [PATCH 04/23] Test config closer to libSession-util --- .drone.jsonnet | 71 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 60 insertions(+), 11 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index fdcbf0a7b2..714f0a8897 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -1,4 +1,5 @@ local docker_base = 'registry.oxen.rocks/lokinet-ci-'; +local default_deps = []; // Log a bunch of version information to make it easier for debugging local version_info = { @@ -12,12 +13,65 @@ local version_info = { // Intentionally doing a depth of 2 as libSession-util has it's own submodules (and libLokinet likely will as well) local clone_submodules = { name: 'Clone Submodules', - commands: ['git fetch --tags', 'git submodule update --init --recursive --depth=2'] + commands: ['git fetch --tags', 'git submodule update --init --recursive --depth=2 --jobs=4'] }; // cmake options for static deps mirror local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https://oxen.rocks/deps ' else ''); +local debian_pipeline(name, + image, + arch='amd64', + deps=default_deps, + oxen_repo=false, + kitware_repo=''/* ubuntu codename, if wanted */, + allow_fail=false, + build=['echo "Error: drone build argument not set"', 'exit 1']) + = { + kind: 'pipeline', + type: 'docker', + name: name, + platform: { arch: arch }, + steps: [ + submodules, + { + name: 'build', + image: image, + pull: 'always', + [if allow_fail then 'failure']: 'ignore', + environment: { SSH_KEY: { from_secret: 'SSH_KEY' }, WINEDEBUG: '-all' }, + commands: [] + build, + }, + ], +}; + +local debian_build(name, + image, + arch='amd64', + deps=default_deps, + build_type='Release', + lto=false, + werror=true, + cmake_extra='', + jobs=6, + tests=true, + oxen_repo=false, + kitware_repo=''/* ubuntu codename, if wanted */, + allow_fail=false) + = debian_pipeline( + name, + image, + arch=arch, + deps=deps, + oxen_repo=oxen_repo, + kitware_repo=kitware_repo, + allow_fail=allow_fail, + build=[ + './gradlew assemblePlayDebug', + ] +); + + [ // Unit tests (PRs only) { @@ -32,7 +86,6 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ { name: 'Run Unit Tests', image: docker_base + 'android', - environment: { ANDROID: 'android' }, commands: [ './gradlew testPlayDebugUnitTestCoverageReport' ], @@ -64,16 +117,12 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ platform: { arch: 'amd64' }, trigger: { event: { exclude: [ 'pull_request' ] } }, steps: [ - version_info, clone_submodules, - { - name: 'Build', - image: docker_base + 'android', - environment: { ANDROID: 'android' }, - commands: [ - './gradlew assemblePlayDebug' - ], - }, + debian_pipeline( + 'Build', + docker_base + 'android', + build=[] + ), { name: 'Upload artifacts', image: docker_base + 'android', From 64fc0a940846b681ff2b1de83103f48792cacc43 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Wed, 7 Feb 2024 14:21:35 +1100 Subject: [PATCH 05/23] Further testing --- .drone.jsonnet | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 714f0a8897..f76d09888f 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -33,14 +33,17 @@ local debian_pipeline(name, name: name, platform: { arch: arch }, steps: [ - submodules, + clone_submodules, { name: 'build', image: image, pull: 'always', [if allow_fail then 'failure']: 'ignore', - environment: { SSH_KEY: { from_secret: 'SSH_KEY' }, WINEDEBUG: '-all' }, - commands: [] + build, + environment: { SSH_KEY: { from_secret: 'SSH_KEY' } }, + commands: [ + './gradlew assemblePlayDebug', + './Scripts/drone-static-upload.sh', + ] + build, }, ], }; @@ -66,9 +69,7 @@ local debian_build(name, oxen_repo=oxen_repo, kitware_repo=kitware_repo, allow_fail=allow_fail, - build=[ - './gradlew assemblePlayDebug', - ] + build=[] ); @@ -117,7 +118,6 @@ local debian_build(name, platform: { arch: 'amd64' }, trigger: { event: { exclude: [ 'pull_request' ] } }, steps: [ - clone_submodules, debian_pipeline( 'Build', docker_base + 'android', From 25e044f13f6fddd721577f1b795f5bb6c805405a Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Wed, 7 Feb 2024 14:26:28 +1100 Subject: [PATCH 06/23] Changing back and adding the 'pull: always' setting --- .drone.jsonnet | 73 +++++++++----------------------------------------- 1 file changed, 13 insertions(+), 60 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index f76d09888f..ea887b6b3b 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -1,5 +1,4 @@ local docker_base = 'registry.oxen.rocks/lokinet-ci-'; -local default_deps = []; // Log a bunch of version information to make it easier for debugging local version_info = { @@ -19,60 +18,6 @@ local clone_submodules = { // cmake options for static deps mirror local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https://oxen.rocks/deps ' else ''); -local debian_pipeline(name, - image, - arch='amd64', - deps=default_deps, - oxen_repo=false, - kitware_repo=''/* ubuntu codename, if wanted */, - allow_fail=false, - build=['echo "Error: drone build argument not set"', 'exit 1']) - = { - kind: 'pipeline', - type: 'docker', - name: name, - platform: { arch: arch }, - steps: [ - clone_submodules, - { - name: 'build', - image: image, - pull: 'always', - [if allow_fail then 'failure']: 'ignore', - environment: { SSH_KEY: { from_secret: 'SSH_KEY' } }, - commands: [ - './gradlew assemblePlayDebug', - './Scripts/drone-static-upload.sh', - ] + build, - }, - ], -}; - -local debian_build(name, - image, - arch='amd64', - deps=default_deps, - build_type='Release', - lto=false, - werror=true, - cmake_extra='', - jobs=6, - tests=true, - oxen_repo=false, - kitware_repo=''/* ubuntu codename, if wanted */, - allow_fail=false) - = debian_pipeline( - name, - image, - arch=arch, - deps=deps, - oxen_repo=oxen_repo, - kitware_repo=kitware_repo, - allow_fail=allow_fail, - build=[] -); - - [ // Unit tests (PRs only) { @@ -86,6 +31,7 @@ local debian_build(name, clone_submodules, { name: 'Run Unit Tests', + pull: always image: docker_base + 'android', commands: [ './gradlew testPlayDebugUnitTestCoverageReport' @@ -103,6 +49,7 @@ local debian_build(name, steps: [ { name: 'Poll for build artifact existence', + pull: always image: docker_base + 'android', commands: [ './Scripts/drone-upload-exists.sh' @@ -118,13 +65,19 @@ local debian_build(name, platform: { arch: 'amd64' }, trigger: { event: { exclude: [ 'pull_request' ] } }, steps: [ - debian_pipeline( - 'Build', - docker_base + 'android', - build=[] - ), + version_info, + clone_submodules, + { + name: 'Build', + pull: always + image: docker_base + 'android', + commands: [ + './gradlew assemblePlayDebug' + ], + }, { name: 'Upload artifacts', + pull: always image: docker_base + 'android', environment: { SSH_KEY: { from_secret: 'SSH_KEY' } }, commands: [ From 309c944b6bab31412cf019fc9abe87f873898f7d Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Wed, 7 Feb 2024 14:27:08 +1100 Subject: [PATCH 07/23] Adding missing commas --- .drone.jsonnet | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index ea887b6b3b..2905c72d1a 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -31,7 +31,7 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ clone_submodules, { name: 'Run Unit Tests', - pull: always + pull: always, image: docker_base + 'android', commands: [ './gradlew testPlayDebugUnitTestCoverageReport' @@ -49,7 +49,7 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ steps: [ { name: 'Poll for build artifact existence', - pull: always + pull: always, image: docker_base + 'android', commands: [ './Scripts/drone-upload-exists.sh' @@ -69,7 +69,7 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ clone_submodules, { name: 'Build', - pull: always + pull: always, image: docker_base + 'android', commands: [ './gradlew assemblePlayDebug' @@ -77,7 +77,7 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ }, { name: 'Upload artifacts', - pull: always + pull: always, image: docker_base + 'android', environment: { SSH_KEY: { from_secret: 'SSH_KEY' } }, commands: [ From a8ffc797e28d942c6d2d36fb70d01fa2406be217 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Wed, 7 Feb 2024 14:28:03 +1100 Subject: [PATCH 08/23] Another config format fix --- .drone.jsonnet | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 2905c72d1a..c825af8074 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -31,7 +31,7 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ clone_submodules, { name: 'Run Unit Tests', - pull: always, + pull: 'always', image: docker_base + 'android', commands: [ './gradlew testPlayDebugUnitTestCoverageReport' @@ -49,7 +49,7 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ steps: [ { name: 'Poll for build artifact existence', - pull: always, + pull: 'always', image: docker_base + 'android', commands: [ './Scripts/drone-upload-exists.sh' @@ -69,7 +69,7 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ clone_submodules, { name: 'Build', - pull: always, + pull: 'always', image: docker_base + 'android', commands: [ './gradlew assemblePlayDebug' @@ -77,7 +77,7 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ }, { name: 'Upload artifacts', - pull: always, + pull: 'always', image: docker_base + 'android', environment: { SSH_KEY: { from_secret: 'SSH_KEY' } }, commands: [ From dd905a92549d3ca8a82bcb89955e8fd1d494f541 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Wed, 7 Feb 2024 14:35:36 +1100 Subject: [PATCH 09/23] Another tweak (incase the error is ambiguous) --- .drone.jsonnet | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index c825af8074..c526171cf6 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -12,6 +12,7 @@ local version_info = { // Intentionally doing a depth of 2 as libSession-util has it's own submodules (and libLokinet likely will as well) local clone_submodules = { name: 'Clone Submodules', + image: 'drone/git', commands: ['git fetch --tags', 'git submodule update --init --recursive --depth=2 --jobs=4'] }; @@ -27,7 +28,6 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ platform: { arch: 'amd64' }, trigger: { event: { exclude: [ 'push' ] } }, steps: [ - version_info, clone_submodules, { name: 'Run Unit Tests', @@ -65,7 +65,6 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ platform: { arch: 'amd64' }, trigger: { event: { exclude: [ 'pull_request' ] } }, steps: [ - version_info, clone_submodules, { name: 'Build', From 79e545b7d1099b0c8e6733dc7a9a068a1eafa02b Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Wed, 7 Feb 2024 14:43:11 +1100 Subject: [PATCH 10/23] More debugging attempts --- .drone.jsonnet | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index c526171cf6..7bbc0f8d05 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -1,14 +1,5 @@ local docker_base = 'registry.oxen.rocks/lokinet-ci-'; -// Log a bunch of version information to make it easier for debugging -local version_info = { - name: 'Version Information', - commands: [ - '/usr/lib/android-ndk --version', - '/usr/lib/android-sdk --version' - ] -}; - // Intentionally doing a depth of 2 as libSession-util has it's own submodules (and libLokinet likely will as well) local clone_submodules = { name: 'Clone Submodules', @@ -31,8 +22,8 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ clone_submodules, { name: 'Run Unit Tests', + image: 'registry.oxen.rocks/lokinet-ci-android', pull: 'always', - image: docker_base + 'android', commands: [ './gradlew testPlayDebugUnitTestCoverageReport' ], @@ -49,8 +40,8 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ steps: [ { name: 'Poll for build artifact existence', + image: 'registry.oxen.rocks/lokinet-ci-android', pull: 'always', - image: docker_base + 'android', commands: [ './Scripts/drone-upload-exists.sh' ] @@ -68,20 +59,13 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ clone_submodules, { name: 'Build', + image: 'registry.oxen.rocks/lokinet-ci-android', pull: 'always', - image: docker_base + 'android', - commands: [ - './gradlew assemblePlayDebug' - ], - }, - { - name: 'Upload artifacts', - pull: 'always', - image: docker_base + 'android', environment: { SSH_KEY: { from_secret: 'SSH_KEY' } }, commands: [ + './gradlew assemblePlayDebug', './Scripts/drone-static-upload.sh' - ] + ], }, ], } From 5f0d5b7fc7998bd62287d8d5b0c91ac42e50fd1d Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Wed, 7 Feb 2024 14:54:42 +1100 Subject: [PATCH 11/23] Trying to setup the env correctly for building --- .drone.jsonnet | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 7bbc0f8d05..01a7a53da3 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -1,5 +1,16 @@ local docker_base = 'registry.oxen.rocks/lokinet-ci-'; +// Log a bunch of version information to make it easier for debugging +local version_info = { + name: 'Version Information', + image: docker_base + 'android', + commands: [ + '/usr/lib/android-ndk --version', + '/usr/lib/android-sdk --version' + ] +}; + + // Intentionally doing a depth of 2 as libSession-util has it's own submodules (and libLokinet likely will as well) local clone_submodules = { name: 'Clone Submodules', @@ -19,11 +30,13 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ platform: { arch: 'amd64' }, trigger: { event: { exclude: [ 'push' ] } }, steps: [ + version_info, clone_submodules, { name: 'Run Unit Tests', - image: 'registry.oxen.rocks/lokinet-ci-android', + image: docker_base + 'android', pull: 'always', + environment: { ANDROID_HOME: '/usr/lib/android-sdk' }, commands: [ './gradlew testPlayDebugUnitTestCoverageReport' ], @@ -40,7 +53,7 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ steps: [ { name: 'Poll for build artifact existence', - image: 'registry.oxen.rocks/lokinet-ci-android', + image: docker_base + 'android', pull: 'always', commands: [ './Scripts/drone-upload-exists.sh' @@ -56,17 +69,26 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ platform: { arch: 'amd64' }, trigger: { event: { exclude: [ 'pull_request' ] } }, steps: [ + version_info, clone_submodules, { name: 'Build', - image: 'registry.oxen.rocks/lokinet-ci-android', + image: docker_base + 'android', pull: 'always', - environment: { SSH_KEY: { from_secret: 'SSH_KEY' } }, + environment: { ANDROID_HOME: '/usr/lib/android-sdk' }, commands: [ - './gradlew assemblePlayDebug', - './Scripts/drone-static-upload.sh' + './gradlew assemblePlayDebug' ], }, + { + name: 'Upload artifacts', + image: docker_base + 'android', + pull: 'always', + environment: { SSH_KEY: { from_secret: 'SSH_KEY' } }, + commands: [ + './Scripts/drone-static-upload.sh' + ] + }, ], } ] \ No newline at end of file From 2571716e0cf9cc163b1f4ffaca3ba86c660e6c5e Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Wed, 7 Feb 2024 14:56:19 +1100 Subject: [PATCH 12/23] Remove version logs until the build is working --- .drone.jsonnet | 2 -- 1 file changed, 2 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 01a7a53da3..fb50c31faf 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -5,8 +5,6 @@ local version_info = { name: 'Version Information', image: docker_base + 'android', commands: [ - '/usr/lib/android-ndk --version', - '/usr/lib/android-sdk --version' ] }; From 78436366a4a3c895fb6d820bc1aca58611a42162 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Wed, 7 Feb 2024 15:04:53 +1100 Subject: [PATCH 13/23] Include relevant version info --- .drone.jsonnet | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.drone.jsonnet b/.drone.jsonnet index fb50c31faf..058af85a8a 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -5,6 +5,8 @@ local version_info = { name: 'Version Information', image: docker_base + 'android', commands: [ + 'cmake --version', + '/usr/lib/android-sdk/tools/bin/sdkmanager --list | awk "/Installed/{flag=1; next} /Available/{flag=0} flag"' ] }; From 13fea6521c14abc7ae01e5c5243e9e28722e5299 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Wed, 7 Feb 2024 15:10:17 +1100 Subject: [PATCH 14/23] Update the cmake version to be a minimum value --- .drone.jsonnet | 3 ++- libsession-util/build.gradle | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 058af85a8a..5fc89893fc 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -6,7 +6,8 @@ local version_info = { image: docker_base + 'android', commands: [ 'cmake --version', - '/usr/lib/android-sdk/tools/bin/sdkmanager --list | awk "/Installed/{flag=1; next} /Available/{flag=0} flag"' + 'apt-show-versions android-sdk', + 'apt-show-versions android-ndk' ] }; diff --git a/libsession-util/build.gradle b/libsession-util/build.gradle index 935227185f..f368f15eea 100644 --- a/libsession-util/build.gradle +++ b/libsession-util/build.gradle @@ -26,7 +26,7 @@ android { externalNativeBuild { cmake { path "src/main/cpp/CMakeLists.txt" - version "3.22.1" + version "3.22.1+" } } compileOptions { From a2e7d26b793ff258c17bec30b0e7ab9efc1a9077 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Wed, 7 Feb 2024 15:13:12 +1100 Subject: [PATCH 15/23] More version check tweaks --- .drone.jsonnet | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 5fc89893fc..f3cb060671 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -6,8 +6,8 @@ local version_info = { image: docker_base + 'android', commands: [ 'cmake --version', - 'apt-show-versions android-sdk', - 'apt-show-versions android-ndk' + 'echo "Android SDK Version: $(cat /usr/lib/android-sdk/source.properties | grep Pkg.Revision)', + 'echo "Android NDK Version: $(cat /usr/lib/android-ndk/source.properties | grep Pkg.Revision)' ] }; From 88e513dbb0bca2a7070e148781f4be1457435508 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Wed, 7 Feb 2024 15:14:56 +1100 Subject: [PATCH 16/23] Trying a different approach for version info --- .drone.jsonnet | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index f3cb060671..c0ad7c5384 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -6,8 +6,7 @@ local version_info = { image: docker_base + 'android', commands: [ 'cmake --version', - 'echo "Android SDK Version: $(cat /usr/lib/android-sdk/source.properties | grep Pkg.Revision)', - 'echo "Android NDK Version: $(cat /usr/lib/android-ndk/source.properties | grep Pkg.Revision)' + 'apt --installed list' ] }; From 026fc43a875654b44ba278e8ea30007beb6279bf Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Wed, 7 Feb 2024 15:18:23 +1100 Subject: [PATCH 17/23] Installing 'ninja-build' --- .drone.jsonnet | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.drone.jsonnet b/.drone.jsonnet index c0ad7c5384..d7eb112144 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -38,6 +38,7 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ pull: 'always', environment: { ANDROID_HOME: '/usr/lib/android-sdk' }, commands: [ + 'apt-get ninja-build', './gradlew testPlayDebugUnitTestCoverageReport' ], } @@ -77,6 +78,7 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ pull: 'always', environment: { ANDROID_HOME: '/usr/lib/android-sdk' }, commands: [ + 'apt-get ninja-build', './gradlew assemblePlayDebug' ], }, From 5b2d9f703cf22469389c5dc87ee7cf856a648d22 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Wed, 7 Feb 2024 15:24:16 +1100 Subject: [PATCH 18/23] Incorrect command fix --- .drone.jsonnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index d7eb112144..7b3faf9463 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -78,7 +78,7 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ pull: 'always', environment: { ANDROID_HOME: '/usr/lib/android-sdk' }, commands: [ - 'apt-get ninja-build', + 'apt-get install -y ninja-build', './gradlew assemblePlayDebug' ], }, From 7652594eed636100424ba224aad0538fa7573b1c Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Wed, 7 Feb 2024 15:33:31 +1100 Subject: [PATCH 19/23] Fixed a path issue, moved the dependencies into it's own step --- .drone.jsonnet | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 7b3faf9463..5ba481d72e 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -18,6 +18,14 @@ local clone_submodules = { commands: ['git fetch --tags', 'git submodule update --init --recursive --depth=2 --jobs=4'] }; +// Install dependencies +local install_dependencies = { + name: 'Install Dependencies', + image: docker_base + 'android', + commands: ['apt-get install -y ninja-build'] +}; + + // cmake options for static deps mirror local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https://oxen.rocks/deps ' else ''); @@ -32,13 +40,13 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ steps: [ version_info, clone_submodules, + install_dependencies, { name: 'Run Unit Tests', image: docker_base + 'android', pull: 'always', environment: { ANDROID_HOME: '/usr/lib/android-sdk' }, commands: [ - 'apt-get ninja-build', './gradlew testPlayDebugUnitTestCoverageReport' ], } @@ -57,7 +65,7 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ image: docker_base + 'android', pull: 'always', commands: [ - './Scripts/drone-upload-exists.sh' + './scripts/drone-upload-exists.sh' ] } ] @@ -72,13 +80,13 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ steps: [ version_info, clone_submodules, + install_dependencies, { name: 'Build', image: docker_base + 'android', pull: 'always', environment: { ANDROID_HOME: '/usr/lib/android-sdk' }, commands: [ - 'apt-get install -y ninja-build', './gradlew assemblePlayDebug' ], }, @@ -88,7 +96,7 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ pull: 'always', environment: { SSH_KEY: { from_secret: 'SSH_KEY' } }, commands: [ - './Scripts/drone-static-upload.sh' + './scripts/drone-static-upload.sh' ] }, ], From 1f4dd6f3dfe2b90e3970b8ddb1225a18eea55c23 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Wed, 7 Feb 2024 16:53:40 +1100 Subject: [PATCH 20/23] Further tweaks --- .drone.jsonnet | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 5ba481d72e..dc81115ce9 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -18,14 +18,6 @@ local clone_submodules = { commands: ['git fetch --tags', 'git submodule update --init --recursive --depth=2 --jobs=4'] }; -// Install dependencies -local install_dependencies = { - name: 'Install Dependencies', - image: docker_base + 'android', - commands: ['apt-get install -y ninja-build'] -}; - - // cmake options for static deps mirror local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https://oxen.rocks/deps ' else ''); @@ -40,13 +32,13 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ steps: [ version_info, clone_submodules, - install_dependencies, { name: 'Run Unit Tests', image: docker_base + 'android', pull: 'always', environment: { ANDROID_HOME: '/usr/lib/android-sdk' }, commands: [ + 'apt-get install -y ninja-build', './gradlew testPlayDebugUnitTestCoverageReport' ], } @@ -80,25 +72,17 @@ local ci_dep_mirror(want_mirror) = (if want_mirror then ' -DLOCAL_MIRROR=https:/ steps: [ version_info, clone_submodules, - install_dependencies, { - name: 'Build', + name: 'Build and upload', image: docker_base + 'android', pull: 'always', - environment: { ANDROID_HOME: '/usr/lib/android-sdk' }, + environment: { SSH_KEY: { from_secret: 'SSH_KEY' }, ANDROID_HOME: '/usr/lib/android-sdk' }, commands: [ - './gradlew assemblePlayDebug' + 'apt-get install -y ninja-build', + './gradlew assemblePlayDebug', + './scripts/drone-static-upload.sh' ], - }, - { - name: 'Upload artifacts', - image: docker_base + 'android', - pull: 'always', - environment: { SSH_KEY: { from_secret: 'SSH_KEY' } }, - commands: [ - './scripts/drone-static-upload.sh' - ] - }, + } ], } ] \ No newline at end of file From 909e6e020701370321fa6a4c18c1715aed732693 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Wed, 7 Feb 2024 17:04:00 +1100 Subject: [PATCH 21/23] Updated the target path for build file --- scripts/drone-static-upload.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/drone-static-upload.sh b/scripts/drone-static-upload.sh index ffce9c077f..b5c9ee83f7 100755 --- a/scripts/drone-static-upload.sh +++ b/scripts/drone-static-upload.sh @@ -19,7 +19,7 @@ chmod 600 ssh_key # Define the output paths build_dir="app/build/outputs/apk/play/debug" -target_path=$(ls ${build_dir} | grep -o 'session-[^[:space:]]*-universal.apk') +target_path="${build_dir}/$(ls ${build_dir} | grep -o 'session-[^[:space:]]*-universal.apk')" # Validate the paths exist if [ ! -d $build_path ]; then From 209f058e77a61e31805e63f39c79dcdbc112c0ef Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Wed, 7 Feb 2024 17:14:06 +1100 Subject: [PATCH 22/23] Updated the 'upload exists' script with the latest fixes --- scripts/drone-upload-exists.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/scripts/drone-upload-exists.sh b/scripts/drone-upload-exists.sh index 1e2db10e1b..bc9b112c26 100755 --- a/scripts/drone-upload-exists.sh +++ b/scripts/drone-upload-exists.sh @@ -21,7 +21,7 @@ fork_repo=$(echo "$head_info" | grep -o '"full_name":"[^"]*' | sed 's/"full_name fork_branch=$(echo "$head_info" | grep -o '"ref":"[^"]*' | sed 's/"ref":"//') upload_dir="https://oxen.rocks/${fork_repo}/${fork_branch}" -echo "Starting to poll ${upload_dir} every 10s to check for a build matching '${prefix}.*${suffix}'" +echo "Starting to poll ${upload_dir}/ every 10s to check for a build matching '${prefix}.*${suffix}'" # Loop indefinitely the CI can timeout the script if it takes too long total_poll_duration=0 @@ -32,14 +32,12 @@ while true; do build_artifacts_html=$(curl -s "${upload_dir}/") if [ $? != 0 ]; then - echo "Failed to retrieve build artifact list" + echo -e "\n\n\n\n\e[31;1mFailed to retrieve build artifact list\e[0m\n\n\n" exit 1 fi - # Extract 'session-ios...' titles using grep and awk - current_build_artifacts=$(echo "$build_artifacts_html" | grep -o 'href="${prefix}[^"]*' | sed 's/href="//') - - # Use grep to check for the combination + # Extract 'session-ios...' titles using grep and awk then look for the target file + current_build_artifacts=$(echo "$build_artifacts_html" | grep -o "href=\"${prefix}[^\"]*" | sed 's/href="//') target_file=$(echo "$current_build_artifacts" | grep -o "${prefix}.*${suffix}" | tail -n 1) if [ -n "$target_file" ]; then From 7e32f3725846994136a2c3502745831868adc257 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Thu, 8 Feb 2024 15:27:40 +1100 Subject: [PATCH 23/23] Removed an unneeded import --- .../securesms/conversation/v2/ConversationViewModelTest.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/test/java/org/thoughtcrime/securesms/conversation/v2/ConversationViewModelTest.kt b/app/src/test/java/org/thoughtcrime/securesms/conversation/v2/ConversationViewModelTest.kt index c3a3528f14..b89c62b6d5 100644 --- a/app/src/test/java/org/thoughtcrime/securesms/conversation/v2/ConversationViewModelTest.kt +++ b/app/src/test/java/org/thoughtcrime/securesms/conversation/v2/ConversationViewModelTest.kt @@ -17,7 +17,6 @@ import org.mockito.Mockito.verify import org.mockito.kotlin.any import org.mockito.kotlin.mock import org.mockito.kotlin.whenever -import org.mockito.verification.VerificationMode import org.session.libsession.utilities.recipients.Recipient import org.thoughtcrime.securesms.BaseViewModelTest import org.thoughtcrime.securesms.database.Storage