Skip to content
This repository was archived by the owner on Jan 31, 2022. It is now read-only.

Commit ffea1f6

Browse files
authored
Fastlane light implementation (#460)
chore(fastlane): Move the deployment to fastlane. Still using additional *.sh scripts for deployment
1 parent e081acd commit ffea1f6

File tree

7 files changed

+64
-14
lines changed

7 files changed

+64
-14
lines changed

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,16 @@ proguard/
4343
# Temporary files
4444
*.bak
4545
*.tmp
46+
47+
# fastlane specific
48+
fastlane/report.xml
49+
50+
# deliver temporary files
51+
fastlane/Preview.html
52+
53+
# snapshot generated screenshots
54+
fastlane/screenshots
55+
56+
# scan temporary files
57+
fastlane/test_output/
58+
fastlane/README.md

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ cache:
4040
- $HOME/.gradle/daemon
4141
- $HOME/.gradle/native
4242
- $HOME/.gradle/wrapper
43+
install: true
4344
before_script:
4445
# Avoid useless reupload of cache after every build, see https://docs.travis-ci.com/user/languages/android
4546
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
@@ -49,6 +50,7 @@ before_script:
4950
- emulator -avd test -no-skin -no-window &
5051
- android-wait-for-emulator
5152
- adb shell input keyevent 82 &
53+
5254
script:
5355
- set -o pipefail
5456
- travis_wait bash run_test.sh

algoliasearch/common.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ android {
4141
versionName PUBLISH_VERSION
4242
}
4343
buildTypes {
44+
all {
45+
buildConfigField "String", "ALGOLIA_APPLICATION_ID", "\"$System.env.ALGOLIA_APPLICATION_ID\""
46+
buildConfigField "String", "ALGOLIA_API_KEY", "\"$System.env.ALGOLIA_API_KEY\""
47+
buildConfigField "String", "PLACES_APPLICATION_ID", "\"$System.env.PLACES_APPLICATION_ID\""
48+
buildConfigField "String", "PLACES_API_KEY", "\"$System.env.PLACES_API_KEY\""
49+
}
4450
release {
4551
minifyEnabled false
4652
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
@@ -170,6 +176,13 @@ task testUploadArchives(type: Upload) {
170176
}
171177
}
172178

179+
// Logging the tests
180+
tasks.withType(Test) {
181+
testLogging {
182+
events "started", "passed", "skipped", "failed"
183+
}
184+
}
185+
173186
// Edit the Maven POM.
174187
//
175188
// NOTE: This function is meant to factorize POM generation between the built-in `uploadArchives` and the custom

algoliasearch/src/test/java/com/algolia/search/saas/Helpers.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@
2525

2626
import android.support.annotation.NonNull;
2727
import java.util.Arrays;
28+
import com.algolia.search.saas.android.BuildConfig;
29+
import java.util.UUID;
2830

2931
public class Helpers {
30-
public static String app_id = "%ALGOLIA_APPLICATION_ID%";
31-
public static String api_key = "%ALGOLIA_API_KEY%";
32-
public static String PLACES_APP_ID = "%PLACES_APPLICATION_ID%";
33-
public static String PLACES_API_KEY = "%PLACES_API_KEY%";
34-
public static String job_number = "%JOB_NUMBER%";
32+
public static String app_id = BuildConfig.ALGOLIA_APPLICATION_ID;
33+
public static String api_key = BuildConfig.ALGOLIA_API_KEY;
34+
public static String PLACES_APP_ID = BuildConfig.PLACES_APPLICATION_ID;
35+
public static String PLACES_API_KEY = BuildConfig.PLACES_API_KEY;
3536

3637
public static int wait = 30;
3738

@@ -43,10 +44,7 @@ static String getLongApiKey() {
4344
}
4445

4546
static String safeIndexName(String name) {
46-
if (job_number.matches("\\d+\\.\\d+")) {
47-
name = String.format("%s_travis-%s", name, job_number);
48-
}
49-
return name;
47+
return name + UUID.randomUUID();
5048
}
5149

5250
/**

fastlane/Appfile

Whitespace-only changes.

fastlane/Fastfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
actions_path 'actions/'
3+
fastlane_version "2.61.0"
4+
default_platform :android
5+
6+
platform :android do
7+
desc "Runs all the tests"
8+
lane :test do
9+
gradle(
10+
task: "test",
11+
build_type: "Release"
12+
)
13+
end
14+
15+
#desc "Deploy the library. Available options: type:major|minor|patch optional: branch:YOUR_BRANCH notest:true|false (default false)"
16+
desc "Deploy the library. Available options: optional: branch:YOUR_BRANCH (default master)"
17+
lane :deploy do |options|
18+
branch = options[:branch] || "master"
19+
prepare_git(branch)
20+
sh("./release.sh")
21+
end
22+
23+
end
24+
25+
def prepare_git(branch)
26+
ensure_git_status_clean
27+
ensure_git_branch(branch:branch)
28+
git_pull
29+
end

run_test.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
set -e
44
set -o pipefail
55

6-
FILE=algoliasearch/src/test/java/com/algolia/search/saas/Helpers.java
7-
export FILE
8-
96
my_travis_retry() {
107
local result=0
118
local count=1
@@ -43,6 +40,4 @@ if ! [[ $TRAVIS_JOB_NUMBER && ${TRAVIS_JOB_NUMBER-_} ]]; then
4340
fi
4441

4542
echo "Running Android test..."
46-
./setup_tests.sh
4743
$RETRY ./gradlew testRelease
48-
./teardown_tests.sh

0 commit comments

Comments
 (0)