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
87 changes: 74 additions & 13 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
#!groovy

class DockerParameters {

// 'docker build' would normally copy the whole build-dir to the container, changing the
// docker build directory avoids that overhead
def dir = 'docker'
def args = '--device /dev/kvm:/dev/kvm -v /var/local/container_shared/gradle_cache/$EXECUTOR_NUMBER:/home/user/.gradle -m=6.5G'
def label = 'LimitedEmulator'
def image = 'floriankanduth/paintroid_java17:latest'

}

def dockerParameters = new DockerParameters()

def startEmulator(String android_version, String stageName) {
sh 'adb start-server'
// creates a new avd, and if it already exists it does nothing.
sh "echo no | avdmanager create avd --force --name android${android_version}" + " --package 'system-images;android-${android_version};default;x86_64'"
sh "/home/user/android/sdk/emulator/emulator -no-window -no-boot-anim -noaudio -avd android${android_version} > ${stageName}_emulator.log 2>&1 &"
}

def waitForEmulatorAndPressWakeUpKey() {
sh 'adb devices'
sh 'timeout 5m adb wait-for-device'
sh '''#!/bin/bash
adb devices
timeout 5m adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1;
done'
echo "Emulator started"
'''
sh '''
adb shell settings put global window_animation_scale 0 &
adb shell settings put global transition_animation_scale 0 &
adb shell settings put global animator_duration_scale 0 &
'''


// In case the device went to sleep
sh 'adb shell input keyevent KEYCODE_WAKEUP'
}

def reports = 'Paintroid/build/reports'

// place the cobertura xml relative to the source, so that the source can be found
Expand All @@ -22,18 +62,32 @@ def useDebugLabelParameter(defaultLabel) {
return env.DEBUG_LABEL?.trim() ? env.DEBUG_LABEL : defaultLabel
}

def checkAnimationScale(scaleName) {
def output = sh(script: "adb shell settings get global ${scaleName}", returnStdout: true).trim()
if (output != "0" && output != "0.0") {
error("Animation scale '${scaleName}' is NOT disabled. Current value: ${output}")
} else {
echo("Animation scale '${scaleName}' is disabled (Value: ${output})")
}
}

pipeline {
environment {
ANDROID_VERSION = 33
ADB_INSTALL_TIMEOUT = 60
}

parameters {
string name: 'DEBUG_LABEL', defaultValue: '', description: 'For debugging when entered will be used as label to decide on which slaves the jobs will run.'
booleanParam name: 'BUILD_WITH_CATROID', defaultValue: false, description: 'When checked then the current Paintroid build will be built with the current develop branch of Catroid'
string name: 'CATROID_BRANCH', defaultValue: 'develop', description: 'The branch which to build catroid with, when BUILD_WITH_CATROID is checked.'
}

agent {
docker {
image 'catrobat/catrobat-paintroid:stable'
args '--device /dev/kvm:/dev/kvm -v /var/local/container_shared/gradle_cache/$EXECUTOR_NUMBER:/home/user/.gradle -m=6.5G'
label 'LimitedEmulator'
docker {
image dockerParameters.image
args dockerParameters.args
label dockerParameters.label
alwaysPull true
}
}
Expand Down Expand Up @@ -70,14 +124,14 @@ pipeline {
sh 'rm -rf Catroid; mkdir Catroid'
dir('Catroid') {
git branch: params.CATROID_BRANCH, url: 'https://github.com/Catrobat/Catroid.git'
sh "rm -f catroid/src/main/libs/*.aar"
sh "mv -f ../colorpicker/build/outputs/aar/colorpicker-debug.aar catroid/src/main/libs/colorpicker-LOCAL.aar"
sh "mv -f ../Paintroid/build/outputs/aar/Paintroid-debug.aar catroid/src/main/libs/Paintroid-LOCAL.aar"
sh 'rm -f catroid/src/main/libs/*.aar'
sh 'mv -f ../colorpicker/build/outputs/aar/colorpicker-debug.aar catroid/src/main/libs/colorpicker-LOCAL.aar'
sh 'mv -f ../Paintroid/build/outputs/aar/Paintroid-debug.aar catroid/src/main/libs/Paintroid-LOCAL.aar'
}
renameApks("${env.BRANCH_NAME}-${env.BUILD_NUMBER}")
dir('Catroid') {
archiveArtifacts "catroid/src/main/libs/*.aar"
sh "./gradlew assembleCatroidDebug"
archiveArtifacts 'catroid/src/main/libs/*.aar'
sh './gradlew assembleCatroidDebug'
archiveArtifacts 'catroid/build/outputs/apk/catroid/debug/catroid-catroid-debug.apk'
}
}
Expand Down Expand Up @@ -114,9 +168,16 @@ pipeline {

stage('Device Tests') {
steps {
sh "echo no | avdmanager create avd --force --name android28 --package 'system-images;android-28;default;x86_64'"
sh "/home/user/android/sdk/emulator/emulator -no-window -no-boot-anim -noaudio -avd android28 > /dev/null 2>&1 &"
sh './gradlew -PenableCoverage -Pjenkins -Pemulator=android28 -Pci createDebugCoverageReport -i'
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
startEmulator(ANDROID_VERSION, 'device_tests')
waitForEmulatorAndPressWakeUpKey()
script {
checkAnimationScale("window_animation_scale")
checkAnimationScale("transition_animation_scale")
checkAnimationScale("animator_duration_scale")
}
sh "./gradlew disableAnimations -PenableCoverage -Pjenkins -Pemulator=android${android_version} -Pci createDebugCoverageReport -i"
}
}
post {
always {
Expand Down Expand Up @@ -145,4 +206,4 @@ pipeline {
notifyChat()
}
}
}
}
177 changes: 84 additions & 93 deletions Paintroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,33 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

apply plugin: 'com.android.library'
apply plugin: 'com.hiya.jacoco-android'
apply plugin: 'com.getkeepsafe.dexcount'
apply plugin: 'kotlin-android'
apply plugin: 'org.catrobat.gradle.androidemulators'
apply plugin: 'maven-publish'
plugins {
id "com.android.library"
id "jacoco"
id "com.getkeepsafe.dexcount"
id "org.jetbrains.kotlin.android"
id "org.catrobat.gradle.androidemulators"
id "maven-publish"
}

apply from: 'gradle/adb_tasks.gradle'
apply from: 'gradle/code_quality_tasks.gradle'
apply from: "gradle/adb_tasks.gradle"
apply from: "gradle/code_quality_tasks.gradle"

emulators {
install project.hasProperty('installSdk')

dependencies {
sdk()
}
install project.hasProperty("installSdk")
dependencies { sdk() }

emulator 'android28', {
emulator "android28", {
avd {
systemImage = 'system-images;android-28;default;x86_64'
systemImage = "system-images;android-28;default;x86_64"
sdcardSizeMb = 1024
hardwareProperties += ['hw.ramSize': 4096, 'vm.heapSize': 1024]
screenDensity = 'xhdpi'
hardwareProperties += ["hw.ramSize": 4096, "vm.heapSize": 1024]
screenDensity = "xhdpi"
}

parameters {
resolution = '768x1280'
language = 'en'
country = 'US'
resolution = "768x1280"
language = "en"
country = "US"
}
}
}
Expand All @@ -54,54 +52,50 @@ jacoco {
toolVersion = "0.8.7"
}

jacocoAndroidUnitTestReport {
csv.enabled false
html.enabled true
xml.enabled true
destination project.getBuildDir().getPath() + "/reports/jacoco/jacocoTestDebugUnitTestReport"
}

android {
compileSdkVersion rootProject.ext.androidCompileSdkVersion
namespace "org.catrobat.paintroid"

// New AGP DSL
compileSdk = rootProject.ext.androidCompileSdkVersion

defaultConfig {
minSdkVersion rootProject.ext.androidMinSdkVersion
targetSdkVersion rootProject.ext.androidTargetSdkVersion
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
versionCode rootProject.ext.androidVersionCode
versionName rootProject.ext.androidVersionName
minSdk = rootProject.ext.androidMinSdkVersion
targetSdk = rootProject.ext.androidTargetSdkVersion
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildFeatures {
buildConfig = true
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions { jvmTarget = "17" }

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
signedRelease {
minifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android.txt"),
"proguard-rules.pro"
)
}
create("signedRelease")
debug {
testCoverageEnabled = project.hasProperty('enableCoverage')
// Multidex is required as espresso and mockito/bytebuddy are adding more functions
// than should be allowed by law.
// See https://github.com/mockito/mockito/issues/1112
multiDexEnabled true
}
}

lintOptions {
// specific ignores should be defined via lint.xml file
lintConfig file('config/lint.xml')
ignore 'ClickableViewAccessibility', 'StaticFieldLeak', 'GradleDependency', 'OldTargetApi', 'LintBaseline'
textReport true
xmlReport true
htmlReport true
xmlOutput file("build/reports/lint-report.xml")
htmlOutput file("build/reports/lint-report.html")
lint {
lintConfig file("config/lint.xml")
disable "ClickableViewAccessibility", "StaticFieldLeak",
"GradleDependency", "OldTargetApi", "LintBaseline"
textReport = true
xmlReport = true
htmlReport = true
xmlOutput = file("build/reports/lint-report.xml")
htmlOutput = file("build/reports/lint-report.html")
}

testOptions {
Expand All @@ -111,54 +105,51 @@ android {

packagingOptions {
resources {
excludes += ['META-INF/AL2.0', 'META-INF/LGPL2.1', "**/attach_hotspot_windows.dll"]
merges += ['META-INF/licenses/ASM']
excludes += ["META-INF/AL2.0", "META-INF/LGPL2.1", "**/attach_hotspot_windows.dll"]
merges += ["META-INF/licenses/ASM"]
}
}
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'com.google.android.material:material:1.2.1'
implementation project(':colorpicker')
implementation "androidx.appcompat:appcompat:1.0.0"
implementation "com.google.android.material:material:1.2.1"
implementation project(":colorpicker")

implementation 'androidx.core:core-ktx:1.3.2'
implementation "androidx.core:core-ktx:1.3.2"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.8'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.8'
implementation 'androidx.exifinterface:exifinterface:1.3.2'
implementation 'com.esotericsoftware:kryo:5.5.0'
implementation 'id.zelory:compressor:2.1.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

debugImplementation 'androidx.multidex:multidex:2.0.0'

implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
implementation 'com.jraska:falcon:2.2.0'

testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.18.3'
testImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0'

androidTestImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.4.3'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test:rules:1.1.1'
androidTestImplementation 'org.mockito:mockito-android:3.6.28'
androidTestImplementation 'tools.fastlane:screengrab:2.1.0'
androidTestImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0'

androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.0'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.8"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.8"
implementation "androidx.exifinterface:exifinterface:1.3.2"
implementation "com.esotericsoftware:kryo:5.5.0"
implementation "id.zelory:compressor:2.1.1"
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
implementation 'androidx.test:monitor:1.8.0'

debugImplementation "androidx.multidex:multidex:2.0.0"

implementation "com.nostra13.universalimageloader:universal-image-loader:1.9.5"
implementation "com.jraska:falcon:2.2.0"

testImplementation "junit:junit:4.12"
testImplementation "org.mockito:mockito-core:2.18.3"
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"

androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.4.3"
androidTestImplementation "androidx.test.ext:junit:1.1.3"
androidTestImplementation "androidx.test:rules:1.1.1"
androidTestImplementation "org.mockito:mockito-android:3.6.28"
androidTestImplementation "tools.fastlane:screengrab:2.1.0"
androidTestImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"

androidTestImplementation "androidx.test.espresso:espresso-core:3.5.1"
androidTestImplementation "androidx.test.espresso:espresso-contrib:3.1.0"
androidTestImplementation "androidx.test.espresso:espresso-intents:3.1.0"
androidTestImplementation "androidx.test.uiautomator:uiautomator:2.2.0"
testImplementation "androidx.test:core-ktx:1.4.0"
implementation 'com.android.support.test.espresso:espresso-idling-resource:3.1.0'
}

tasks.withType(Javadoc).all {
enabled = false
implementation "androidx.test.espresso:espresso-idling-resource:3.5.1"
}

if (project.hasProperty('jenkins')) {
android.dexOptions.preDexLibraries = false
}
tasks.withType(Javadoc).configureEach { enabled = false }

Loading