diff --git a/algoliasearch/src/main/java/com/algolia/search/saas/AbstractClient.java b/algoliasearch/src/main/java/com/algolia/search/saas/AbstractClient.java index 260b69dc..22d130b0 100644 --- a/algoliasearch/src/main/java/com/algolia/search/saas/AbstractClient.java +++ b/algoliasearch/src/main/java/com/algolia/search/saas/AbstractClient.java @@ -45,7 +45,6 @@ import java.lang.ref.WeakReference; import java.net.HttpURLConnection; import java.net.URL; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; @@ -93,20 +92,14 @@ public int hashCode() { } } - static class HostStatus { - boolean isUp; + private static class HostStatus { + boolean isUp = true; long lastTryTimestamp; HostStatus(boolean isUp) { this.isUp = isUp; lastTryTimestamp = new Date().getTime(); } - - @Override - public String toString() { - return (isUp ? "up" : "down") + " at " + new SimpleDateFormat("HH:mm:ss.SSS") - .format(new Date(lastTryTimestamp)); - } } // ---------------------------------------------------------------------- diff --git a/algoliasearch/src/test/java/com/algolia/search/saas/IndexTest.java b/algoliasearch/src/test/java/com/algolia/search/saas/IndexTest.java index 82ff950a..4d6b16cd 100644 --- a/algoliasearch/src/test/java/com/algolia/search/saas/IndexTest.java +++ b/algoliasearch/src/test/java/com/algolia/search/saas/IndexTest.java @@ -45,7 +45,6 @@ import java.util.Map; import java.util.UUID; -import static com.algolia.search.saas.AbstractClient.HostStatus; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; @@ -531,16 +530,9 @@ public void DNSTimeout() throws AssertionError { // Expect failed search after timeout final long startTime = System.nanoTime(); index.searchAsync(new Query(), new AssertCompletionHandler() { - @Override - public void doRequestCompleted(JSONObject content, AlgoliaException error) { + @Override public void doRequestCompleted(JSONObject content, AlgoliaException error) { if (error != null) { final long duration = (System.nanoTime() - startTime) / 1000000; - System.err.println(error.getMessage()); -// Whitebox.getInternalState(client, "readHosts", hostsArray); - HashMap hostStatuses = (HashMap) Whitebox.getInternalState(client, "hostStatuses"); - for (Map.Entry entry : hostStatuses.entrySet()) { - System.err.println(entry.getKey() + ": " + entry.getValue().toString()); - } assertTrue("We should hit 4 times the timeout before failing, but test took only " + duration + " ms.", duration > timeout * 4); } else { diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 61afef05..f726617d 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -18,8 +18,8 @@ platform :android do branch = options[:branch] || "master" notest = options[:notest] || false type = options[:type] - UI.user_error!("You need to specify a type.") unless type != nil - UI.user_error!("Type #{type} is not a valid type (patch/minor/major") unless ["major","minor","patch"].include? type + type.nil? and UI.user_error!("You need to specify a type.") + ["major", "minor", "patch"].include? type or UI.user_error!("Type #{type} is not a valid type (patch/minor/major") # Compute next version number current_version = get_version_name( @@ -31,6 +31,9 @@ platform :android do puts "New version: #{version_number}" # Ensure branch is master & WC clean, then pull changes + if sh("git rev-parse origin/master") != sh("git rev-parse HEAD") + raise "Error: master and HEAD hashes do not match, meaning that we are probably not on master and therefore can't deploy" + end sh("git checkout ../Gemfile.lock") # Ignore different bundle version changing Gemfile https://discuss.bitrise.io/t/5176/5 prepare_git() @@ -43,23 +46,29 @@ platform :android do file_edit("../CHANGELOG.md", /^(# Changelog\n+)/, "\\1\n#{changes}\n") # Tests / deployment - if notest == false - test() - end - - masterHash = sh("git rev-parse origin/master") - headHash = sh("git rev-parse HEAD") - if masterHash != headHash - raise "Error: master and HEAD hashes do not match, meaning that we are probably not on master and therefore can't deploy" - end + notest == false or test # Release the new version sh("cd .. && ./release.sh #{version_number}") - # Post the changes via GitHub Release API - post_github_release(version_number, changes) + # Remove temporary version tags sh("git tag --delete minor major patch | true") sh("git push origin :refs/tag/patch :refs/tag/minor :refs/tag/major") + + # Send PR + pull_request_url = create_pull_request( + api_token: ENV["GITHUB_TOKEN"], + repo: "algolia/algoliasearch-client-android", + title: "chore(release): Version #{version_number} [ci skip]", + head: "version-#{version_number}", + base: "master", + body: "Please check the files before merging in case I've overidden something accidentally." + ) + puts "PR opened: #{pull_request_url}" + ENV["PR_URL"] = pull_request_url + + # Post the changes via GitHub Release API + post_github_release(version_number, changes) end end diff --git a/release.sh b/release.sh index bd2a22fc..914e7560 100755 --- a/release.sh +++ b/release.sh @@ -99,7 +99,9 @@ git checkout $SELF_ROOT/algoliasearch/build.gradle # Commit to git and push to GitHub git add . +git checkout -b version-$VERSION_CODE git commit -m "chore(release): Version $VERSION_CODE [ci skip]" -echo "Release complete! Pushing to GitHub" +echo "Release complete! Pushing to GitHub on branch version-$VERSION_CODE" git push origin HEAD +git checkout master \ No newline at end of file