Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 51 additions & 73 deletions .github/workflows/android-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,19 @@ name: Android Tests
on:
push:
branches: ["main"]
paths:
- "android/**"
- "core"
- "core/**"
- ".gitmodules"
- ".github/workflows/android-ci.yml"
pull_request:
branches: ["main"]
paths:
- "android/**"
- "core"
- "core/**"
- ".gitmodules"
- ".github/workflows/android-ci.yml"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
UNIT_TESTS: "true"
ANDROID_COMPILE_SDK: "36"
ANDROID_API: "35"
ANDROID_AVD_NAME: "ci-emulator"
ANDROID_EMULATOR_DEVICE: "pixel_6"

jobs:
unit_test:
Expand All @@ -32,79 +24,65 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
submodules: recursive

# Re-enable these setup steps if the self-hosted runner stops providing
# Java, Android SDK/NDK, and `just` out of the box.
# - name: Set up JDK 17
# uses: actions/setup-java@v3
# with:
# java-version: "17"
# distribution: "temurin"
#
# - name: Setup Android SDK
# uses: android-actions/setup-android@v3
#
# - name: Install just
# uses: extractions/setup-just@v2
#
# - name: Cache NDK
# uses: actions/cache@v4
# with:
# path: ${{ env.ANDROID_HOME }}/ndk/28.1.13356709
# key: ndk-28.1.13356709-${{ runner.os }}
#
# - name: Setup NDK
# working-directory: android
# run: just install-ndk

# Re-enable this on ephemeral GitHub-hosted runners where ~/.android/avd
# does not persist between jobs and emulator provisioning cost matters.
# - name: Cache AVD
# uses: actions/cache@v4
# id: avd-cache
# with:
# path: |
# ~/.android/avd/*
# ~/.android/adb*
# key: avd-35-google-apis-arm64-v8a-${{ runner.os }}-${{ runner.arch }}

# Re-enable Gradle cache if CI time becomes an issue and the self-hosted
# runner is no longer reusing local Gradle state effectively.
# - name: Gradle cache
# uses: gradle/actions/setup-gradle@v3
# with:
# cache-read-only: ${{ github.ref != 'refs/heads/main' }}

- name: Build tests
- name: Resolve Runner Toolchain
run: |
JAVA_HOME="$(/usr/libexec/java_home -v 17)"
ANDROID_HOME="/opt/homebrew/share/android-commandlinetools"

[ -x "${JAVA_HOME}/bin/java" ] || { echo "JAVA_HOME is invalid: ${JAVA_HOME}"; exit 1; }
[ -x "${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager" ] || { echo "sdkmanager is missing under ${ANDROID_HOME}"; exit 1; }

{
echo "JAVA_HOME=${JAVA_HOME}"
echo "ANDROID_HOME=${ANDROID_HOME}"
echo "ANDROID_SDK_ROOT=${ANDROID_HOME}"
} >> "${GITHUB_ENV}"

- name: Bootstrap
working-directory: android
run: just bootstrap

- name: Provision Android SDK
working-directory: android
run: just provision-emulator

- name: Build
working-directory: android
run: just build
env:
GPR_USERNAME: ${{ github.actor }}
GPR_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run unit tests
working-directory: android
run: just unit-test
env:
GPR_USERNAME: ${{ github.actor }}
GPR_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Start emulator
working-directory: android
run: just start-emulator

- name: Build instrumented tests
working-directory: android
run: just build-test
env:
GPR_USERNAME: ${{ github.actor }}
GPR_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run tests
- name: Run instrumented tests
working-directory: android
run: just test
env:
GPR_USERNAME: ${{ github.actor }}
GPR_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Re-enable this on GitHub-hosted runners, or when the self-hosted runner
# does not keep a booted emulator/device available for connected tests.
# - name: Run tests
# uses: reactivecircus/android-emulator-runner@v2
# with:
# api-level: 35
# target: google_apis
# arch: arm64-v8a
# force-avd-creation: false
# disk-size: 2048M
# emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
# disable-animations: true
# script: cd android && just test
# env:
# GPR_USERNAME: ${{ github.actor }}
# GPR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Stop emulator
if: always()
working-directory: android
run: just stop-emulator
2 changes: 1 addition & 1 deletion .github/workflows/android-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
submodules: recursive

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/android-publish-base-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Read base image tag
id: base_tag
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/android-verify-apk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
VERIFY_REPO_URL: https://github.com/${{ github.repository }}.git
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
submodules: recursive

Expand Down
14 changes: 1 addition & 13 deletions .github/workflows/ios-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,8 @@ name: iOS Unit Tests
on:
push:
branches: ["main"]
paths:
- "ios/**"
- "core"
- "core/**"
- ".gitmodules"
- ".github/workflows/ios-ci.yml"
pull_request:
branches: ["main"]
paths:
- "ios/**"
- "core"
- "core/**"
- ".gitmodules"
- ".github/workflows/ios-ci.yml"

jobs:
unit_test:
Expand All @@ -25,7 +13,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
submodules: recursive

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ios-ui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV

- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
submodules: recursive

Expand Down
5 changes: 1 addition & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,4 @@ This repository is a monorepo:

* iOS application code lives under `ios/`
* Android application code lives under `android/`
* Shared Rust core is the `core/` submodule

### Commit Convention
We use [Conventional Commits](https://www.conventionalcommits.org/) for commit messages. Please read the guide through if you aren't familiar with it already.
* Shared Rust core is the `core/` submodule
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ fun GemPerpetualData.toDTO(): PerpetualData? {
volume24h = perpetual.volume24h,
funding = perpetual.funding,
maxLeverage = perpetual.maxLeverage,
isIsolatedOnly = perpetual.isIsolatedOnly,
),
asset = asset.toDTO(),
metadata = PerpetualMetadata(
Expand Down Expand Up @@ -145,4 +146,4 @@ fun GemChartCandleStick.toDTO(): ChartCandleStick {

fun uniffi.gemstone.PerpetualProvider.toDTO(): PerpetualProvider = when (this) {
uniffi.gemstone.PerpetualProvider.HYPERCORE -> PerpetualProvider.Hypercore
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class GetPerpetualImpl @Inject constructor(
}

class PerpetualDetailsDataAggregateImpl(
val data: PerpetualData
private val data: PerpetualData
) : PerpetualDetailsDataAggregate {
override val id: String = data.perpetual.id

Expand All @@ -45,4 +45,6 @@ class PerpetualDetailsDataAggregateImpl(
override val price: Double = data.perpetual.price

override val identifier: String = data.perpetual.identifier
}

override val isIsolatedOnly: Boolean = data.perpetual.isIsolatedOnly
}
Original file line number Diff line number Diff line change
Expand Up @@ -242,35 +242,32 @@ class AssetsRepository @Inject constructor(
searchTokensCase.search(widgetAssetIds, currency)
}

val prices = widgetAssetIds.map { assetId ->
val marketsByAssetId = widgetAssetIds.map { assetId ->
async {
try {
gemApi.getAsset(assetId.toIdentifier())
val market = try {
gemApi.getMarket(assetId.toIdentifier(), currency.string)
} catch (_: Throwable) {
null
}
assetId to market
}
}
.awaitAll()
.filterNotNull()
.toMap()
(getTokensInfo(widgetAssetIds.map { it.toIdentifier() }).firstOrNull() ?: emptyList())
.map { assetInfo ->
val price = prices.firstOrNull { it.asset.id == assetInfo.asset.id }
if (price == null) {
assetInfo
} else {
assetInfo.copy(
price = AssetPriceInfo(
currency = currency,
price = AssetPrice(
assetId = assetInfo.asset.id,
price = price.price.price,
priceChangePercentage24h = price.price.priceChangePercentage24h,
updatedAt = System.currentTimeMillis()
)
val marketPrice = marketsByAssetId[assetInfo.asset.id]?.price ?: return@map assetInfo
assetInfo.copy(
price = AssetPriceInfo(
currency = currency,
price = AssetPrice(
assetId = assetInfo.asset.id,
price = marketPrice.price,
priceChangePercentage24h = marketPrice.priceChangePercentage24h,
updatedAt = System.currentTimeMillis()
)
)
}
)
}
}

Expand Down Expand Up @@ -525,4 +522,4 @@ class AssetsRepository @Inject constructor(
): Flow<List<AssetInfo>> {
return assetsDao.getRecentByType(type).toAssetInfoModel()
}
}
}
Loading