Skip to content
Closed
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
64 changes: 63 additions & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,72 @@ jobs:
cache-read-only: false

- name: Run Gradle
run: ./gradlew assemblePrereleaseDebug lint
run: ./gradlew assemblePrereleaseDebug check

- name: Upload Artifact
uses: actions/upload-artifact@v7
with:
name: pull-request-build
path: "app/build/outputs/apk/prerelease/debug/*.apk"

instrumented-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- name: Set up JDK 17
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
with:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
cache-read-only: false

- name: Get target SDK
id: sdk
run: |
TARGET_SDK=$(grep 'targetSdk' gradle/libs.versions.toml | grep -o '[0-9]\+' | head -1)
echo "version=$TARGET_SDK" >> $GITHUB_OUTPUT

- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm

- name: Run Instrumented Tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ steps.sdk.outputs.version }}
arch: x86_64
profile: Nexus 6
script: ./gradlew connectedPrereleaseDebugAndroidTest

- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v7
with:
name: instrumented-test-results
path: '**/build/reports/androidTests/'

- name: Pull debug logs
if: always()
run: |
adb pull /sdcard/Android/data/com.lagradost.cloudstream3/files/classgraph_debug.txt || true
adb pull /sdcard/Android/data/com.lagradost.cloudstream3/files/classgraph_load_failures.txt || true

- name: Upload debug logs
if: always()
uses: actions/upload-artifact@v4
with:
name: classgraph-debug
path: |
classgraph_debug.txt
classgraph_load_failures.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ class ExampleInstrumentedTest {
return APIHolder.allProviders.toTypedArray() //.filter { !it.usesWebView }
}

@Test
/* @Test
fun providersExist() {
Assert.assertTrue(getAllProviders().isNotEmpty())
println("Done providersExist")
}
} */

@Throws
private inline fun <reified T : ViewBinding> testAllLayouts(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,48 @@ class SerializationClassTester {
}

private fun findSerializableClasses(packageName: String): List<KClass<*>> {
val context = InstrumentationRegistry
.getInstrumentation()
.targetContext
val instrumentation = InstrumentationRegistry.getInstrumentation()
val classLoader = instrumentation.targetContext.classLoader

return ClassGraph()
val classpaths = listOfNotNull(
instrumentation.context.packageCodePath,
instrumentation.targetContext.packageCodePath,
).distinct()

val scanResult = ClassGraph()
.enableClassInfo()
.enableAnnotationInfo()
.overrideClassLoaders(context.classLoader)
.overrideClassLoaders(classLoader)
.acceptPackages(packageName)
.scan()

val allClasses = scanResult.allClasses.map { it.name }
val serializableClasses = scanResult.getClassesWithAnnotation(Serializable::class.java.name).map { it.name }

check(allClasses.isNotEmpty()) {
"""
ClassGraph found no classes at all!
Classpaths: $classpaths
""".trimIndent()
}

check(serializableClasses.isNotEmpty()) {
"""
ClassGraph found no @Serializable classes!
Classpaths: $classpaths
All scanned classes (${allClasses.size}): $allClasses
""".trimIndent()
}

return scanResult
.getClassesWithAnnotation(Serializable::class.java.name)
.mapNotNull { runCatching { Class.forName(it.name, false, context.classLoader).kotlin }.getOrNull() }
.mapNotNull {
runCatching {
Class.forName(it.name, true, classLoader).kotlin
}.onFailure { err ->
error("LOAD FAILED: ${it.name} -> $err")
}.getOrNull()
}
}

@OptIn(InternalSerializationApi::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import com.lagradost.cloudstream3.utils.ExtractorApi
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.M3u8Helper
import kotlin.random.Random
import kotlinx.serialization.Serializable
import kotlinx.serialization.SerialName

class Sblona : StreamSB() {
override var name = "Sblona"
Expand Down Expand Up @@ -189,9 +191,10 @@ open class StreamSB : ExtractorApi() {
}
}

@Serializable
data class Subs (
@JsonProperty("file") val file: String? = null,
@JsonProperty("label") val label: String? = null,
@SerialName("file2") val file: String? = null,
@SerialName("label") val label: String? = null,
)

data class StreamData (
Expand Down
Loading