Skip to content
Open
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
135 changes: 127 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,31 +133,150 @@ jobs:

test-kotlin:
runs-on: ubuntu-24.04
permissions:
contents: read
packages: read
container:
image: ghcr.io/liminal-hq/threshold/ci-base:latest
options: --user root
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup Java
uses: actions/setup-java@v4
- name: Cache Gradle
uses: actions/cache@v4
with:
distribution: temurin
java-version: 17

- name: Setup Android SDK
uses: android-actions/setup-android@v3
path: |
/github/home/.gradle/caches
/github/home/.gradle/wrapper
key: ${{ runner.os }}-gradle-kotlin-${{ hashFiles('apps/threshold-wear/**/*.gradle*', 'apps/threshold-wear/**/gradle-wrapper.properties', 'apps/threshold-wear/gradle/libs.versions.toml', 'plugins/**/android/**/*.gradle*', 'plugins/**/android/**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-kotlin-

- name: Run Wear app unit tests
working-directory: apps/threshold-wear
run: ./gradlew testDebugUnitTest

- name: Run core plugin Android unit tests
run: |
TAURI_VERSION="$(awk '
BEGIN { in_tauri = 0 }
/^\[\[package\]\]$/ { in_tauri = 0; next }
/^name = "tauri"$/ { in_tauri = 1; next }
in_tauri == 1 && /^version = "/ {
match($0, /"([^"]+)"/);
print substr($0, RSTART + 1, RLENGTH - 2);
exit
}
' apps/threshold/src-tauri/Cargo.lock)"
if [ -z "${TAURI_VERSION}" ]; then
echo "Failed to determine tauri version from Cargo.lock"
exit 1
fi

mkdir -p .ci
curl -LsSf "https://crates.io/api/v1/crates/tauri/${TAURI_VERSION}/download" | tar -xz -C .ci
TAURI_ANDROID_PATH="$(pwd)/.ci/tauri-${TAURI_VERSION}/mobile/android"
if [ ! -f "${TAURI_ANDROID_PATH}/build.gradle.kts" ]; then
echo "tauri-android source not found at ${TAURI_ANDROID_PATH}"
exit 1
fi

write_kts_settings() {
local plugin_dir="$1"
cat > "${plugin_dir}/settings.gradle.kts" <<EOF
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
google()
}
resolutionStrategy {
eachPlugin {
when (requested.id.id) {
"com.android.library" -> useVersion("8.0.2")
"org.jetbrains.kotlin.android" -> useVersion("1.8.20")
}
}
}
}

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
google()
}
}

include(":tauri-android")
project(":tauri-android").projectDir = file("${TAURI_ANDROID_PATH}")
EOF
}

write_groovy_settings() {
local plugin_dir="$1"
cat > "${plugin_dir}/settings.gradle" <<EOF
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
google()
}
resolutionStrategy {
eachPlugin {
switch (requested.id.id) {
case "com.android.library":
useVersion("8.0.2")
break
case "org.jetbrains.kotlin.android":
useVersion("1.8.20")
break
}
}
}
}

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
google()
}
}

include ':tauri-android'
project(':tauri-android').projectDir = new File('${TAURI_ANDROID_PATH}')
EOF
}

write_kts_settings "plugins/alarm-manager/android"
write_kts_settings "plugins/theme-utils/android"
write_kts_settings "plugins/time-prefs/android"
write_kts_settings "plugins/wear-sync/android"
write_groovy_settings "plugins/app-management/android"
write_groovy_settings "plugins/toast/android"

./apps/threshold-wear/gradlew -p plugins/alarm-manager/android testDebugUnitTest -Pandroid.useAndroidX=true --no-daemon
./apps/threshold-wear/gradlew -p plugins/app-management/android testDebugUnitTest -Pandroid.useAndroidX=true --no-daemon
./apps/threshold-wear/gradlew -p plugins/theme-utils/android testDebugUnitTest -Pandroid.useAndroidX=true --no-daemon
./apps/threshold-wear/gradlew -p plugins/time-prefs/android testDebugUnitTest -Pandroid.useAndroidX=true --no-daemon
./apps/threshold-wear/gradlew -p plugins/wear-sync/android testDebugUnitTest -Pandroid.useAndroidX=true --no-daemon
./apps/threshold-wear/gradlew -p plugins/toast/android testDebugUnitTest -Pandroid.useAndroidX=true --no-daemon

- name: Upload Kotlin Test Results
uses: actions/upload-artifact@v4
if: always()
with:
name: kotlin-test-results
path: apps/threshold-wear/build/test-results/**/*.xml
path: |
apps/threshold-wear/build/test-results/**/*.xml
plugins/**/android/build/test-results/**/*.xml

report:
runs-on: ubuntu-24.04
Expand Down
10 changes: 10 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- [Commit Messages](#commit-messages)
- [Play Console Release Notes](#play-console-release-notes)
- [Pull Request Titles](#pull-request-titles)
- [Pull Request Labels](#pull-request-labels)
- [Application Protocol](#application-protocol)
- [Code Organization](#code-organization)
- [Best Practices](#best-practices)
Expand Down Expand Up @@ -82,6 +83,15 @@ Enter or paste your release notes for en-CA here
- Do not rename merged PRs unless explicitly requested.
- Keep linked issues and merge order aligned after any title changes in a stack.

## Pull Request Labels

**REQUIREMENT:** Add labels to every PR when it is created or updated.

- Apply labels that match scope and impact (for example: `build`, `plugin`, `android`, `release`, `bug`).
- Prefer 2-4 labels that clearly describe the PR; avoid label spam.
- Keep labels consistent across open PRs in the same stack.
- If scope changes during review, update labels so they stay accurate.

## Git Workflow

**REQUIREMENT:** Do not push changes (especially force pushes) to the repository unless explicitly requested by the user.
Expand Down
Loading