mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 10:46:53 -04:00
Switch to using test gateway
This commit is contained in:
parent
acf0f7f8fb
commit
bd5c665320
@ -1,3 +1,11 @@
|
||||
import com.testdroid.api.APIClient
|
||||
import com.testdroid.api.APIException
|
||||
import com.testdroid.api.APIKeyClient
|
||||
import com.testdroid.api.model.APIProject
|
||||
import com.testdroid.api.model.APIUser
|
||||
import com.android.builder.testing.api.TestServer;
|
||||
import com.android.annotations.NonNull;
|
||||
|
||||
import groovy.json.JsonSlurper
|
||||
|
||||
buildscript {
|
||||
@ -9,14 +17,13 @@ buildscript {
|
||||
|
||||
dependencies {
|
||||
classpath "com.android.tools.build:gradle:$androidGradlePluginVersion"
|
||||
classpath "com.testdroid:gradle:$testdroidGradlePluginVersion"
|
||||
classpath 'org.apache.httpcomponents:httpclient-android:4.3.3'
|
||||
classpath "com.testdroid:testdroid-api:2.71"
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'checkstyle'
|
||||
apply plugin: 'testdroid'
|
||||
|
||||
repositories {
|
||||
google()
|
||||
@ -30,7 +37,6 @@ repositories {
|
||||
String[] archs = ['arm64-v8a', 'armeabi', 'mips', 'mips64', 'x86', 'x86_64']
|
||||
|
||||
dependencies {
|
||||
|
||||
// Get kiwixlib online if it is not populated locally
|
||||
if (file("../kiwixlib/src/main").list().length == 1) {
|
||||
implementation 'org.kiwix.kiwixlib:kiwixlib:1.0.11'
|
||||
@ -161,6 +167,7 @@ if (custom.listFiles()) {
|
||||
|
||||
android {
|
||||
compileSdkVersion 28
|
||||
testServer new TestDroidUpload();
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
@ -367,21 +374,42 @@ android {
|
||||
*/
|
||||
}
|
||||
|
||||
// Testdroid deployment configuration
|
||||
def buildNumber = System.getenv('TRAVIS_BUILD_NUMBER')
|
||||
|
||||
def findJar(prefix) {
|
||||
configurations.runtime.filter { it.name.startsWith(prefix) }
|
||||
}
|
||||
public class TestDroidUpload extends TestServer{
|
||||
def buildNumber = System.getenv('TRAVIS_BUILD_NUMBER')
|
||||
def API_KEY = System.getenv('PUBLIC_TESTDROID_API_KEY')
|
||||
def TESTDROID_SERVER = "https://cloud.testdroid.com";
|
||||
def RUNNER_GATEWAY = System.getenv('TESTDROID_RUNNER_GATEWAY')
|
||||
def accessGroup = System.getenv('ACCESS_GROUP_ID')
|
||||
|
||||
testdroid {
|
||||
authorization "APIKEY"
|
||||
apiKey System.getenv('BITBAR_API_KEY')
|
||||
deviceGroup 'Kiwix'
|
||||
projectName "Kiwix"
|
||||
testRunName "Auto Test " + buildNumber
|
||||
@Override
|
||||
String getName() {
|
||||
return "kiwixtest";
|
||||
}
|
||||
|
||||
fullRunConfig {
|
||||
instrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
@Override
|
||||
void uploadApks(@NonNull String variantName, @NonNull File testApk, @Nullable File testedApk) {
|
||||
APIUser.metaClass.shareFile { id, accessGroup ->
|
||||
System.out.println(id)
|
||||
try {
|
||||
delegate.postResource(createUri(selfURI, "/files/" + id + "/share"), [accessGroupId: accessGroup], APIProject.class)
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getLocalizedMessage())
|
||||
}
|
||||
}
|
||||
|
||||
APIClient client = new APIKeyClient(TESTDROID_SERVER, API_KEY);
|
||||
APIUser user = client.me();
|
||||
String testId = user.uploadFile(testApk).getId()
|
||||
user.shareFile(testId, accessGroup);
|
||||
String testedId = user.uploadFile(testedApk).getId()
|
||||
user.shareFile(testedId, accessGroup);
|
||||
|
||||
new URL(RUNNER_GATEWAY + "?apk=" + testedId + "&test=" + testId + "&buildno=" + buildNumber).getText()
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isConfigured() {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user