Skip to content

Commit 770b579

Browse files
authored
Ignore github example integration tests when building PR (OpenFeign#1094)
1 parent 2dbe24a commit 770b579

File tree

2 files changed

+45
-12
lines changed

2 files changed

+45
-12
lines changed

example-github/pom.xml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@
9292
<groupId>org.apache.maven.plugins</groupId>
9393
<artifactId>maven-failsafe-plugin</artifactId>
9494
<version>${maven-surefire-plugin.version}</version>
95+
<configuration>
96+
<!--
97+
Travis does not inject GITHUB_TOKEN when building PRs, which will make module fail
98+
https://docs.travis-ci.com/user/environment-variables/#defining-encrypted-variables-in-travisyml
99+
100+
ignoring test errors for any build that is not master
101+
-->
102+
<testFailureIgnore>true</testFailureIgnore>
103+
</configuration>
95104
<executions>
96105
<execution>
97106
<goals>
@@ -103,4 +112,26 @@
103112
</plugin>
104113
</plugins>
105114
</build>
115+
116+
<profiles>
117+
<profile>
118+
<activation>
119+
<property>
120+
<name>env.TRAVIS_PULL_REQUEST</name>
121+
<value>false</value>
122+
</property>
123+
</activation>
124+
<build>
125+
<plugins>
126+
<plugin>
127+
<groupId>org.apache.maven.plugins</groupId>
128+
<artifactId>maven-failsafe-plugin</artifactId>
129+
<configuration>
130+
<testFailureIgnore>false</testFailureIgnore>
131+
</configuration>
132+
</plugin>
133+
</plugins>
134+
</build>
135+
</profile>
136+
</profiles>
106137
</project>

example-github/src/main/java/example/github/GitHubExample.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
*/
1414
package example.github;
1515

16+
import java.io.IOException;
17+
import java.util.List;
18+
import java.util.stream.Collectors;
1619
import feign.*;
1720
import feign.codec.Decoder;
1821
import feign.codec.Encoder;
1922
import feign.codec.ErrorDecoder;
2023
import feign.gson.GsonDecoder;
2124
import feign.gson.GsonEncoder;
22-
import java.io.IOException;
23-
import java.util.List;
24-
import java.util.stream.Collectors;
2525

2626
/**
2727
* Inspired by {@code com.example.retrofit.GitHubClient}
@@ -72,8 +72,8 @@ default List<String> contributors(String owner) {
7272
}
7373

7474
static GitHub connect() {
75-
Decoder decoder = new GsonDecoder();
76-
Encoder encoder = new GsonEncoder();
75+
final Decoder decoder = new GsonDecoder();
76+
final Encoder encoder = new GsonEncoder();
7777
return Feign.builder()
7878
.encoder(encoder)
7979
.decoder(decoder)
@@ -84,6 +84,8 @@ static GitHub connect() {
8484
if (System.getenv().containsKey(GITHUB_TOKEN)) {
8585
System.out.println("Detected Authorization token from environment variable");
8686
template.header(
87+
// not available when building PRs...
88+
// https://docs.travis-ci.com/user/environment-variables/#defining-encrypted-variables-in-travisyml
8789
"Authorization",
8890
"token " + System.getenv(GITHUB_TOKEN));
8991
}
@@ -103,28 +105,28 @@ public String getMessage() {
103105
}
104106

105107
public static void main(String... args) {
106-
GitHub github = GitHub.connect();
108+
final GitHub github = GitHub.connect();
107109

108110
System.out.println("Let's fetch and print a list of the contributors to this org.");
109-
List<String> contributors = github.contributors("openfeign");
110-
for (String contributor : contributors) {
111+
final List<String> contributors = github.contributors("openfeign");
112+
for (final String contributor : contributors) {
111113
System.out.println(contributor);
112114
}
113115

114116
System.out.println("Now, let's cause an error.");
115117
try {
116118
github.contributors("openfeign", "some-unknown-project");
117-
} catch (GitHubClientError e) {
119+
} catch (final GitHubClientError e) {
118120
System.out.println(e.getMessage());
119121
}
120122

121123
System.out.println("Now, try to create an issue - which will also cause an error.");
122124
try {
123-
GitHub.Issue issue = new GitHub.Issue();
125+
final GitHub.Issue issue = new GitHub.Issue();
124126
issue.title = "The title";
125127
issue.body = "Some Text";
126128
github.createIssue(issue, "OpenFeign", "SomeRepo");
127-
} catch (GitHubClientError e) {
129+
} catch (final GitHubClientError e) {
128130
System.out.println(e.getMessage());
129131
}
130132
}
@@ -144,7 +146,7 @@ public Exception decode(String methodKey, Response response) {
144146
// must replace status by 200 other GSONDecoder returns null
145147
response = response.toBuilder().status(200).build();
146148
return (Exception) decoder.decode(response, GitHubClientError.class);
147-
} catch (IOException fallbackToDefault) {
149+
} catch (final IOException fallbackToDefault) {
148150
return defaultDecoder.decode(methodKey, response);
149151
}
150152
}

0 commit comments

Comments
 (0)