Skip to content

Commit

Permalink
Add ci settings
Browse files Browse the repository at this point in the history
  • Loading branch information
gen0083 committed Nov 8, 2016
1 parent 535c437 commit ec8906d
Show file tree
Hide file tree
Showing 12 changed files with 225 additions and 59 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
/build /build
/captures /captures
.externalNativeBuild .externalNativeBuild
release.keystore
filteredhatebu_play_api.json
48 changes: 48 additions & 0 deletions .travis.yml
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,48 @@
language: android
android:
components:
- tools
- platform-tools
- build-tools-25.0.0
- android-25
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
- addon-google_apis-google-19
- sys-img-armeabi-v7a-android-19
jdk:
- oraclejdk8
before_install:
- openssl aes-256-cbc -K $encrypted_da784680a32e_key -iv $encrypted_da784680a32e_iv -in encrypted.tar.enc -out encrypted.tar -d
- tar xvf encrypted.tar
- echo $ANDROID_HOME
- mkdir -p $ANDROID_HOME/licenses
- echo -e "e6b7c2ab7fa2298c15165e9583d0acf0b04a2232\n8933bad161af4178b1185d1a37fbf41ea5269c55" > $ANDROID_HOME/licenses/android-sdk-license
env:
global:
- ADB_INSTALL_TIMEOUT=10
- secure: IQ48XiX7PbRLtpX7S0lPjDFLb4IcyKFrjGkhiYtqGdw18vmx6SegkMgilGXYqKMXT5U1lK02Fb4m+H0gO1lZ4qCzaW8HJ2ST6ylXhmYKEoel8ad5ylArAbY6qk8LkDdGEK56EkNdh6xzZxpRkW7XwBE/lD2bOnGh4gw4uNomxwbvQYGHzax2acn25INJ7RMLadirsirzBQUpaESS2k/00qwZp+jLzBh/gYzOWezGNFj1UIPoKXSmZiXBJAWIHzQKcmYp2VGqlYE+m/ggQXrqwx2ipaDSx1mDeVJRV/Zn7flAx/UoopgbMKasJdR9oe5aB5dQMtWCUyRQrsaDkb+l/PnXNjvDpFdB0FgSRHMslW5DggqzorNSEzE7vrEDeBDR4qqs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gbeXFL563k8kcolsGubxkXOIYKHeJbJ5GEU7MiluwUuWXRfdpw//n4WBLpZ2T2Py32NplUAmSQlwW5t0GQiYutdzwt4VIQZHBB4X43mZsOGRmISjBPp1lrs47GRFgMwTZemKoZzdBKvvFeyh7IEVxKvjf9Bd/c3PLhgPf3SnTJdOEMPBIFPuRaWPSinghmJ0qaMC2E8pYjn17u4lz9jatXkAjOg4HTFS2k6ve/W3xSgxxNugs743D06ay6LK3cOhniexeSwtKiYqKrY76SlDIAiKS8M1olUWPHuvvh7jSZADHU6u6JBYf0/cjCcvJ6aBCJLhduxQYPnsepQ8SmCIhTrkZzA+UHPsy5dnxxouuIaD7nSzpXaxjogGD6jtiexgkNcQZBME9mf+6cOfjs40hBowtwu1JmAI4eY46ttcIKpoUV0hRGCi3G+Z9Ujiu56kj5nGP9fXKT7ywiD4gJKltO4F8TBvpqv4nS6p7BBls1RakTG8rqsNXVJpoyQl/PMsnPzSaXbSgYJmzFH1N4A3rQdw9pn7qN0krZQV19oXIgLJa9B0X4iWE6o/+GmiAvjCgfgjnyIikIyZ+soLU=
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
cache:
directories:
- "$HOME/.gradle/caches/"
- "$HOME/.gradle/wrapper/"
script:
- "./gradlew testProdDebugUnitTest"
- echo no | android create avd --force -n test -t android-19 --abi armeabi-v7a
- emulator -avd test -no-skin -no-audio -no-window &
- android-wait-for-emulator
- sleep 10
- adb shell settings put global window_animation_scale 0
- adb shell settings put global transition_animation_scale 0
- adb shell settings put global animator_duration_scale 0
- adb shell input keyevent 82
- "./gradlew connectedAndroidTest"
notifications:
slack:
secure: PyCqXWFVULLq19pk2Q2fpKlQp0+ETvWe+n7wV6+Xy7J6KBoKVarQ4bBqWJEUAq9AKn1nzW0WUsyZRA1+QvYHpeQZF+e3ayyTiBJetLfwCRAzW6EHRHRTBBeMwV0v6Aft0k07uJpu3d89+joHo/7Eg7tlvbCgXj1obq9YrXWGmNJnEf0XWbfs6O4pl0tnRDJ90eRJPlWRD6AdMHb+B5N38bJ7YMhEgp+Vd3tZ+PzxOLHMV/LOpA5Eb8dbnJFtVpD2yuo10dggjNSJ2peDocpC1aAV6LkSCgC/UoHJpn2FUT3OnYUyHHyX5lt1Z3BbuYh0DMyockR/cG3ctCl7V63FoOPxEo57xqpgfMIJVU88VgVNF21GFAA8LSrYzJ7hCjP0zcw58iUecm9Fi6G//ZL7HLt66Wf/oqT821vCyZBQI+JSb3/EdpyN6V5wkZ/p5lOjMe+gVophlxElggjo87iH+jDwaEfPm/2nlrasPpR8mx5zFR/WUvJZVy21EQrc8poOw3WQKWHpIdx9uBgPrHDGA4PQ76wJNLy8/pnTBfKfyW9VDLwLl4Qoerj2W9lUIgS68ZtAyecIjV7UcHyzO1rXoDVQLo/q+c4ZC5K7Ca1EdcGhqmhkc85qZUt5p/KnsTXhjVbWe8X1GHBGgTFbQwg8SCcauqTYq4sC24Lpl99eq5o=
email: false
sudo: false
63 changes: 60 additions & 3 deletions app/build.gradle
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ apply plugin: 'com.cookpad.android.licensetools'
apply plugin: 'io.fabric' apply plugin: 'io.fabric'
apply plugin: 'com.github.triplet.play' apply plugin: 'com.github.triplet.play'


android { ext {
apply from: "${System.getenv('HOME')}/.android-mykey/FilteredHatebu.sign.gradle", to: android ciBuild = System.getenv("CI") == "true"
travisBuild = System.getenv("TRAVIS") == "true"
}


android {
compileSdkVersion 25 compileSdkVersion 25
buildToolsVersion "25.0.0" buildToolsVersion "25.0.0"
defaultConfig { defaultConfig {
Expand All @@ -24,6 +27,30 @@ android {
prod { prod {
} }
} }
signingConfigs {
debug {
storeFile rootProject.file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
release {
// Travisでだけリリースビルドを行う
if (travisBuild) {
storeFile rootProject.file('release.keystore')
storePassword System.getenv('filtered_hatebu_pass')
keyAlias System.getenv('filtered_hatebu_alias')
keyPassword System.getenv('filtered_hatebu_key_pass')
}
// ローカルビルド
if (!ciBuild) {
storeFile rootProject.file('release.keystore')
storePassword getProperty('filtered_hatebu_pass')
keyAlias getProperty('filtered_hatebu_alias')
keyPassword getProperty('filtered_hatebu_key_pass')
}
}
}
buildTypes { buildTypes {
debug { debug {
minifyEnabled false minifyEnabled false
Expand All @@ -40,6 +67,9 @@ android {
dataBinding { dataBinding {
enabled = true enabled = true
} }
dexOptions {
preDexLibraries = !ciBuild
}
} }


ribbonizer { ribbonizer {
Expand All @@ -56,7 +86,9 @@ ribbonizer {


play { play {
track = 'production' track = 'production'
jsonFile = file(System.getenv('HOME') + "/.android-mykey/filteredhatebu_play_api.json") if (!ciBuild) {
jsonFile = rootProject.file("filteredhatebu_play_api.json")
}
} }


dependencies { dependencies {
Expand Down Expand Up @@ -130,3 +162,28 @@ dependencies {
testCompile "org.robolectric:robolectric:3.1.2" testCompile "org.robolectric:robolectric:3.1.2"
testCompile 'org.mockito:mockito-core:1.10.19' testCompile 'org.mockito:mockito-core:1.10.19'
} }

/*
* On Travis-CI androidTest failed as java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
* at android.databinding.DataBindingUtil.<clinit>(DataBindingUtil.java:31)
*
* This is workaround for it.
*
* Workaround for https://code.google.com/p/android/issues/detail?id=182715
*
* The Android Gradle plugin is creating DataBindingExportBuildInfoTasks for the instrumentation
* APK that generates from the app APKs layouts. This creates duplicate classes in the app and
* instrumentation APK which leads to
* java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
* on older devices.
*
* The workaround is to get the DataBindingExportBuildInfoTasks tasks for the instrumentation APK
* and delete the files right after it creates them.
*/
tasks.withType(com.android.build.gradle.internal.tasks.databinding.DataBindingExportBuildInfoTask) { task ->
if (task.name.endsWith("AndroidTest")) {
task.finalizedBy(tasks.create("${task.name}Workaround") << {
task.output.deleteDir()
})
}
}
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public class HatebuFeedDetailActivityTest {
activityTestRule.launchActivity( activityTestRule.launchActivity(
HatebuFeedDetailActivity.createIntent(InstrumentationRegistry.getTargetContext(), HatebuFeedDetailActivity.createIntent(InstrumentationRegistry.getTargetContext(),
item)); item));
CommentLoadIdlingResource idlingResource = new CommentLoadIdlingResource(activityTestRule.getActivity());
CommentLoadIdlingResource idlingResource =
new CommentLoadIdlingResource(activityTestRule.getActivity());
Espresso.registerIdlingResources(idlingResource); Espresso.registerIdlingResources(idlingResource);


onView(allOf(withId(R.id.comment), onView(allOf(withId(R.id.comment),
Expand All @@ -60,7 +62,9 @@ public class HatebuFeedDetailActivityTest {
activityTestRule.launchActivity( activityTestRule.launchActivity(
HatebuFeedDetailActivity.createIntent(InstrumentationRegistry.getTargetContext(), HatebuFeedDetailActivity.createIntent(InstrumentationRegistry.getTargetContext(),
item)); item));
CommentLoadIdlingResource idlingResource = new CommentLoadIdlingResource(activityTestRule.getActivity());
CommentLoadIdlingResource idlingResource = new CommentLoadIdlingResource(
activityTestRule.getActivity());
Espresso.registerIdlingResources(idlingResource); Espresso.registerIdlingResources(idlingResource);


onView(withId(R.id.comment_status)) onView(withId(R.id.comment_status))
Expand All @@ -69,7 +73,7 @@ public class HatebuFeedDetailActivityTest {
} }


private static class CommentLoadIdlingResource implements IdlingResource { private static class CommentLoadIdlingResource implements IdlingResource {
private ResourceCallback callback; private ResourceCallback callback;
private HatebuFeedDetailActivity activity; private HatebuFeedDetailActivity activity;


public CommentLoadIdlingResource(HatebuFeedDetailActivity activity) { public CommentLoadIdlingResource(HatebuFeedDetailActivity activity) {
Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -1,7 +1,6 @@
package jp.gcreate.product.filteredhatebu.ui.feedlist; package jp.gcreate.product.filteredhatebu.ui.feedlist;




import android.content.Intent;
import android.support.test.espresso.Espresso; import android.support.test.espresso.Espresso;
import android.support.test.espresso.IdlingResource; import android.support.test.espresso.IdlingResource;
import android.support.test.espresso.ViewInteraction; import android.support.test.espresso.ViewInteraction;
Expand All @@ -24,32 +23,30 @@


import jp.gcreate.product.filteredhatebu.R; import jp.gcreate.product.filteredhatebu.R;


import static android.support.test.espresso.Espresso.onData;
import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.Espresso.pressBack; import static android.support.test.espresso.Espresso.pressBack;
import static android.support.test.espresso.action.ViewActions.click; import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.assertion.ViewAssertions.doesNotExist; import static android.support.test.espresso.assertion.ViewAssertions.doesNotExist;
import static android.support.test.espresso.assertion.ViewAssertions.matches; import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition; import static android.support.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withClassName;
import static android.support.test.espresso.matcher.ViewMatchers.withId; import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withParent;
import static android.support.test.espresso.matcher.ViewMatchers.withText; import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.anything;


@LargeTest @LargeTest
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
public class HatebuFeedActivityTest { public class HatebuFeedActivityTest {
private IdlingResource idlingResource; private IdlingResource idlingResource;


@Rule @Rule
public ActivityTestRule<HatebuFeedActivity> mActivityTestRule = new ActivityTestRule<>( public ActivityTestRule<HatebuFeedActivity> mActivityTestRule =
HatebuFeedActivity.class, false, false); new ActivityTestRule<>(HatebuFeedActivity.class);


@Before @Before
public void setUp() { public void setUp() {
mActivityTestRule.launchActivity(new Intent());
mActivityTestRule.getActivity().presenter.initialzieFilterRepository(); mActivityTestRule.getActivity().presenter.initialzieFilterRepository();
idlingResource = new ItemSetIdlingResource( mActivityTestRule.getActivity()); idlingResource = new ItemSetIdlingResource( mActivityTestRule.getActivity());
Espresso.registerIdlingResources(idlingResource); Espresso.registerIdlingResources(idlingResource);
Expand All @@ -63,23 +60,15 @@ public void tearDown() {


@Test @Test
public void フィルタを追加したら該当記事表示されない() { public void フィルタを追加したら該当記事表示されない() {
ViewInteraction recyclerView = onView( onView(allOf(withId(R.id.recycler_view), isDisplayed()))
allOf(withId(R.id.recycler_view), isDisplayed())); .perform(actionOnItemAtPosition(0, click()));
recyclerView.perform(actionOnItemAtPosition(0, click()));


ViewInteraction appCompatButton = onView( onView(withId(R.id.add_filter_button))
allOf(withId(R.id.add_filter_button), withText("フィルタを追加"), isDisplayed())); .perform(click());
appCompatButton.perform(click());


ViewInteraction appCompatTextView = onView( onData(anything())
allOf(withId(android.R.id.text1), withText("test.com/"), .atPosition(0)
childAtPosition( .perform(click());
allOf(withClassName(
is("com.android.internal.app.AlertController$RecycleListView")),
withParent(withClassName(is("android.widget.FrameLayout")))),
0),
isDisplayed()));
appCompatTextView.perform(click());


pressBack(); pressBack();


Expand All @@ -105,15 +94,9 @@ public void tearDown() {
allOf(withId(R.id.add_filter_button), withText("フィルタを追加"), isDisplayed())); allOf(withId(R.id.add_filter_button), withText("フィルタを追加"), isDisplayed()));
appCompatButton.perform(click()); appCompatButton.perform(click());


ViewInteraction appCompatTextView = onView( onData(anything())
allOf(withId(android.R.id.text1), withText("test.com/test/"), .atPosition(1)
childAtPosition( .perform(click());
allOf(withClassName(
is("com.android.internal.app.AlertController$RecycleListView")),
withParent(withClassName(is("android.widget.FrameLayout")))),
1),
isDisplayed()));
appCompatTextView.perform(click());


pressBack(); pressBack();


Expand Down Expand Up @@ -168,15 +151,10 @@ public void tearDown() {
isDisplayed())) isDisplayed()))
.perform(click()); .perform(click());


ViewInteraction appCompatTextView = onView( // test.comをフィルタに追加
allOf(withId(android.R.id.text1), withText("test.com/"), onData(anything())
childAtPosition( .atPosition(0)
allOf(withClassName( .perform(click());
is("com.android.internal.app.AlertController$RecycleListView")),
withParent(withClassName(is("android.widget.FrameLayout")))),
0),
isDisplayed()));
appCompatTextView.perform(click());


pressBack(); pressBack();


Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@


import org.junit.Test; import org.junit.Test;


import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;


import rx.Single; import rx.Single;
import rx.SingleSubscriber; import rx.SingleSubscriber;
import rx.Subscription; import rx.Subscription;
import rx.functions.Action1; import rx.functions.Action1;
import rx.observers.TestSubscriber;
import rx.schedulers.Schedulers; import rx.schedulers.Schedulers;


import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
Expand Down Expand Up @@ -66,14 +66,21 @@ public void call(String s) {


@Test @Test
public void onSuccessはunsubscribeされる() throws InterruptedException { public void onSuccessはunsubscribeされる() throws InterruptedException {
TestSubscriber<String> test = new TestSubscriber<>(); // this test is unstable on ci. This code is bad design.
final CountDownLatch latch = new CountDownLatch(1);
final String[] test = {""};
Subscription s = source Subscription s = source
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.subscribe(test); .subscribe(new Action1<String>() {
@Override
public void call(String s) {
test[0] = s;
latch.countDown();
}
});
assertThat(s.isUnsubscribed(), is(false)); assertThat(s.isUnsubscribed(), is(false));
test.awaitTerminalEvent(3, TimeUnit.SECONDS); latch.await(5, TimeUnit.SECONDS);
test.assertValue("test"); assertThat(test[0], is("test"));
test.onCompleted();
assertThat(s.isUnsubscribed(), is(true)); assertThat(s.isUnsubscribed(), is(true));
} }
} }
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@


import java.util.List; import java.util.List;


import jp.gcreate.product.filteredhatebu.ui.common.FilterGenerator;

import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;


Expand All @@ -16,7 +14,7 @@
*/ */
@RunWith(Enclosed.class) @RunWith(Enclosed.class)
public class FilterGeneratorTest { public class FilterGeneratorTest {
public static class フィルタ候補生成 { public static class GenerateCandidate {
@Test @Test
public void ホスト2つサブディレクトリあり() { public void ホスト2つサブディレクトリあり() {
List<String> actual = FilterGenerator List<String> actual = FilterGenerator
Expand Down Expand Up @@ -55,7 +53,7 @@ public static class フィルタ候補生成 {
} }




public static class ホスト部分 { public static class Host {
@Test @Test
public void ホスト2() { public void ホスト2() {
String actual = FilterGenerator.getHost("http://test.com/hoge/fuga"); String actual = FilterGenerator.getHost("http://test.com/hoge/fuga");
Expand All @@ -81,7 +79,7 @@ public void https() {
} }
} }


public static class サブドメインを除去 { public static class RemoveSubDomain {


@Test @Test
public void ホストが2つ() { public void ホストが2つ() {
Expand All @@ -108,7 +106,7 @@ public void https() {
} }
} }


public static class サブディレクトリ { public static class SubDirectory {
@Test @Test
public void サブディレクトリあり() { public void サブディレクトリあり() {
String actual = FilterGenerator.getHostAndSubDirectory("http://test.com/subuser/123"); String actual = FilterGenerator.getHostAndSubDirectory("http://test.com/subuser/123");
Expand All @@ -128,7 +126,7 @@ public void https() {
} }
} }


public static class サブドメインの除去メソッド { public static class MethodRemoveSubDomain {
@Test @Test
public void ホストが2つ() { public void ホストが2つ() {
String actual = FilterGenerator.removeSubDomain("test.com/"); String actual = FilterGenerator.removeSubDomain("test.com/");
Expand Down
Loading

0 comments on commit ec8906d

Please sign in to comment.