diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..99f0199 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,49 @@ +name: Continuous Integration +on: [push, pull_request] + +jobs: + test: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: "recursive" + + - name: Set up JDK environment + uses: actions/setup-java@v3 + with: + distribution: "zulu" + java-version: 17 + + - name: Make gradlew executable + run: chmod +x ./gradlew + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + + - name: Run local unit tests + run: bash ./gradlew test --stacktrace + + build: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: "recursive" + + - name: Set up JDK environment + uses: actions/setup-java@v3 + with: + distribution: "zulu" + java-version: 17 + + - name: Make gradlew executable + run: chmod +x ./gradlew + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + + - name: Build the app + run: bash ./gradlew build --stacktrace \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 3a43c47..8666ad2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { applicationId "org.secuso.privacyfriendlypaindiary" minSdkVersion 21 targetSdkVersion 31 - versionCode 4 - versionName "1.3.0" + versionCode 5 + versionName "1.3.1" testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } buildTypes { @@ -22,20 +22,29 @@ android { lintOptions { abortOnError false } + + android.applicationVariants.configureEach { variant -> + variant.outputs.all { + def appName = "pfa-pain-diary" + outputFileName = appName + "-${variant.name}-v${variant.versionName}.apk" + } + } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) testImplementation 'junit:junit:4.12' androidTestImplementation 'junit:junit:4.12' - androidTestImplementation ('androidx.test.ext:junit:1.1.1') { + androidTestImplementation('androidx.test.ext:junit:1.1.1') { exclude group: 'com.android.support', module: 'support-annotations' } + androidTestImplementation('androidx.test:runner:1.5.2') + androidTestImplementation('androidx.test:core:1.5.0') implementation 'androidx.appcompat:appcompat:1.4.2' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'com.google.android.material:material:1.2.1' implementation 'com.prolificinteractive:material-calendarview:1.4.3' - implementation ("com.github.bumptech.glide:glide:4.6.1") { + implementation("com.github.bumptech.glide:glide:4.6.1") { exclude group: "com.android.support" } annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1' diff --git a/app/src/androidTest/java/org/secuso/privacyfriendlypaindiary/ApplicationTest.java b/app/src/androidTest/java/org/secuso/privacyfriendlypaindiary/ApplicationTest.java index 68c0611..543c823 100644 --- a/app/src/androidTest/java/org/secuso/privacyfriendlypaindiary/ApplicationTest.java +++ b/app/src/androidTest/java/org/secuso/privacyfriendlypaindiary/ApplicationTest.java @@ -16,14 +16,21 @@ License, or (at your option) any later version. */ package org.secuso.privacyfriendlypaindiary; -import android.app.Application; -import android.test.ApplicationTestCase; +import static org.junit.Assert.assertEquals; + +import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.platform.app.InstrumentationRegistry; + +import org.junit.Test; +import org.junit.runner.RunWith; /** * Testing Fundamentals */ -public class ApplicationTest extends ApplicationTestCase { - public ApplicationTest() { - super(Application.class); +@RunWith(AndroidJUnit4.class) +public class ApplicationTest { + @Test + public void instrumentationTest() throws Exception { + assertEquals("org.secuso.privacyfriendlypaindiary", InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageName()); } } \ No newline at end of file diff --git a/app/src/androidTest/java/org/secuso/privacyfriendlypaindiary/DBServiceTest.java b/app/src/androidTest/java/org/secuso/privacyfriendlypaindiary/DBServiceTest.java index 0ad57a0..d8dddb5 100644 --- a/app/src/androidTest/java/org/secuso/privacyfriendlypaindiary/DBServiceTest.java +++ b/app/src/androidTest/java/org/secuso/privacyfriendlypaindiary/DBServiceTest.java @@ -16,14 +16,19 @@ License, or (at your option) any later version. */ package org.secuso.privacyfriendlypaindiary; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; +import static junit.framework.TestCase.assertNotNull; +import static junit.framework.TestCase.fail; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.platform.app.InstrumentationRegistry; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.secuso.privacyfriendlypaindiary.database.DBService; +import org.secuso.privacyfriendlypaindiary.database.PainDiaryDatabaseService; import org.secuso.privacyfriendlypaindiary.database.entities.enums.BodyRegion; import org.secuso.privacyfriendlypaindiary.database.entities.enums.Condition; import org.secuso.privacyfriendlypaindiary.database.entities.enums.Gender; @@ -47,15 +52,9 @@ License, or (at your option) any later version. import java.util.List; import java.util.Set; -import static junit.framework.TestCase.assertNotNull; -import static junit.framework.TestCase.fail; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - /** * This class tests the basic database functionality, i.e. the methods of the class - * {@link DBService}. + * {@link PainDiaryDatabaseService}. * * @author Susanne Felsen * @version 20180110 @@ -65,17 +64,17 @@ License, or (at your option) any later version. @RunWith(AndroidJUnit4.class) public class DBServiceTest { - DBService service; + PainDiaryDatabaseService service; @Before public void setUp() { - service = DBService.getInstance(InstrumentationRegistry.getTargetContext()); - service.reinitializeDatabase(); + service = PainDiaryDatabaseService.getInstance(InstrumentationRegistry.getInstrumentation().getTargetContext()); + service.reinitializeDatabase(InstrumentationRegistry.getInstrumentation().getTargetContext()); } @After public void tearDown() throws Exception { - service.close(); + //service.close(); } @Test @@ -169,7 +168,7 @@ public void testDiaryEntryAndAssociatedObjects() { assertEquals("Times of Pain were incorrect.", timesOfPain, painDescription.getTimesOfPain()); Set intakes = entry.getDrugIntakes(); - assertEquals("Number of Drug Intakes was incorrect.", 1, intakes.size()); + assertEquals("Number of Drug Intakes was incorrect.", 1, intakes.size()); drugIntake = intakes.iterator().next(); assertEquals("Quantity Morning was incorrect.", quantityMorning, drugIntake.getQuantityMorning()); assertEquals("Quantity Noon was incorrect.", quantityNoon, drugIntake.getQuantityNoon()); diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0a93aca..642617a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -21,8 +21,8 @@ android:theme="@style/AppTheme">