Skip to content

Commit

Permalink
IDE-245 merge java11 support back to develop (Catrobat#4960)
Browse files Browse the repository at this point in the history
* DEVOPS-701 Introduce Java11 support (Catrobat#4851)

* Remove debug info from logs (Catrobat#4861)

Co-authored-by: Csongor Hegedüs <[email protected]>

* Changes suggested by Maria

* IDE-168 Migrate targetSDKVersion 33 (Catrobat#4897)

* Improve build pipeline

- Improve the handling of the emulator
- Add a gradle task to disable the animations in the emulator
- Log the output of the emulator
- Remove the shared .gradle volume

* IDE-150 Refactoring UI Espresso Tests and TestUtils (Catrobat#4748)

* CATROID-1461 New function "subtext(from, to, "string")" (Catrobat#4600)

* IDE-176 Rework formula editor

* CATROID-1597 - Fix error where directory does not exist in test (Catrobat#4913)

- some tests reference a directory which does not exists. This is now fixed by using a temporary directory.

* Fix disableAnimations task, to not run on evaluation. (Catrobat#4908)

* CATROID-1574 Add new CTL for the move steps brick (Catrobat#4825)

* HOTFIX add ic_assistant drawable for flavours

* [HOTFIX] Fix testThatAspectRatioRemainsUnchangedAfterResize unit test

* Copy unified dockerparameters from Jenkinsfile to other Jenkinsfiles (Catrobat#4942)

* [DEVOPS-788] Work on worker robustness and Gradle daemon crash (Catrobat#4944)

* Copy unified dockerparameters from Jenkinsfile to other Jenkinsfiles

* Remove volume in docker parameter

* Add disabling gradle cache

* Increase log level of emulator

* Add parantheses to end of aspectRatio function call

* Increase memory of container

* Increase memory in containers in other Jenkinsfiles

---------

Co-authored-by: Csongor Hegedüs <[email protected]>

---------

Co-authored-by: Csongor Hegedüs <[email protected]>
Co-authored-by: Csongor Hegedüs <[email protected]>
Co-authored-by: becothas <[email protected]>
Co-authored-by: Lukas Jedinger <[email protected]>
Co-authored-by: Thomas Végh <[email protected]>
Co-authored-by: Dominik <[email protected]>
Co-authored-by: Simon Schuster <[email protected]>
Co-authored-by: Patrick Ratschiller <[email protected]>
  • Loading branch information
9 people authored Apr 11, 2024
1 parent ad66b56 commit a128eac
Show file tree
Hide file tree
Showing 146 changed files with 115,849 additions and 115,516 deletions.
18 changes: 0 additions & 18 deletions .idea/vcs.xml

This file was deleted.

137 changes: 97 additions & 40 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,59 @@ 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 ' +
'-m=12G '
def label = 'LimitedEmulator'
def image = 'catrobat/catrobat-android:stable'
def image = 'catrobat/catrobat-android:api33'
}

def d = 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 -f --name android${android_version} --package " +
"'system-images;android-${android_version};google_apis;x86_64' || true"

sh "/home/user/android/sdk/emulator/emulator -avd android${android_version}" +
" -logcat *:w" +
" -wipe-data -no-window -no-boot-anim -noaudio" +
" -camera-back emulated -camera-front emulated " +
" -no-snapshot-save -accel on -gpu swiftshader_indirect > ${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"
'''
// In case the device went to sleep
sh 'adb shell input keyevent KEYCODE_WAKEUP'
}

def runTestsWithEmulator(String testClass) {
sh " ./gradlew compileCatroidDebugSources compileCatroidDebugAndroidTestSources"

waitForEmulatorAndPressWakeUpKey()

sh " ./gradlew disableAnimations -PenableCoverage createCatroidDebugAndroidTestCoverageReport" +
" -Pandroid.testInstrumentationRunnerArguments.class=${testClass} "

}

def postEmulator(String coverageNameAndLogcatPrefix) {
archiveArtifacts "${coverageNameAndLogcatPrefix}_emulator.log"
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 @@ -21,14 +67,23 @@ def junitAndCoverage(String jacocoReportDir, String jacocoReportXml, String cove
publishJacocoHtml jacocoReportDir, jacocoReportXml, coverageName
}

def postEmulator(String coverageNameAndLogcatPrefix) {
sh './gradlew stopEmulator'

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 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"
}

def webTestUrlParameter() {
Expand Down Expand Up @@ -57,6 +112,11 @@ def useDockerLabelParameter(dockerImage, defaultLabel) {
pipeline {
agent none

environment {
ANDROID_VERSION = 33
ADB_INSTALL_TIMEOUT = 60
}

parameters {
string name: 'WEB_TEST_URL', defaultValue: '', description: 'When set, all the archived ' +
'APKs will point to this Catrobat web server, useful for testing web changes. E.g https://web-test.catrob.at'
Expand Down Expand Up @@ -125,7 +185,7 @@ pipeline {
cron(env.BRANCH_NAME == 'develop' ? '@midnight' : '')
issueCommentTrigger('.*test this please.*')
}

stages {
stage('All') {
parallel {
Expand Down Expand Up @@ -211,9 +271,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 @@ -223,16 +282,17 @@ pipeline {
when {
expression { params.INSTRUMENTED_UNIT_TESTS == true }
}

steps {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh '''./gradlew -PenableCoverage -PlogcatFile=instrumented_unit_logcat.txt -Pemulator=android28 \
startEmulator createCatroidDebugAndroidTestCoverageReport \
-Pandroid.testInstrumentationRunnerArguments.class=org.catrobat.catroid.testsuites.LocalHeadlessTestSuite'''
startEmulator(ANDROID_VERSION, 'instrumented_unit')
runTestsWithEmulator("org.catrobat.catroid.testsuites.LocalHeadlessTestSuite")
}
}

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

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

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

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

post {
always {
postEmulator 'rtltests'
killRunningEmulator()
postEmulator('rtltests')
}
}
}
Expand Down Expand Up @@ -341,14 +398,14 @@ pipeline {
}
steps {
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
sh '''./gradlew copyAndroidNatives -PenableCoverage -PlogcatFile=pull_request_suite_logcat.txt -Pemulator=android28 \
startEmulator createCatroidDebugAndroidTestCoverageReport \
-Pandroid.testInstrumentationRunnerArguments.class=org.catrobat.catroid.testsuites.UiEspressoPullRequestTriggerSuite'''
startEmulator(ANDROID_VERSION, 'pull_request_suite')
runTestsWithEmulator("org.catrobat.catroid.testsuites.UiEspressoPullRequestTriggerSuite")
}
}

post {
always {
killRunningEmulator()
postEmulator 'pull_request_suite'
}
}
Expand All @@ -366,4 +423,4 @@ pipeline {
}
}
}
}
}
20 changes: 16 additions & 4 deletions Jenkinsfile.BuildStandalone
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
#!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 ' +
' -m=12G '
def label = 'LimitedEmulator'
def image = 'catrobat/catrobat-android:api33'
}

def d = new DockerParameters()

def standaloneApk = 'catroid/build/outputs/apk/standalone/debug/catroid-standalone-debug.apk'

pipeline {
agent {
agent {
docker {
image 'catrobat/catrobat-android:stable'
args '--device /dev/kvm:/dev/kvm -v /var/local/container_shared/gradle_cache/$EXECUTOR_NUMBER:/home/user/.gradle'
label 'Standalone'
image d.image
args d.args
label d.label
alwaysPull true
}
}
Expand Down
24 changes: 20 additions & 4 deletions Jenkinsfile.ManualTests
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
#!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 ' +
' -m=12G '
def label = 'LimitedEmulator'
def image = 'catrobat/catrobat-android:api33'
}

def d = new DockerParameters()

pipeline {
agent {
docker {
image 'catrobat/catrobat-android:stable'
args '--device /dev/kvm:/dev/kvm -v /var/local/container_shared/gradle_cache/$EXECUTOR_NUMBER:/home/user/.gradle -m=6.5G'
label 'LimitedEmulator'
image d.image
args d.args
label d.label
alwaysPull true
}
}

environment {
ANDROID_VERSION = 33
}

options {
timeout(time: 2, unit: 'HOURS')
timestamps()
Expand All @@ -26,7 +42,7 @@ pipeline {

stage('Unit and Device tests') {
steps {
sh """./gradlew -PenableCoverage -Pemulator=${env.EMULATOR} startEmulator \
sh """./gradlew -PenableCoverage -Pemulator=android${ANDROID_VERSION} startEmulator \
createCatroidDebugAndroidTestCoverageReport -Pandroid.testInstrumentationRunnerArguments.${env.TYPE}=${env.NAME}"""
}

Expand Down
23 changes: 19 additions & 4 deletions Jenkinsfile.OutgoingNetworkCallsTests
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
#!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 ' +
' -m=12G '
def label = 'LimitedEmulator'
def image = 'catrobat/catrobat-android:api33'
}

def d = new DockerParameters()
pipeline {
agent {
docker {
image 'catrobat/catrobat-android:stable'
args '--device /dev/kvm:/dev/kvm -v /var/local/container_shared/gradle_cache/$EXECUTOR_NUMBER:/home/user/.gradle -m=6.5G'
label 'LimitedEmulator'
image d.image
args d.args
label d.label
alwaysPull true
}
}

environment {
ANDROID_VERSION = 33
}

options {
timeout(time: 2, unit: 'HOURS')
timestamps()
Expand All @@ -18,7 +33,7 @@ pipeline {
stages {
stage('End to end tests requiring share authentication') {
steps {
sh '''./gradlew -PenableCoverage -Pemulator=android28 \
sh '''./gradlew -PenableCoverage -Pemulator=android${ANDROID_VERSION} \
startEmulator createCatroidDebugAndroidTestCoverageReport \
-Pandroid.testInstrumentationRunnerArguments.class=org.catrobat.catroid.testsuites.OutgoingNetworkCallsTestSuite'''
}
Expand Down
Loading

0 comments on commit a128eac

Please sign in to comment.