schema-version 1

// The OxygenFlow Android build image: Java, Android SDK, and Rust toolchain
// for building the JNI/uniffi core. Needs to be built and pinned in oxygenflow/images.
sandbox "android" {
    runtime "microvm"
    rootfs "cas://blob/0000000000000000000000000000000000000000000000000000000000000000" // TODO: Replace with actual Android image hash
    memory-limit "8GiB"
    cpu-limit 4
    network "isolated"
    env {
        GRADLE_USER_HOME "/src/.gradle"
        ANDROID_HOME "/opt/android-sdk"
    }
}

sandbox "android-small" {
    runtime "microvm"
    rootfs "cas://blob/0000000000000000000000000000000000000000000000000000000000000000" // TODO: Replace with actual Android image hash
    memory-limit "2GiB"
    cpu-limit 1
    network "isolated"
}

job "lint" {
    sandbox "android-small"
    exec "sh" "-c" "echo '=== 🧹 Running ktlint ===' && ./gradlew ktlintCheck"
}

job "build" {
    sandbox "android"
    depends-on "lint"
    mount {
        source "ephemeral://disk"
        target "/src/app/build"
        size "24GiB"
    }
    exec "sh" "-c" "echo '=== 🧱 Building Debug APK ===' && ./gradlew assembleDebug"
    
    output {
        artifact "app-debug" {
            path "/src/app/build/outputs/apk/debug/app-debug.apk"
        }
    }
}

job "functional-tests" {
    sandbox "android"
    depends-on "build"
    exec "sh" "-c" "echo '=== 🧪 Running Unit & UI Tests ===' && ./gradlew testDebugUnitTest"
}
