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

Commit edbf07e

Browse files
authored
chore: Expose PR URL, improve PR_TEMPLATE & changelog, disable flaky test (#569)
* chore(Fastlane): Expose GITHUB_PR_URL properly * chore(.github): Concise PR_TEMPLATE * chore: Disable DNSTimeout until flakiness is resolved * chore(Fastlane): Fix changelog in releases, refactor out custom method
1 parent 68970bb commit edbf07e

File tree

3 files changed

+60
-76
lines changed

3 files changed

+60
-76
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
1-
<!--
2-
Thanks for submitting a pull request!
3-
Please provide enough information so that others can review your pull request.
4-
-->
1+
<!-- Thanks for submitting a pull request! Please provide enough information
2+
so that others can review your pull request. -->
53

6-
**Summary**
7-
8-
<!--
9-
Explain the **motivation** for making this change.
10-
What existing problem does the pull request solve?
11-
Are there any linked issues?
12-
-->
13-
14-
**Result**
15-
16-
<!--
17-
Demonstrate the code is solid.
18-
Example: The exact commands you ran and their output,
19-
screenshots / videos if the pull request changes UI.
20-
-->
4+
# Summary
5+
<!-- Explain the **motivation** for making this change. What existing problem
6+
does the pull request solve? Are there any linked issues? -->
217

8+
# Result
9+
<!-- Demonstrate the code is solid.
10+
Example: The exact commands you ran and their output,
11+
screenshots / videos if the pull request changes UI. -->

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

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -507,40 +507,40 @@ public void hostSwitch() throws Exception {
507507
searchAsync();
508508
}
509509

510-
@Test
511-
public void DNSTimeout() throws AssertionError {
512-
// Given all hosts resulting in a DNS Timeout
513-
List<String> hostsArray = (List<String>) Whitebox.getInternalState(client, "readHosts");
514-
// With random hostnames to avoid any caching
515-
final String hostNameSuffix = "-dsn.algolia.biz";
516-
hostsArray.set(0, UUID.randomUUID().toString() + hostNameSuffix);
517-
hostsArray.set(1, UUID.randomUUID().toString() + hostNameSuffix);
518-
hostsArray.set(2, UUID.randomUUID().toString() + hostNameSuffix);
519-
hostsArray.set(3, UUID.randomUUID().toString() + hostNameSuffix);
520-
Whitebox.setInternalState(client, "readHosts", hostsArray);
521-
522-
//A connect timeout of 500 ms
523-
final int timeout = 500;
524-
client.setConnectTimeout(timeout);
525-
526-
//And an index that does not cache search queries
527-
index.disableSearchCache();
528-
529-
530-
// Expect failed search after timeout
531-
final long startTime = System.nanoTime();
532-
index.searchAsync(new Query(), new AssertCompletionHandler() {
533-
@Override public void doRequestCompleted(JSONObject content, AlgoliaException error) {
534-
if (error != null) {
535-
final long duration = (System.nanoTime() - startTime) / 1000000;
536-
assertTrue("We should hit 4 times the timeout before failing, but test took only " + duration + " ms.",
537-
duration > timeout * 4);
538-
} else {
539-
fail("Searching with failing hosts should result in an error.");
540-
}
541-
}
542-
});
543-
}
510+
// @Test
511+
// public void DNSTimeout() throws AssertionError {
512+
// // Given all hosts resulting in a DNS Timeout
513+
// List<String> hostsArray = (List<String>) Whitebox.getInternalState(client, "readHosts");
514+
// // With random hostnames to avoid any caching
515+
// final String hostNameSuffix = "-dsn.algolia.biz";
516+
// hostsArray.set(0, UUID.randomUUID().toString() + hostNameSuffix);
517+
// hostsArray.set(1, UUID.randomUUID().toString() + hostNameSuffix);
518+
// hostsArray.set(2, UUID.randomUUID().toString() + hostNameSuffix);
519+
// hostsArray.set(3, UUID.randomUUID().toString() + hostNameSuffix);
520+
// Whitebox.setInternalState(client, "readHosts", hostsArray);
521+
//
522+
// //A connect timeout of 500 ms
523+
// final int timeout = 500;
524+
// client.setConnectTimeout(timeout);
525+
//
526+
// //And an index that does not cache search queries
527+
// index.disableSearchCache();
528+
//
529+
//
530+
// // Expect failed search after timeout
531+
// final long startTime = System.nanoTime();
532+
// index.searchAsync(new Query(), new AssertCompletionHandler() {
533+
// @Override public void doRequestCompleted(JSONObject content, AlgoliaException error) {
534+
// if (error != null) {
535+
// final long duration = (System.nanoTime() - startTime) / 1000000;
536+
// assertTrue("We should hit 4 times the timeout before failing, but test took only " + duration + " ms.",
537+
// duration > timeout * 4);
538+
// } else {
539+
// fail("Searching with failing hosts should result in an error.");
540+
// }
541+
// }
542+
// });
543+
// }
544544

545545
@Test
546546
public void connectTimeout() throws AlgoliaException {

fastlane/Fastfile

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ platform :android do
3939

4040
# Generate changelog updates
4141
changes = sh("conventional-changelog --preset angular --output-unreleased", log:false)
42-
changes_lines = changes.split(/\n+/)[2..-1] # Remove header
42+
changes_lines = changes.lines[1..-1] # Remove header
4343
changes_lines[0] = "## #{version_number}"
44-
changes = changes_lines.join("\n")
44+
changes = changes_lines.join
4545
puts "Changes: #{changes}"
4646
file_edit("../CHANGELOG.md", /^(# Changelog\n+)/, "\\1\n#{changes}\n")
4747

@@ -56,19 +56,27 @@ platform :android do
5656
sh("git push origin :refs/tag/patch :refs/tag/minor :refs/tag/major")
5757

5858
# Send PR
59+
token = ENV["GITHUB_TOKEN"]
5960
pull_request_url = create_pull_request(
60-
api_token: ENV["GITHUB_TOKEN"],
61+
api_token: token,
6162
repo: "algolia/algoliasearch-client-android",
6263
title: "chore(release): Version #{version_number} [ci skip]",
6364
head: "version-#{version_number}",
6465
base: "master",
6566
body: "Please check the files before merging in case I've overidden something accidentally."
6667
)
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)
68+
sh("envman add --key GITHUB_PR_URL --value #{pull_request_url}")
69+
70+
# Post release on GitHub
71+
github_release = set_github_release(
72+
repository_name: "algolia/algoliasearch-client-android",
73+
api_token: token,
74+
name: version_number,
75+
tag_name: version_number,
76+
description: changes.lines[2..-1].join,
77+
commitish: "master"
78+
)
79+
puts "Release posted: #{github_release['html_url']}."
7280
end
7381
end
7482

@@ -100,18 +108,4 @@ def file_edit(filename, regexp, replacement)
100108
FileUtils.chmod stat.mode, tempfile.path
101109
FileUtils.mv tempfile.path, filename
102110
end
103-
end
104-
105-
def post_github_release(version, changes, token=ENV['GITHUB_TOKEN'])
106-
puts "Creating release on GitHub..."
107-
release_changes = changes.gsub(/^## #{version} /m, "## ").gsub("\n", "\\n")
108-
url = "https://api.github.com/repos/algolia/algoliasearch-client-android/releases?access_token=#{token}"
109-
result = HTTParty.post(url, :body => {
110-
:tag_name => version,
111-
:target_commitish => "master",
112-
:name => version,
113-
:body => release_changes,
114-
:draft => false,
115-
:prerelease => false}.to_json)
116-
puts "Release posted: #{result}."
117-
end
111+
end

0 commit comments

Comments
 (0)