Skip to content

Commit

Permalink
IDE-168 Migrate targetSDKVersion 33
Browse files Browse the repository at this point in the history
  • Loading branch information
becothas authored and dorianpercic committed Nov 3, 2023
1 parent b05a171 commit 8feccf6
Show file tree
Hide file tree
Showing 32 changed files with 182 additions and 289 deletions.
129 changes: 77 additions & 52 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,46 @@ 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 -v /var/local/container_shared/huawei:/home/user/huawei -m=8G'
def args = '--device /dev/kvm:/dev/kvm -v ' +
'/var/local/container_shared/gradle_cache/$EXECUTOR_NUMBER:/home/user/.gradle -v ' +
'/var/local/container_shared/huawei:/home/user/huawei -m=8G '
def label = 'LimitedEmulator'
def image = 'catrobat/catrobat-android:api33'
}

def d = new DockerParameters()

def startEmulator(String android_version) {
sh "adb start-server"
// creates a new avd, and if it already exists it does nothing.
sh "echo no | avdmanager create avd --name android${android_version} --package " +
"'system-images;android-${android_version};google_apis;x86_64' || true"
sh "/home/user/android/sdk/emulator/emulator -wipe-data -no-window -no-boot-anim -noaudio " +
"-no-snapshot-save -gpu swiftshader_indirect" +
" -avd android${android_version} &"

sh "timeout 5m adb wait-for-device"
sh '''#!/bin/bash
timeout 5m adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1;
done'
echo "Emulator started"
'''
}

def runTestsWithEmulator(String testClass) {
sh " ./gradlew -PenableCoverage \
createCatroidDebugAndroidTestCoverageReport \
-Pandroid.testInstrumentationRunnerArguments.class=${testClass} "
}

def postEmulator(String coverageNameAndLogcatPrefix) {
zip zipFile: "${coverageNameAndLogcatPrefix}_logcat.zip", dir: "catroid/build/outputs/androidTest-results/connected/flavors/", archive: true
def jacocoReportDir = 'catroid/build/reports/coverage/androidTest/catroid/debug/connected'
if (fileExists('catroid/build/reports/coverage/androidTest/catroid/debug/connected/report.xml')) {
junitAndCoverage jacocoReportDir, 'report.xml', coverageNameAndLogcatPrefix
}
}

def junitAndCoverage(String jacocoReportDir, String jacocoReportXml, String coverageName) {
// Consume all test xml files. Otherwise tests would be tracked multiple
// times if this function was called again.
Expand All @@ -20,19 +53,24 @@ def junitAndCoverage(String jacocoReportDir, String jacocoReportXml, String cove

publishJacocoHtml jacocoReportDir, jacocoReportXml, coverageName
}

def postEmulator(String coverageNameAndLogcatPrefix) {
def jacocoReportDir = 'catroid/build/reports/coverage/catroid/debug'
if (fileExists('catroid/build/reports/coverage/catroid/debug/report.xml')){
junitAndCoverage jacocoReportDir, 'report.xml', coverageNameAndLogcatPrefix
archiveArtifacts "${coverageNameAndLogcatPrefix}_logcat.txt"
}
}

def startEmulator(String android_version){
sh "adb start-server"
sh "echo no | avdmanager create avd --name android${android_version} --package 'system-images;android-${android_version};google_apis;x86_64'"
sh "/home/user/android/sdk/emulator/emulator -no-window -no-boot-anim -noaudio -avd android${android_version} &"
def killRunningEmulator() {
sh '''adb emu kill || true'''
sh '''#!/bin/bash
while :
do
output=$(eval "adb devices")
if [[ $output != *"emulator"* ]]; then
echo "All Emulators are killed"
echo $output
break
fi
echo "Emulator is still running"
sleep 2
done
'''
sh "adb kill-server"
sh "kill -f 'emulator -avd android${ANDROID_VERSION}' || true"
}

def webTestUrlParameter() {
Expand Down Expand Up @@ -116,7 +154,7 @@ pipeline {
cron(env.BRANCH_NAME == 'develop' ? '@midnight' : '')
issueCommentTrigger('.*test this please.*')
}

stages {
stage('All') {
parallel {
Expand Down Expand Up @@ -179,9 +217,8 @@ pipeline {
}
steps {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "./gradlew ${debugUnitTests()} -PenableCoverage jacocoTestCatroidDebugUnitTestReport --full-stacktrace"
sh 'mkdir -p catroid/build/reports/jacoco/jacocoTestCatroidDebugUnitTestReport/'
sh 'touch catroid/build/reports/jacoco/jacocoTestCatroidDebugUnitTestReport/jacocoTestCatroidDebugUnitTestReport.xml'
sh "./gradlew ${debugUnitTests()} -PenableCoverage " +
"jacocoTestCatroidDebugUnitTestReport --full-stacktrace"
junitAndCoverage 'catroid/build/reports/jacoco/jacocoTestCatroidDebugUnitTestReport', 'jacocoTestCatroidDebugUnitTestReport.xml', 'unit'
}
}
Expand All @@ -193,15 +230,14 @@ pipeline {
}
steps {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
startEmulator("${ANDROID_VERSION}")
sh '''./gradlew -PenableCoverage -PlogcatFile=instrumented_unit_logcat.txt -Pemulator=android${ANDROID_VERSION} \
createCatroidDebugAndroidTestCoverageReport \
-Pandroid.testInstrumentationRunnerArguments.class=org.catrobat.catroid.testsuites.LocalHeadlessTestSuite'''
startEmulator(ANDROID_VERSION)
runTestsWithEmulator("org.catrobat.catroid.testsuites.LocalHeadlessTestSuite")
}
}

post {
always {
killRunningEmulator()
postEmulator 'instrumented_unit'
}
}
Expand All @@ -213,15 +249,14 @@ pipeline {
}
steps {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh '''
./gradlew -PenableCoverage -PlogcatFile=testrunner_logcat.txt -Pemulator=android${ANDROID_VERSION} \
createCatroidDebugAndroidTestCoverageReport \
-Pandroid.testInstrumentationRunnerArguments.package=org.catrobat.catroid.catrobattestrunner'''
startEmulator(ANDROID_VERSION)
runTestsWithEmulator("org.catrobat.catroid.catrobattestrunner.CatrobatTestRunner")
}
}

post {
always {
killRunningEmulator()
postEmulator 'testrunner'
}
}
Expand All @@ -233,15 +268,14 @@ pipeline {
}
steps {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh '''
./gradlew -PenableCoverage -PlogcatFile=quarantined_logcat.txt \
createCatroidDebugAndroidTestCoverageReport -Pemulator=android${ANDROID_VERSION} \
-Pandroid.testInstrumentationRunnerArguments.class=org.catrobat.catroid.testsuites.UiEspressoQuarantineTestSuite'''
startEmulator(ANDROID_VERSION)
runTestsWithEmulator("org.catrobat.catroid.testsuites.UiEspressoQuarantineTestSuite")
}
}

post {
always {
killRunningEmulator()
postEmulator 'quarantined'
}
}
Expand All @@ -252,20 +286,16 @@ pipeline {
expression { params.OUTGOING_NETWORK_CALL_TESTS == true }
}
steps {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE')
{
sh '''
./gradlew -PenableCoverage -Pemulator=android${ANDROID_VERSION} \
createCatroidDebugAndroidTestCoverageReport -Pemulator=android${ANDROID_VERSION} \
-Pandroid.testInstrumentationRunnerArguments.class=org.catrobat.catroid.testsuites.OutgoingNetworkCallsTestSuite'''
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
startEmulator(ANDROID_VERSION)
runTestsWithEmulator("org.catrobat.catroid.testsuites.OutgoingNetworkCallsTestSuite")
}
}
post {
always {
junit '**/*TEST*.xml'
postEmulator 'networktest'
archiveArtifacts 'logcat.txt'
}
killRunningEmulator()
postEmulator('networktest')
}
}
}

Expand All @@ -275,15 +305,15 @@ pipeline {
}
steps {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh '''./gradlew -PenableCoverage -PlogcatFile=rtltests_logcat.txt \
createCatroidDebugAndroidTestCoverageReport -Pemulator=android${ANDROID_VERSION} \
-Pandroid.testInstrumentationRunnerArguments.class=org.catrobat.catroid.testsuites.UiEspressoRtlTestSuite'''
startEmulator(ANDROID_VERSION)
runTestsWithEmulator("org.catrobat.catroid.testsuites.UiEspressoRtlTestSuite")
}
}

post {
always {
postEmulator 'rtltests'
killRunningEmulator()
postEmulator( 'rtltests')
}
}
}
Expand All @@ -292,7 +322,6 @@ pipeline {
post {
always {
stash name: 'logParserRules', includes: 'buildScripts/log_parser_rules'
adb kill-server
}
}
}
Expand All @@ -314,19 +343,15 @@ pipeline {
}
steps {
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
startEmulator("${ANDROID_VERSION}")
sh '''
./gradlew copyAndroidNatives -PenableCoverage -PlogcatFile=pull_request_suite_logcat.txt -Pemulator=android${ANDROID_VERSION} \
createCatroidDebugAndroidTestCoverageReport -Pemulator=android${ANDROID_VERSION} \
-Pandroid.testInstrumentationRunnerArguments.class=org.catrobat.catroid.testsuites.UiEspressoPullRequestTriggerSuite
'''
startEmulator(ANDROID_VERSION)
runTestsWithEmulator("org.catrobat.catroid.testsuites.UiEspressoPullRequestTriggerSuite")
}
}

post {
always {
killRunningEmulator()
postEmulator 'pull_request_suite'
adb kill-server
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ buildscript {
dependencies {
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.android.tools.build:gradle:7.0.0'
classpath 'com.android.tools.build:gradle:7.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jacoco:org.jacoco.core:$jacoco_core_version"
classpath 'org.catrobat.gradle.androidemulators:android-emulators-gradle:1.6.2'
classpath 'com.huawei.agconnect:agcp:1.4.2.300'
}
}

allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven { url "https://developer.huawei.com/repo/" }
Expand Down
38 changes: 20 additions & 18 deletions catroid/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import com.android.build.api.dsl.ManagedVirtualDevice

/*
* Catroid: An on-device visual programming system for Android devices
* Copyright (C) 2010-2022 The Catrobat Team
Expand Down Expand Up @@ -63,7 +65,6 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

apply from: 'gradle/code_quality_tasks.gradle'
apply from: 'gradle/emulator_tasks.gradle'
apply from: 'gradle/release_crowdin_tasks.gradle'
apply from: 'gradle/release_fastlane_tasks.gradle'
apply from: 'gradle/standalone_apk_tasks.gradle'
Expand Down Expand Up @@ -104,7 +105,8 @@ def defaultVersionCode = 88
def defaultVersionName = "1.1.2"

android {
compileSdkVersion 33
compileSdk 33
buildToolsVersion = "33.0.2"

namespace 'org.catrobat.catroid'

Expand Down Expand Up @@ -183,6 +185,7 @@ android {
unitTests.all {
jvmArgs '-Xmx2g'
}
animationsDisabled = true
}

sourceSets {
Expand Down Expand Up @@ -252,30 +255,27 @@ android {
}
}

flavorDimensions "default"
flavorDimensions = ["default"]
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
aaptOptions {
androidResources {
noCompress 'lite'
}

lintOptions {
lintConfig file('config/lint.xml')
ignore 'GradleDependency', 'OldTargetApi', 'ExtraTranslation', 'MissingTranslation',
'LintBaseline', 'ObsoleteLintCustomCheck'

lint {
abortOnError false

baseline file('config/lint-baseline.xml')
htmlOutput file('build/reports/lint-report.html')
htmlReport true
ignore 'GradleDependency', 'OldTargetApi', 'ExtraTranslation', 'MissingTranslation', 'LintBaseline', 'ObsoleteLintCustomCheck'
lintConfig file('config/lint.xml')
textReport true
xmlOutput file('build/reports/lint-report.xml')
xmlReport true
htmlReport true
xmlOutput file("build/reports/lint-report.xml")
htmlOutput file("build/reports/lint-report.html")
baseline file('config/lint-baseline.xml')
}


productFlavors {
catroid {
isDefault.set(true)
Expand Down Expand Up @@ -373,7 +373,7 @@ dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
androidTestImplementation project(path: ':catroid')
androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version"
androidTestImplementation ('androidx.arch.core:core-testing:2.1.0') {
androidTestImplementation('androidx.arch.core:core-testing:2.2.0') {
exclude group: 'org.mockito', module: 'mockito-core'
}

Expand Down Expand Up @@ -490,7 +490,7 @@ dependencies {
}
androidTestImplementation "androidx.test.espresso:espresso-web:$espressoVersion"

testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13.2'
testImplementation "org.mockito:mockito-core:$mockitoVersion"
testImplementation 'org.hamcrest:hamcrest-library:1.3'

Expand All @@ -513,7 +513,9 @@ dependencies {
androidTestImplementation "org.mockito:mockito-android:$mockitoVersion"
androidTestImplementation "org.mockito:mockito-core:$mockitoVersion"

androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.5'

androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
androidTestImplementation "androidx.test.espresso:espresso-contrib:$espressoVersion"
androidTestImplementation "androidx.test.espresso:espresso-intents:$espressoVersion"
Expand Down
4 changes: 2 additions & 2 deletions catroid/config/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ style:
UnnecessaryLet:
active: true
UnnecessaryParentheses:
active: true
active: false
UntilInsteadOfRangeTo:
active: true
UnusedImports:
Expand Down Expand Up @@ -560,4 +560,4 @@ style:
WildcardImport:
active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
excludeImports: 'java.util.*,kotlinx.android.synthetic.*'
excludeImports: 'java.util.*,kotlinx.android.synthetic.*'
Loading

0 comments on commit 8feccf6

Please sign in to comment.