From 7dcea7ace3250efce668d462848ee0539822befd Mon Sep 17 00:00:00 2001 From: PenguinEncounter <49845522+penguinencounter@users.noreply.github.com> Date: Mon, 10 Jun 2024 16:29:39 -0700 Subject: [PATCH] Gradle optimizations + Actions builds --- .github/workflows/build_and_test.yml | 36 ++++++++++++++++++++++++++++ TeamCode/build.gradle | 3 +++ build.common.gradle | 1 + build.dependencies.gradle | 2 ++ build.gradle | 2 ++ gradle.properties | 7 +++--- 6 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/build_and_test.yml diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml new file mode 100644 index 000000000000..85eb46898973 --- /dev/null +++ b/.github/workflows/build_and_test.yml @@ -0,0 +1,36 @@ +name: Build and Test + +on: + pull_request: + push: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up JDK + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + - name: Set +x + run: chmod a+x gradlew + - name: Build and test + run: ./gradlew clean assembleDebug test + - name: Collate tests + if: ${{ true }} + run: | + mkdir -p build/test_results + find . -regextype posix-extended -regex '.*reports/tests/([^/]+?)' -exec cp -r {} build/test_results/ \; + - name: Upload test results + if: ${{ true }} + uses: actions/upload-artifact@v4 + with: + name: test-results + path: build/test_results + - name: Upload APK + uses: actions/upload-artifact@v4 + with: + name: app-debug + path: TeamCode/build/outputs/apk/debug/TeamCode-debug.apk diff --git a/TeamCode/build.gradle b/TeamCode/build.gradle index dd9be15a6be9..2af1b8084759 100644 --- a/TeamCode/build.gradle +++ b/TeamCode/build.gradle @@ -34,3 +34,6 @@ dependencies { testImplementation 'org.junit.jupiter:junit-jupiter:5.8.1' annotationProcessor files('lib/OpModeAnnotationProcessor.jar') } +tasks.withType(Test).configureEach { + useJUnitPlatform() +} diff --git a/build.common.gradle b/build.common.gradle index 59d82863eeb1..4a4b41c34672 100644 --- a/build.common.gradle +++ b/build.common.gradle @@ -17,6 +17,7 @@ import java.util.regex.Pattern +apply plugin: 'com.adarshr.test-logger' apply plugin: 'com.android.application' apply plugin: 'org.jetbrains.kotlin.android' diff --git a/build.dependencies.gradle b/build.dependencies.gradle index f5eae9739202..938d0c5bb821 100644 --- a/build.dependencies.gradle +++ b/build.dependencies.gradle @@ -19,5 +19,7 @@ dependencies { runtimeOnly 'org.tensorflow:tensorflow-lite:2.12.0' implementation 'androidx.core:core-ktx:1.13.1' implementation 'androidx.appcompat:appcompat:1.2.0' + testImplementation 'org.junit.jupiter:junit-jupiter:5.9.2' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } diff --git a/build.gradle b/build.gradle index 480fa8e02759..147112e683d6 100644 --- a/build.gradle +++ b/build.gradle @@ -11,12 +11,14 @@ buildscript { repositories { mavenCentral() google() + gradlePluginPortal() } dependencies { // Note for FTC Teams: Do not modify this yourself. // no lol -Miles classpath 'com.android.tools.build:gradle:8.4.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath "com.adarshr:gradle-test-logger-plugin:4.0.0" } } diff --git a/gradle.properties b/gradle.properties index 70890bc6c24c..7e6507794dac 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,8 @@ android.useAndroidX=true # Automatically convert third-party libraries to use AndroidX android.enableJetifier=true -# Allow Gradle to use up to 1 GB of RAM -org.gradle.jvmargs=-Xmx1024M +# Allow Gradle to use up to 2 GB of RAM +org.gradle.jvmargs=-Xmx2048M android.nonTransitiveRClass=false -android.nonFinalResIds=false +android.nonFinalResIds=true +org.gradle.configuration-cache=true