Skip to content

Commit 15f7483

Browse files
committed
Merge remote-tracking branch 'upstream/master' into bugfix-883
2 parents 68ef40e + b30d648 commit 15f7483

File tree

152 files changed

+3530
-730
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+3530
-730
lines changed

CONTRIBUTING.md

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ Example:
1414

1515
This the default behavior.
1616

17+
Example for a single test case:
18+
19+
`mvn install -Dtest=WireMockStatusReporterTest#user_whenProxying_AuthCorrectlyConfigured`
20+
1721

1822
### Setting up credential
1923

@@ -27,21 +31,37 @@ This the default behavior.
2731

2832
`WireMockStatusReporterTest: GitHub proxying and user auth correctly configured for user login: <your login>`
2933

30-
Whenever you run tests with `-Dtest.github.useProxy`, they will try to get data from local files but will fallback to proxying to github if not found.
31-
34+
Whenever you run tests with `-Dtest.github.useProxy`, they will try to get data from local files but will fallback to proxying to GitHub if not found.
3235

3336
### Writing a new test
3437

3538
Once you have credentials setup, you add new test classes and test methods as you would normally.
36-
Keep `useProxy` enabled and iterate on your tests as needed. Remember, while proxying your tests are interacting with GitHub - you will need to clean up your state between runs.
3739

38-
When you are ready to create a snapshot of your test data,
39-
run your test with `test.github.takeSnapshot` ("-Dtest.github.takeSnapshot" as a Java VM option). For example:
40+
#### Running tests using GitHub test proxy
41+
42+
Keep `useProxy` enabled and iterate on your tests as needed. With `useProxy` enabled your tests will interact with
43+
GitHub - you will need to clean up your server-state between runs. This can be done manually to start with.
44+
Once your test code is somewhat stable, use `getGitHubBeforeAfter()` to get a `GitHub` instance for test setup and cleanup.
45+
Interactions with that `GitHub` instance will not be recorded as part of the test, keeping the test data files to a minimum.
46+
47+
#### Running tests against your personal GitHub user account
48+
49+
By default, test helper methods such as `getTempRepository()` target the `hub4j-test-org` GitHub organization.
50+
Please request access to this org to record your tests before submitting a PR. This helps keep the project stable and nimble.
51+
Until you have access (or if you don't want access), you can set the following additional system property to target
52+
your personal github account.
53+
54+
`mvn install -Dtest.github.org=false -Dtest=YourTestClassName`
55+
56+
#### Taking a snapshot
57+
58+
When you are ready to create a snapshot of your test data, run your test with `test.github.takeSnapshot` ("-Dtest.github.takeSnapshot" as
59+
a Java VM option). For example:
4060

41-
`mvn install -Dtest.github.takeSnapshot -Dtest=YourTestClassName`
61+
`mvn install -Dtest.github.takeSnapshot -Dtest.github.org=false -Dtest=YourTestClassName`
4262

43-
The above command would create snapshot WireMock data files under the path `src/test/resources/org/kohsuhke/github/YourTestClassName/wiremock`.
44-
Each method would get a separate director that would hold the data files for that test method.
63+
The above command will create snapshot WireMock data files under the path `src/test/resources/org/kohsuhke/github/YourTestClassName/wiremock`.
64+
Each method will get a separate directory that will hold the data files for that test method.
4565

4666
Add all files including the generated data to your commit and submit a PR.
4767

pom.xml

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,13 @@
3333

3434
<properties>
3535
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
36-
<spotbugs-maven-plugin.version>4.0.4</spotbugs-maven-plugin.version>
37-
<spotbugs.version>4.1.2</spotbugs.version>
36+
<spotbugs-maven-plugin.version>4.1.4</spotbugs-maven-plugin.version>
37+
<spotbugs.version>4.1.3</spotbugs.version>
3838
<spotbugs-maven-plugin.failOnError>true</spotbugs-maven-plugin.failOnError>
3939
<hamcrest.version>2.2</hamcrest.version>
4040
<okhttp3.version>4.4.1</okhttp3.version>
4141
<okio.version>2.5.0</okio.version>
42-
<formatter-maven-plugin.goal>format</formatter-maven-plugin.goal>
43-
<impsort-maven-plugin.goal>sort</impsort-maven-plugin.goal>
42+
<spotless-maven-plugin.goal>apply</spotless-maven-plugin.goal>
4443
<!-- Using this as the minimum bar for code coverage. Adding methods without covering them will fail this. -->
4544
<jacoco.coverage.target.bundle.method>0.60</jacoco.coverage.target.bundle.method>
4645
<jacoco.coverage.target.class.method>0.25</jacoco.coverage.target.class.method>
@@ -261,7 +260,7 @@
261260
<plugin>
262261
<groupId>org.apache.maven.plugins</groupId>
263262
<artifactId>maven-project-info-reports-plugin</artifactId>
264-
<version>3.1.0</version>
263+
<version>3.1.1</version>
265264
<dependencies>
266265
<dependency>
267266
<groupId>org.apache.bcel</groupId>
@@ -343,37 +342,34 @@
343342
</executions>
344343
</plugin>
345344
<plugin>
346-
<groupId>net.revelc.code.formatter</groupId>
347-
<artifactId>formatter-maven-plugin</artifactId>
348-
<version>2.12.1</version>
345+
<groupId>com.diffplug.spotless</groupId>
346+
<artifactId>spotless-maven-plugin</artifactId>
347+
<version>2.6.1</version>
349348
<executions>
350349
<execution>
350+
<id>spotless-check</id>
351+
<phase>process-sources</phase>
351352
<goals>
352-
<goal>${formatter-maven-plugin.goal}</goal>
353+
<goal>${spotless-maven-plugin.goal}</goal>
353354
</goals>
354-
<configuration>
355-
<configFile>src/main/resources/eclipse/formatter.xml</configFile>
356-
<cachedir>${project.build.directory}/.cache</cachedir>
357-
</configuration>
358355
</execution>
359356
</executions>
360-
</plugin>
361-
<plugin>
362-
<groupId>net.revelc.code</groupId>
363-
<artifactId>impsort-maven-plugin</artifactId>
364-
<version>1.4.1</version>
365357
<configuration>
366-
<groups>*,java.,javax.</groups>
367-
<removeUnused>true</removeUnused>
368-
<staticAfter>true</staticAfter>
358+
<java>
359+
<eclipse>
360+
<file>${basedir}/src/build/eclipse/formatter.xml</file>
361+
</eclipse>
362+
363+
<importOrder>
364+
<file>${basedir}/src/build/eclipse/eclipse.importorder</file>
365+
</importOrder>
366+
<removeUnusedImports />
367+
368+
<trimTrailingWhitespace />
369+
<endWithNewline />
370+
371+
</java>
369372
</configuration>
370-
<executions>
371-
<execution>
372-
<goals>
373-
<goal>${impsort-maven-plugin.goal}</goal>
374-
</goals>
375-
</execution>
376-
</executions>
377373
</plugin>
378374
<plugin>
379375
<groupId>com.github.spotbugs</groupId>
@@ -410,6 +406,12 @@
410406
<artifactId>commons-lang3</artifactId>
411407
<version>3.9</version>
412408
</dependency>
409+
<dependency>
410+
<groupId>com.tngtech.archunit</groupId>
411+
<artifactId>archunit</artifactId>
412+
<version>0.15.0</version>
413+
<scope>test</scope>
414+
</dependency>
413415
<dependency>
414416
<groupId>org.hamcrest</groupId>
415417
<artifactId>hamcrest</artifactId>
@@ -481,7 +483,7 @@
481483
<dependency>
482484
<groupId>org.eclipse.jgit</groupId>
483485
<artifactId>org.eclipse.jgit</artifactId>
484-
<version>5.9.0.202009080501-r</version>
486+
<version>5.10.0.202012080955-r</version>
485487
<scope>test</scope>
486488
</dependency>
487489
<dependency>
@@ -561,7 +563,7 @@
561563
<dependency>
562564
<groupId>org.slf4j</groupId>
563565
<artifactId>slf4j-simple</artifactId>
564-
<version>1.7.2</version>
566+
<version>1.7.30</version>
565567
<scope>test</scope>
566568
</dependency>
567569
</dependencies>
@@ -589,8 +591,7 @@
589591
</os>
590592
</activation>
591593
<properties>
592-
<formatter-maven-plugin.goal>validate</formatter-maven-plugin.goal>
593-
<impsort-maven-plugin.goal>check</impsort-maven-plugin.goal>
594+
<spotless-maven-plugin.goal>check</spotless-maven-plugin.goal>
594595
</properties>
595596
</profile>
596597
<profile>
@@ -615,8 +616,7 @@
615616
<profile>
616617
<id>release</id>
617618
<properties>
618-
<formatter-maven-plugin.goal>validate</formatter-maven-plugin.goal>
619-
<impsort-maven-plugin.goal>check</impsort-maven-plugin.goal>
619+
<spotless-maven-plugin.goal>check</spotless-maven-plugin.goal>
620620
</properties>
621621
<build>
622622
<plugins>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Organize Import Order
2+
# Import this file in Window -> Preferences -> Java -> Code Style -> Organize Imports -> Import...
3+
0=
4+
1=java
5+
2=javax
6+
3=\#
File renamed without changes.

src/main/java/org/kohsuke/github/AbstractBuilder.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
* <p>
1313
* Batching looks like this:
1414
* </p>
15-
*
15+
*
1616
* <pre>
1717
* update().someName(value).otherName(value).done()
1818
* </pre>
1919
* <p>
2020
* Single changes look like this:
2121
* </p>
22-
*
22+
*
2323
* <pre>
2424
* set().someName(value);
2525
* set().otherName(value);
@@ -38,7 +38,7 @@
3838
* Intermediate return type for this builder returned by calls to {@link #with(String, Object)}. If {@link S}
3939
* the same as {@link R}, this builder will commit changes after each call to {@link #with(String, Object)}.
4040
*/
41-
abstract class AbstractBuilder<R, S> {
41+
abstract class AbstractBuilder<R, S> extends GitHubInteractiveObject {
4242

4343
@Nonnull
4444
private final Class<R> returnType;
@@ -75,6 +75,7 @@ protected AbstractBuilder(@Nonnull Class<R> finalReturnType,
7575
@Nonnull Class<S> intermediateReturnType,
7676
@Nonnull GitHub root,
7777
@CheckForNull R baseInstance) {
78+
super(root);
7879
this.requester = root.createRequest();
7980
this.returnType = finalReturnType;
8081
this.commitChangesImmediately = returnType.equals(intermediateReturnType);
@@ -97,7 +98,7 @@ protected AbstractBuilder(@Nonnull Class<R> finalReturnType,
9798
* if there is an I/O Exception
9899
*/
99100
@Nonnull
100-
@Preview
101+
@BetaApi
101102
@Deprecated
102103
public R done() throws IOException {
103104
R result;
@@ -127,7 +128,7 @@ public R done() throws IOException {
127128
* if an I/O error occurs
128129
*/
129130
@Nonnull
130-
@Preview
131+
@BetaApi
131132
@Deprecated
132133
protected S with(@Nonnull String name, Object value) throws IOException {
133134
requester.with(name, value);
@@ -148,7 +149,7 @@ protected S with(@Nonnull String name, Object value) throws IOException {
148149
* if an I/O error occurs
149150
*/
150151
@Nonnull
151-
@Preview
152+
@BetaApi
152153
@Deprecated
153154
protected S continueOrDone() throws IOException {
154155
// This little bit of roughness in this base class means all inheriting builders get to create Updater and
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package org.kohsuke.github;
2+
3+
import java.lang.annotation.Documented;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.RetentionPolicy;
6+
7+
/**
8+
* Indicates that the method/class/etc marked is a beta implementation of an sdk feature.
9+
* <p>
10+
* These APIs are subject to change and not a part of the backward compatibility commitment. Always used in conjunction
11+
* with 'deprecated' to raise awareness to clients.
12+
* </p>
13+
*
14+
*/
15+
@Retention(RetentionPolicy.RUNTIME)
16+
@Documented
17+
public @interface BetaApi {
18+
}

src/main/java/org/kohsuke/github/GHApp.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
public class GHApp extends GHObject {
1717

18-
private GitHub root;
1918
private GHUser owner;
2019
private String name;
2120
private String description;
@@ -189,7 +188,7 @@ GHApp wrapUp(GitHub root) {
189188
* @return a list of App installations
190189
* @see <a href="https://developer.github.com/v3/apps/#list-installations">List installations</a>
191190
*/
192-
@Preview
191+
@Preview(MACHINE_MAN)
193192
@Deprecated
194193
public PagedIterable<GHAppInstallation> listInstallations() {
195194
return root.createRequest()
@@ -210,7 +209,7 @@ public PagedIterable<GHAppInstallation> listInstallations() {
210209
* on error
211210
* @see <a href="https://developer.github.com/v3/apps/#get-an-installation">Get an installation</a>
212211
*/
213-
@Preview
212+
@Preview(MACHINE_MAN)
214213
@Deprecated
215214
public GHAppInstallation getInstallationById(long id) throws IOException {
216215
return root.createRequest()
@@ -233,7 +232,7 @@ public GHAppInstallation getInstallationById(long id) throws IOException {
233232
* @see <a href="https://developer.github.com/v3/apps/#get-an-organization-installation">Get an organization
234233
* installation</a>
235234
*/
236-
@Preview
235+
@Preview(MACHINE_MAN)
237236
@Deprecated
238237
public GHAppInstallation getInstallationByOrganization(String name) throws IOException {
239238
return root.createRequest()
@@ -258,7 +257,7 @@ public GHAppInstallation getInstallationByOrganization(String name) throws IOExc
258257
* @see <a href="https://developer.github.com/v3/apps/#get-a-repository-installation">Get a repository
259258
* installation</a>
260259
*/
261-
@Preview
260+
@Preview(MACHINE_MAN)
262261
@Deprecated
263262
public GHAppInstallation getInstallationByRepository(String ownerName, String repositoryName) throws IOException {
264263
return root.createRequest()
@@ -280,7 +279,7 @@ public GHAppInstallation getInstallationByRepository(String ownerName, String re
280279
* on error
281280
* @see <a href="https://developer.github.com/v3/apps/#get-a-user-installation">Get a user installation</a>
282281
*/
283-
@Preview
282+
@Preview(MACHINE_MAN)
284283
@Deprecated
285284
public GHAppInstallation getInstallationByUser(String name) throws IOException {
286285
return root.createRequest()

src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,19 @@
1414
* @see GHAppInstallation#createToken(Map) GHAppInstallation#createToken(Map)
1515
* @see GHAppInstallation#createToken() GHAppInstallation#createToken()
1616
*/
17-
public class GHAppCreateTokenBuilder {
18-
private final GitHub root;
17+
public class GHAppCreateTokenBuilder extends GitHubInteractiveObject {
1918
protected final Requester builder;
2019
private final String apiUrlTail;
2120

22-
@Preview
21+
@BetaApi
2322
@Deprecated
2423
GHAppCreateTokenBuilder(GitHub root, String apiUrlTail) {
2524
this.root = root;
2625
this.apiUrlTail = apiUrlTail;
2726
this.builder = root.createRequest();
2827
}
2928

30-
@Preview
29+
@BetaApi
3130
@Deprecated
3231
GHAppCreateTokenBuilder(GitHub root, String apiUrlTail, Map<String, GHPermissionType> permissions) {
3332
this(root, apiUrlTail);
@@ -43,7 +42,7 @@ public class GHAppCreateTokenBuilder {
4342
* Array containing the repositories Ids
4443
* @return a GHAppCreateTokenBuilder
4544
*/
46-
@Preview
45+
@BetaApi
4746
@Deprecated
4847
public GHAppCreateTokenBuilder repositoryIds(List<Long> repositoryIds) {
4948
this.builder.with("repository_ids", repositoryIds);
@@ -58,7 +57,7 @@ public GHAppCreateTokenBuilder repositoryIds(List<Long> repositoryIds) {
5857
* Map containing the permission names and types.
5958
* @return a GHAppCreateTokenBuilder
6059
*/
61-
@Preview
60+
@BetaApi
6261
@Deprecated
6362
public GHAppCreateTokenBuilder permissions(Map<String, GHPermissionType> permissions) {
6463
Map<String, String> retMap = new HashMap<>();
@@ -78,7 +77,7 @@ public GHAppCreateTokenBuilder permissions(Map<String, GHPermissionType> permiss
7877
* @throws IOException
7978
* on error
8079
*/
81-
@Preview
80+
@Preview(MACHINE_MAN)
8281
@Deprecated
8382
public GHAppInstallationToken create() throws IOException {
8483
return builder.method("POST")

0 commit comments

Comments
 (0)