Skip to content

Commit

Permalink
Merge pull request #178 from Tribler/CS4160/class-of-2024
Browse files Browse the repository at this point in the history
Fix Linux build
  • Loading branch information
InvictusRMC authored Feb 20, 2024
2 parents fae3f1f + a842f0f commit d9afda2
Show file tree
Hide file tree
Showing 22 changed files with 114 additions and 111 deletions.
38 changes: 0 additions & 38 deletions .github/workflows/build.yml

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Execute checks

on:
pull_request:
push:
branches: master

jobs:
test:
name: Run Checks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- uses: ./.github/actions/checkout_submodules

- name: Setup Java
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '17'

# TODO: Without this step, the Gradle check task fails with the following error:
# Execution failed for task ':common:verifyDebugDatabaseMigration'.
# > A failure occurred while executing app.cash.sqldelight.gradle.VerifyMigrationTask$VerifyMigrationAction
# > No suitable driver found for jdbc:sqlite:
- name: Run verifyDebugDatabase
run: bash ./gradlew verifyDebugDatabaseMigration

- name: Run check
run: bash ./gradlew check

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
110 changes: 59 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,65 @@

This repository contains a collection of Android apps built on top of [IPv8](https://github.com/MattSkala/kotlin-ipv8) (our P2P networking stack) and [TrustChain](https://github.com/Tribler/kotlin-ipv8/blob/master/doc/TrustChainCommunity.md) (a scalable, distributed, pair-wise ledger). All applications are built into a single APK, following the concept of [super apps](https://home.kpmg/xx/en/home/insights/2019/06/super-app-or-super-disruption.html) – an emerging trend that allows to provide an ecosystem for multiple services within a single all-in-one app experience.

## Build Instructions

If you want to build an APK, run the following command:

```
./gradlew :app:buildDebug
```

The resulting APK will be stored in `app/build/outputs/apk/debug/app-debug.apk`.

### Install

You can also build and automatically install the app on all connected Android devices with a single command:

```
./gradlew :app:installDebug
```

*Note: It is required to have an Android device connected with USB debugging enabled before running this command.*

### Check
Run the Gradle check task to verify that the project is correctly set up and that tests pass:

```
./gradlew check
```

*Note: this task is also run on the CI, so ensure that it passes before making a PR.*

### Tests

Run unit tests:
```
./gradlew test
```

Run instrumented tests:
```
./gradlew connectedAndroidTest
```

### Code style

[Ktlint](https://ktlint.github.io/) is used to enforce a consistent code style across the whole project. It is recommended to install the [ktlint plugin](https://plugins.jetbrains.com/plugin/15057-ktlint) for your IDE to get real-time feedback.


Check code style:
```
./gradlew ktlintCheck
```

Run code formatter:
```
./gradlew ktlintFormat
```

## Adding Your Own App
If you want to add your own app to the TrustChain Super App, you can follow the tutorial in the [AppTutorial.md](doc/AppTutorial.md) document.

## Apps

### On-Chain Democracy
Expand Down Expand Up @@ -104,54 +163,3 @@ A user can publish a Release (which is an album/EP/single/...), after which the
Video 1: <a href="doc/musicdao/thesis2.mp4">Load example.</a> This uses a default magnet link for an album that has a decent amount of peers. The user submits the metadata and the block gets proposed and signed. Then playback.

Video 2: <a href="doc/musicdao/thesis3.mp4">Share track.</a> Note: as a fresh magnet link is generated in this video, there is only 1 peer. For this reason it will be difficult to obtain the metadata of the magnet link (cold start issue, write about this in thesis) so the video stops there.

### Do you want to add your own app?

- [Adding your own app to the TrustChain Super App](doc/AppTutorial.md)

## Build

If you want to build an APK, run the following command:

```
./gradlew :app:buildDebug
```

The resulting APK will be stored in `app/build/outputs/apk/debug/app-debug.apk`.

## Install

You can also build and automatically install the app on all connected Android devices with a single command:

```
./gradlew :app:installDebug
```

*Note: It is required to have an Android device connected with USB debugging enabled before running this command.*

## Tests

Run unit tests:
```
./gradlew test
```
*Note: Currently tests fail on Linux, but pass on Windows and Mac. This is due to the tests relying on a native jlibtorrent binary, of which the linux version cannot be bundled with android builds. We are working on a solution to this problem.*

Run instrumented tests:
```
./gradlew connectedAndroidTest
```

## Code style

[Ktlint](https://ktlint.github.io/) is used to enforce a consistent code style across the whole project. It is recommended to install the [ktlint plugin](https://plugins.jetbrains.com/plugin/15057-ktlint) for your IDE to get real-time feedback.

Check code style:
```
./gradlew ktlintCheck
```

Run code formatter:
```
./gradlew ktlintFormat
```
4 changes: 1 addition & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ android {

sourceSets {
main {
// TODO: Find a way to exclude linux .so
// TODO: Reintroduce the jlibtorrent library for linux.
jniLibs.srcDirs = ['../common/libs']
}
}
Expand Down Expand Up @@ -164,7 +162,7 @@ dependencies {

// Logging
implementation 'io.github.microutils:kotlin-logging:1.7.7'
implementation('net.java.dev.jna:jna:5.8.0@aar')
implementation('net.java.dev.jna:jna:5.12.1@aar')
implementation('com.github.tony19:logback-android:2.0.0')

implementation 'com.github.MattSkala:recyclerview-itemadapter:0.4'
Expand Down
6 changes: 1 addition & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

buildscript {
ext.kotlin_version = '1.9.22'
ext.coroutines_version = '1.6.4'
ext.coroutines_version = '1.8.0'
ext.ktlint_version = '1.1.1'
ext.ktlint_gradle_version = '12.1.0'
ext.sqldelight_version = '2.0.1'
Expand All @@ -29,10 +29,6 @@ buildscript {
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
classpath 'com.google.gms:google-services:4.3.14'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
}
}
Expand Down
10 changes: 5 additions & 5 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ dependencies {
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation 'androidx.databinding:viewbinding:8.2.2'

// QR
implementation 'com.journeyapps:zxing-android-embedded:4.3.0'
Expand All @@ -107,8 +108,8 @@ dependencies {

// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"

// Logging
Expand All @@ -126,13 +127,12 @@ dependencies {
implementation files('libs/jlibtorrent-android-arm-' + jlibtorrent_version + '.jar')
implementation files('libs/jlibtorrent-android-x86-' + jlibtorrent_version + '.jar')
implementation files('libs/jlibtorrent-android-x86_64-' + jlibtorrent_version + '.jar')
implementation 'androidx.databinding:viewbinding:8.2.2'

// Testing
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.3'
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version"
testImplementation "io.mockk:mockk:$mockk_version"
testImplementation 'org.json:json:20190722'
testImplementation "app.cash.sqldelight:sqlite-driver:$sqldelight_version"
Expand All @@ -143,6 +143,6 @@ dependencies {

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions.freeCompilerArgs += [
"-opt-in=kotlin.RequiresOptIn"
"-opt-in=kotlin.RequiresOptIn"
]
}
Binary file removed common/libs/jlibtorrent-linux-1.2.17.0.jar
Binary file not shown.
File renamed without changes.
Binary file added common/native_libs/libjlibtorrent-1.2.17.0.so
Binary file not shown.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,11 @@ class TransactionRepository(
return initialBalance
}
Log.d("getMyBalance", "latest block found")
val myBalance = getBalanceForBlock(latestBlock, trustChainCommunity.database)!!
val myBalance = getBalanceForBlock(latestBlock, trustChainCommunity.database)
if (myBalance == null) {
Log.d("getMyBalance", "no balance found, defaulting to initial balance")
return initialBalance
}
Log.d("getMyBalance", "balance = $myBalance")
return myBalance
}
Expand Down
4 changes: 2 additions & 2 deletions currencyii/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ dependencies {

// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation 'androidx.preference:preference:1.1.1'

Expand Down
4 changes: 1 addition & 3 deletions eurotoken/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,10 @@ dependencies {
// Logging
implementation 'io.github.microutils:kotlin-logging:1.7.7'

// Testing
testImplementation 'junit:junit:4.12'

androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

annotationProcessor "androidx.room:room-compiler:$room_version"


}
6 changes: 3 additions & 3 deletions freedomOfComputing/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ dependencies {

// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
}

Expand All @@ -84,5 +84,5 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
}

tasks.withType(Test) {
systemProperty "java.library.path", "../common/libs"
systemProperty "java.library.path", "../common/native_libs"
}
Empty file added peerai/consumer-rules.pro
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit d9afda2

Please sign in to comment.