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

Commit

Permalink
chore: Revert WIP Commit, Fastlane PR Deploy Workflow (#567)
Browse files Browse the repository at this point in the history
Apply final deployment process from [instantsearch-android](https://github.com/algolia/instantsearch-android) to the client.
Reverts commit 89be9cb.
  • Loading branch information
PLNech authored Jan 22, 2019
1 parent 3380ae0 commit 1271069
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
}

// ----------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String, HostStatus> hostStatuses = (HashMap<String, HostStatus>) Whitebox.getInternalState(client, "hostStatuses");
for (Map.Entry<String, HostStatus> 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 {
Expand Down
35 changes: 22 additions & 13 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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()

Expand All @@ -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

Expand Down
4 changes: 3 additions & 1 deletion release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 1271069

Please sign in to comment.