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

Commit 1271069

Browse files
authored
chore: Revert WIP Commit, Fastlane PR Deploy Workflow (#567)
Apply final deployment process from [instantsearch-android](https://github.com/algolia/instantsearch-android) to the client. Reverts commit 89be9cb.
1 parent 3380ae0 commit 1271069

File tree

4 files changed

+28
-32
lines changed

4 files changed

+28
-32
lines changed

algoliasearch/src/main/java/com/algolia/search/saas/AbstractClient.java

+2-9
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
import java.lang.ref.WeakReference;
4646
import java.net.HttpURLConnection;
4747
import java.net.URL;
48-
import java.text.SimpleDateFormat;
4948
import java.util.ArrayList;
5049
import java.util.Arrays;
5150
import java.util.Date;
@@ -93,20 +92,14 @@ public int hashCode() {
9392
}
9493
}
9594

96-
static class HostStatus {
97-
boolean isUp;
95+
private static class HostStatus {
96+
boolean isUp = true;
9897
long lastTryTimestamp;
9998

10099
HostStatus(boolean isUp) {
101100
this.isUp = isUp;
102101
lastTryTimestamp = new Date().getTime();
103102
}
104-
105-
@Override
106-
public String toString() {
107-
return (isUp ? "up" : "down") + " at " + new SimpleDateFormat("HH:mm:ss.SSS")
108-
.format(new Date(lastTryTimestamp));
109-
}
110103
}
111104

112105
// ----------------------------------------------------------------------

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

+1-9
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
import java.util.Map;
4646
import java.util.UUID;
4747

48-
import static com.algolia.search.saas.AbstractClient.HostStatus;
4948
import static org.junit.Assert.assertEquals;
5049
import static org.junit.Assert.assertFalse;
5150
import static org.junit.Assert.assertNotEquals;
@@ -531,16 +530,9 @@ public void DNSTimeout() throws AssertionError {
531530
// Expect failed search after timeout
532531
final long startTime = System.nanoTime();
533532
index.searchAsync(new Query(), new AssertCompletionHandler() {
534-
@Override
535-
public void doRequestCompleted(JSONObject content, AlgoliaException error) {
533+
@Override public void doRequestCompleted(JSONObject content, AlgoliaException error) {
536534
if (error != null) {
537535
final long duration = (System.nanoTime() - startTime) / 1000000;
538-
System.err.println(error.getMessage());
539-
// Whitebox.getInternalState(client, "readHosts", hostsArray);
540-
HashMap<String, HostStatus> hostStatuses = (HashMap<String, HostStatus>) Whitebox.getInternalState(client, "hostStatuses");
541-
for (Map.Entry<String, HostStatus> entry : hostStatuses.entrySet()) {
542-
System.err.println(entry.getKey() + ": " + entry.getValue().toString());
543-
}
544536
assertTrue("We should hit 4 times the timeout before failing, but test took only " + duration + " ms.",
545537
duration > timeout * 4);
546538
} else {

fastlane/Fastfile

+22-13
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ platform :android do
1818
branch = options[:branch] || "master"
1919
notest = options[:notest] || false
2020
type = options[:type]
21-
UI.user_error!("You need to specify a type.") unless type != nil
22-
UI.user_error!("Type #{type} is not a valid type (patch/minor/major") unless ["major","minor","patch"].include? type
21+
type.nil? and UI.user_error!("You need to specify a type.")
22+
["major", "minor", "patch"].include? type or UI.user_error!("Type #{type} is not a valid type (patch/minor/major")
2323

2424
# Compute next version number
2525
current_version = get_version_name(
@@ -31,6 +31,9 @@ platform :android do
3131
puts "New version: #{version_number}"
3232

3333
# Ensure branch is master & WC clean, then pull changes
34+
if sh("git rev-parse origin/master") != sh("git rev-parse HEAD")
35+
raise "Error: master and HEAD hashes do not match, meaning that we are probably not on master and therefore can't deploy"
36+
end
3437
sh("git checkout ../Gemfile.lock") # Ignore different bundle version changing Gemfile https://discuss.bitrise.io/t/5176/5
3538
prepare_git()
3639

@@ -43,23 +46,29 @@ platform :android do
4346
file_edit("../CHANGELOG.md", /^(# Changelog\n+)/, "\\1\n#{changes}\n")
4447

4548
# Tests / deployment
46-
if notest == false
47-
test()
48-
end
49-
50-
masterHash = sh("git rev-parse origin/master")
51-
headHash = sh("git rev-parse HEAD")
52-
if masterHash != headHash
53-
raise "Error: master and HEAD hashes do not match, meaning that we are probably not on master and therefore can't deploy"
54-
end
49+
notest == false or test
5550

5651
# Release the new version
5752
sh("cd .. && ./release.sh #{version_number}")
58-
# Post the changes via GitHub Release API
59-
post_github_release(version_number, changes)
53+
6054
# Remove temporary version tags
6155
sh("git tag --delete minor major patch | true")
6256
sh("git push origin :refs/tag/patch :refs/tag/minor :refs/tag/major")
57+
58+
# Send PR
59+
pull_request_url = create_pull_request(
60+
api_token: ENV["GITHUB_TOKEN"],
61+
repo: "algolia/algoliasearch-client-android",
62+
title: "chore(release): Version #{version_number} [ci skip]",
63+
head: "version-#{version_number}",
64+
base: "master",
65+
body: "Please check the files before merging in case I've overidden something accidentally."
66+
)
67+
puts "PR opened: #{pull_request_url}"
68+
ENV["PR_URL"] = pull_request_url
69+
70+
# Post the changes via GitHub Release API
71+
post_github_release(version_number, changes)
6372
end
6473
end
6574

release.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ git checkout $SELF_ROOT/algoliasearch/build.gradle
9999

100100
# Commit to git and push to GitHub
101101
git add .
102+
git checkout -b version-$VERSION_CODE
102103
git commit -m "chore(release): Version $VERSION_CODE [ci skip]"
103104

104-
echo "Release complete! Pushing to GitHub"
105+
echo "Release complete! Pushing to GitHub on branch version-$VERSION_CODE"
105106
git push origin HEAD
107+
git checkout master

0 commit comments

Comments
 (0)