diff --git a/.github/workflows/library.yml b/.github/workflows/library.yml index 2ce1e20c..4e0c4e5b 100644 --- a/.github/workflows/library.yml +++ b/.github/workflows/library.yml @@ -46,10 +46,17 @@ jobs: run: git fetch origin master && git rev-list --first-parent --count origin/master - name: Clean project - run: ./gradlew clean --stacktrace + run: ./gradlew clean --stacktrace + + - name: Build project skipping tests + run: ./gradlew build -x test --stacktrace + + - name: Run Instrumented Tests manually + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 34 + script: ./gradlew :library:connectedDebug --stacktrace --info - - name: Run unit tests with Gradle - run: ./gradlew :library:clean :library:testDebugUnitTest --stacktrace - name: Generate & upload library snapshot artifact AAR (Android Archive) file run: ./gradlew :library:clean --stacktrace && ./gradlew :library:assembleRelease --stacktrace && ./gradlew :library:publishMavenJavaPublicationToMavenCentralRepository --stacktrace diff --git a/.github/workflows/utils.yml b/.github/workflows/utils.yml index 03ce438b..1f6046e4 100644 --- a/.github/workflows/utils.yml +++ b/.github/workflows/utils.yml @@ -48,6 +48,15 @@ jobs: - name: Clean project run: ./gradlew clean --stacktrace + - name: Build project skipping tests + run: ./gradlew build -x test --stacktrace + + - name: Run Instrumented Tests manually + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 34 + script: ./gradlew :utils:connectedDebug --stacktrace + - name: Generate & upload utils snapshot artifact AAR (Android Archive) file to Sonatype run: ./gradlew :utils:clean --stacktrace && ./gradlew :utils:assembleRelease --stacktrace && ./gradlew :utils:publishMavenJavaPublicationToMavenCentralRepository --stacktrace diff --git a/library/build.gradle b/library/build.gradle index 461db719..c628ddf5 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -121,7 +121,7 @@ dependencies { configuration -> // Comment the line below when creating releases - The line is for development of the library & utils implementation (project(":utils")) { // Uncomment the line below when creating releases - //implementation('io.ona.kujaku:utils:0.10.8-SNAPSHOT') { + implementation('io.ona.kujaku:utils:0.10.8-SNAPSHOT') { transitive = true exclude group: 'com.mapbox.mapboxsdk', module: 'mapbox-android-sdk' exclude group: 'com.android.support', module: 'support-v4' diff --git a/library/src/main/java/io/ona/kujaku/services/TrackingService.java b/library/src/main/java/io/ona/kujaku/services/TrackingService.java index e3c4f924..9359d4bf 100644 --- a/library/src/main/java/io/ona/kujaku/services/TrackingService.java +++ b/library/src/main/java/io/ona/kujaku/services/TrackingService.java @@ -502,7 +502,7 @@ private synchronized void recordPendingLocation() { /** * Volatile because different methods are called from the main thread and serviceThread */ - private final LocationListener locationListener = new LocationListener() { + private volatile LocationListener locationListener = new LocationListener() { @Override public void onStatusChanged(String provider, int status, Bundle extras) { diff --git a/library/src/test/java/io/ona/kujaku/services/MapboxOfflineDownloaderServiceTest.java b/library/src/test/java/io/ona/kujaku/services/MapboxOfflineDownloaderServiceTest.java index c84dc5b8..2d0f2af6 100644 --- a/library/src/test/java/io/ona/kujaku/services/MapboxOfflineDownloaderServiceTest.java +++ b/library/src/test/java/io/ona/kujaku/services/MapboxOfflineDownloaderServiceTest.java @@ -21,7 +21,6 @@ import org.json.JSONObject; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mockito; @@ -79,7 +78,7 @@ }) public class MapboxOfflineDownloaderServiceTest { - private String mapName = UUID.randomUUID().toString(); + private final String mapName = UUID.randomUUID().toString(); private static final String TAG = MapboxOfflineDownloaderServiceTest.class.getSimpleName(); private Context context; @@ -87,15 +86,15 @@ public class MapboxOfflineDownloaderServiceTest { private final String sampleValidMapboxStyleURL = "mapbox://styles/ona/90kiosdcIJ3d"; private String mapboxAccessToken; - private float minZoom = 22; - private float maxZoom = 10; - private LatLng topLeftBound = new LatLng(9.1, 9.1); - private LatLng topRightBound = new LatLng(9.1, 20.5); - private LatLng bottomRightBound = new LatLng(1.1, 20.5); - private LatLng bottomLeftBound = new LatLng(9.1, 1.1); + private final float minZoom = 22; + private final float maxZoom = 10; + private final LatLng topLeftBound = new LatLng(9.1, 9.1); + private final LatLng topRightBound = new LatLng(9.1, 20.5); + private final LatLng bottomRightBound = new LatLng(1.1, 20.5); + private final LatLng bottomLeftBound = new LatLng(9.1, 1.1); private CountDownLatch latch; - private ArrayList resultsToCheck = new ArrayList<>(); + private final ArrayList resultsToCheck = new ArrayList<>(); @Before public void setUp() throws Exception { @@ -241,19 +240,16 @@ public void persistOfflineMapTaskShouldSaveQueueTaskWhenGivenValidDownloadTask() } @Test - @Ignore("Hanging on CI") public void sendBroadcastShouldProduceValidIntentWhenGivenDownloadUpdate() { assertValidBroadcastCreatedWhenSendBroadcastIsCalled(MapboxOfflineDownloaderService.SERVICE_ACTION_RESULT.SUCCESSFUL, mapName, "9.0%", MapboxOfflineDownloaderService.SERVICE_ACTION.DOWNLOAD_MAP); } @Test - @Ignore("Hanging on CI") public void sendBroadcast2ShouldProduceValidIntentWhenGivenDownloadUpdate() { assertValidBroadcastCreatedWhenSendBroadcast2IsCalled(MapboxOfflineDownloaderService.SERVICE_ACTION_RESULT.SUCCESSFUL, mapName, MapboxOfflineDownloaderService.SERVICE_ACTION.DELETE_MAP); } @Test - @Ignore("Hanging on CI") public void mapboxTileLimitExceededShouldCreateValidBroadcast() throws InterruptedException, NoSuchFieldException, IllegalAccessException { latch = new CountDownLatch(1); @@ -269,7 +265,6 @@ public void mapboxTileLimitExceededShouldCreateValidBroadcast() throws Interrupt } @Test - @Ignore("Failing : To Do Fix") public void onErrorShouldCreateValidBroadcastWhenGivenNonEmptyReasonAndMessage() throws NoSuchFieldException, IllegalAccessException { latch = new CountDownLatch(1); @@ -286,7 +281,6 @@ public void onErrorShouldCreateValidBroadcastWhenGivenNonEmptyReasonAndMessage() } @Test - @Ignore("Hanging on CI") public void onErrorShouldCreateValidBroadcastWhenGivenNonEmptyReasonAndEmptyMessage() throws NoSuchFieldException, IllegalAccessException, InterruptedException { latch = new CountDownLatch(1); @@ -304,7 +298,6 @@ public void onErrorShouldCreateValidBroadcastWhenGivenNonEmptyReasonAndEmptyMess } @Test - @Ignore("Hanging on CI") public void onStatusChangedShouldShowProgressNotificationWhenGivenIncompleteOfflineRegionStatus() throws NoSuchFieldException, IllegalAccessException, InterruptedException, NoSuchMethodException, InvocationTargetException { latch = new CountDownLatch(1); OfflineRegionStatus incompleteOfflineRegionStatus = createOfflineRegion(OfflineRegion.STATE_ACTIVE, 200, 98923, 898, 230909, 300, true, false); @@ -427,7 +420,6 @@ public void getTaskStatusShouldUpdateCurrentDownloadMapNameWhenGivenValidDeleteQ } @Test - @Ignore("Hanging on CI") public synchronized void onStatusChangedShouldShowDownloadCompleteNotificationWhenGivenCompletedOfflineRegion() throws Throwable { latch = new CountDownLatch(1); OfflineRegionStatus completeOfflineRegionStatus = createOfflineRegion(OfflineRegion.STATE_ACTIVE, 300, 98923, 898, 230909, 300, true, true); diff --git a/library/src/test/java/io/ona/kujaku/services/TrackingServiceTest.java b/library/src/test/java/io/ona/kujaku/services/TrackingServiceTest.java index 2309d4ac..e6e40d76 100644 --- a/library/src/test/java/io/ona/kujaku/services/TrackingServiceTest.java +++ b/library/src/test/java/io/ona/kujaku/services/TrackingServiceTest.java @@ -192,7 +192,6 @@ public void testTrackingServiceDefaultUiConfiguration() { } @Test - @Ignore("Hanging on CI") public void testStartAndBindService() throws InterruptedException { CountDownLatch latch1 = new CountDownLatch(1); CountDownLatch latch2 = new CountDownLatch(1); @@ -222,7 +221,6 @@ public void onServiceDisconnected(ComponentName name) { } @Test - @Ignore("Hanging on CI") public void testServiceWithLocationInDistanceTolerance() throws InterruptedException { controller = Robolectric.buildService(TrackingService.class, TrackingService.getIntent(context, MapActivity.class, new TrackingServiceHighAccuracyOptions())); @@ -320,7 +318,6 @@ public void onServiceDisconnected() { } @Test - @Ignore("Flakey Unit Test : To Do Fix") public void testServiceWithTags() throws InterruptedException { long startTag = 1000; long nextTag = 2000;