Skip to content

Commit daf5c5e

Browse files
authored
Merge branch 'master' into remove-add-label-payload
2 parents 8509957 + a7b4c97 commit daf5c5e

6 files changed

Lines changed: 106 additions & 8 deletions

File tree

.github/workflows/maven-build.yml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@ name: CI
22

33
on: [push, pull_request]
44

5+
# this is required by spotless for JDK 16+
6+
env:
7+
JAVA_11_PLUS_MAVEN_OPTS: "--add-opens jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED"
58

69
jobs:
710
build:
811
name: build-only (Java ${{ matrix.java }})
912
runs-on: ubuntu-latest
1013
strategy:
14+
fail-fast: false
1115
matrix:
12-
java: [ 13 ]
16+
java: [ 16 ]
1317
steps:
1418
- uses: actions/checkout@v2
1519
- name: Set up JDK
@@ -24,11 +28,14 @@ jobs:
2428
restore-keys: |
2529
${{ runner.os }}-maven-
2630
- name: Maven Install (skipTests)
31+
env:
32+
MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }}
2733
run: mvn -B install -DskipTests -D enable-ci --file pom.xml
2834
site:
2935
name: site (Java ${{ matrix.java }})
3036
runs-on: ubuntu-latest
3137
strategy:
38+
fail-fast: false
3239
matrix:
3340
java: [ 8, 11 ]
3441
steps:
@@ -49,9 +56,10 @@ jobs:
4956
name: test (${{ matrix.os }}, Java ${{ matrix.java }})
5057
runs-on: ${{ matrix.os }}-latest
5158
strategy:
59+
fail-fast: false
5260
matrix:
5361
os: [ ubuntu, windows ]
54-
java: [ 8, 11, 13, 15-ea ]
62+
java: [ 8, 11, 16 ]
5563
steps:
5664
- uses: actions/checkout@v2
5765
- name: Set up JDK
@@ -64,9 +72,21 @@ jobs:
6472
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
6573
restore-keys: |
6674
${{ runner.os }}-maven-
75+
# JDK 8
6776
- name: Maven Install without Code Coverage
68-
if: matrix.os == 'windows'
77+
if: matrix.os == 'windows' && matrix.java == '8'
6978
run: mvn -B install --file pom.xml
7079
- name: Maven Install with Code Coverage
71-
if: matrix.os != 'windows'
80+
if: matrix.os != 'windows' && matrix.java == '8'
81+
run: mvn -B install -D enable-ci --file pom.xml
82+
# JDK 11+
83+
- name: Maven Install without Code Coverage
84+
if: matrix.os == 'windows' && matrix.java != '8'
85+
env:
86+
MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }}
87+
run: mvn -B install --file pom.xml
88+
- name: Maven Install with Code Coverage
89+
if: matrix.os != 'windows' && matrix.java != '8'
90+
env:
91+
MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }}
7292
run: mvn -B install -D enable-ci --file pom.xml

pom.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
<!-- For non-ci builds we'd like the build to still complete if jacoco metrics aren't met. -->
4646
<jacoco.haltOnFailure>false</jacoco.haltOnFailure>
4747
<jjwt.suite.version>0.11.2</jjwt.suite.version>
48+
49+
<surefire.argLine></surefire.argLine>
4850
</properties>
4951

5052
<build>
@@ -272,6 +274,7 @@
272274
<id>default-test</id>
273275
<configuration>
274276
<excludesFile>src/test/resources/slow-or-flaky-tests.txt</excludesFile>
277+
<argLine>${surefire.argLine}</argLine>
275278
</configuration>
276279
</execution>
277280
<execution>
@@ -284,6 +287,7 @@
284287
<rerunFailingTestsCount>2</rerunFailingTestsCount>
285288
<!-- There are some tests that take longer or are a little flaky. Run them here. -->
286289
<includesFile>src/test/resources/slow-or-flaky-tests.txt</includesFile>
290+
<argLine>${surefire.argLine}</argLine>
287291
</configuration>
288292
</execution>
289293
</executions>
@@ -561,6 +565,16 @@
561565
</pluginRepository>
562566
</pluginRepositories>
563567
<profiles>
568+
<profile>
569+
<id>jdk11+</id>
570+
<activation>
571+
<jdk>[11,)</jdk>
572+
</activation>
573+
<properties>
574+
<!-- this is required for GithubHttpUrlConnectionClient#setRequestMethod() to work with JDK 16+ -->
575+
<surefire.argLine>--add-opens java.base/java.net=ALL-UNNAMED</surefire.argLine>
576+
</properties>
577+
</profile>
564578
<profile>
565579
<id>ci-non-windows</id>
566580
<activation>

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.fasterxml.jackson.annotation.JacksonInject;
44
import com.fasterxml.jackson.annotation.JsonCreator;
5+
import com.fasterxml.jackson.annotation.JsonProperty;
56

67
import java.io.IOException;
78
import java.util.ArrayList;
@@ -22,6 +23,11 @@
2223
*/
2324
public class GHLabel extends GitHubInteractiveObject {
2425

26+
private long id;
27+
private String nodeId;
28+
@JsonProperty("default")
29+
private boolean default_;
30+
2531
@Nonnull
2632
private String url, name, color;
2733

@@ -42,6 +48,24 @@ GitHub getApiRoot() {
4248
return Objects.requireNonNull(root);
4349
}
4450

51+
/**
52+
* Gets id.
53+
*
54+
* @return the id
55+
*/
56+
public long getId() {
57+
return id;
58+
}
59+
60+
/**
61+
* Gets node id.
62+
*
63+
* @return the node id.
64+
*/
65+
public String getNodeId() {
66+
return nodeId;
67+
}
68+
4569
/**
4670
* Gets url.
4771
*
@@ -82,6 +106,15 @@ public String getDescription() {
82106
return description;
83107
}
84108

109+
/**
110+
* If the label is one of the default labels created by GitHub automatically.
111+
*
112+
* @return true if the label is a default one
113+
*/
114+
public boolean isDefault() {
115+
return default_;
116+
}
117+
85118
/**
86119
* Sets color.
87120
*

src/test/java/org/kohsuke/github/AppTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,9 @@ public void testRepoLabel() throws IOException {
965965
GHLabel e = r.getLabel("enhancement");
966966
assertEquals("enhancement", e.getName());
967967
assertNotNull(e.getUrl());
968+
assertEquals(177339106, e.getId());
969+
assertEquals("MDU6TGFiZWwxNzczMzkxMDY=", e.getNodeId());
970+
assertTrue(e.isDefault());
968971
assertTrue(Pattern.matches("[0-9a-fA-F]{6}", e.getColor()));
969972

970973
GHLabel t = null;
@@ -976,12 +979,17 @@ public void testRepoLabel() throws IOException {
976979
assertThat(t, not(sameInstance(t2)));
977980
assertThat(t, equalTo(t2));
978981

982+
assertFalse(t2.isDefault());
983+
984+
assertEquals(t.getId(), t2.getId());
985+
assertEquals(t.getNodeId(), t2.getNodeId());
979986
assertEquals(t.getName(), t2.getName());
980987
assertEquals(t.getColor(), "123456");
981988
assertEquals(t.getColor(), t2.getColor());
982989
assertEquals(t.getDescription(), "");
983990
assertEquals(t.getDescription(), t2.getDescription());
984991
assertEquals(t.getUrl(), t2.getUrl());
992+
assertEquals(t.isDefault(), t2.isDefault());
985993

986994
// update works on multiple changes in one call
987995
t3 = t.update().color("000000").description("It is dark!").done();

src/test/java/org/kohsuke/github/GHPullRequestTest.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@
99
import java.util.Collections;
1010
import java.util.List;
1111

12-
import static org.hamcrest.Matchers.*;
12+
import static org.hamcrest.Matchers.containsInAnyOrder;
13+
import static org.hamcrest.Matchers.containsString;
14+
import static org.hamcrest.Matchers.equalTo;
15+
import static org.hamcrest.Matchers.hasProperty;
16+
import static org.hamcrest.Matchers.instanceOf;
17+
import static org.hamcrest.Matchers.is;
18+
import static org.hamcrest.Matchers.notNullValue;
19+
import static org.hamcrest.Matchers.nullValue;
1320

1421
/**
1522
* @author Kohsuke Kawaguchi
@@ -418,7 +425,11 @@ public void setLabels() throws Exception {
418425

419426
Collection<GHLabel> labels = getRepository().getPullRequest(p.getNumber()).getLabels();
420427
assertEquals(1, labels.size());
421-
assertEquals(label, labels.iterator().next().getName());
428+
GHLabel savedLabel = labels.iterator().next();
429+
assertEquals(label, savedLabel.getName());
430+
assertNotNull(savedLabel.getId());
431+
assertNotNull(savedLabel.getNodeId());
432+
assertFalse(savedLabel.isDefault());
422433
}
423434

424435
@Test

src/test/java/org/kohsuke/github/GitHubConnectionTest.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
package org.kohsuke.github;
22

3+
import org.junit.Assume;
34
import org.junit.Test;
45
import org.kohsuke.github.authorization.UserAuthorizationProvider;
56

67
import java.io.IOException;
78
import java.lang.reflect.Field;
8-
import java.util.*;
9+
import java.util.Collections;
10+
import java.util.HashMap;
11+
import java.util.Map;
912

10-
import static org.hamcrest.CoreMatchers.*;
13+
import static org.hamcrest.Matchers.equalTo;
14+
import static org.hamcrest.Matchers.instanceOf;
15+
import static org.hamcrest.Matchers.lessThan;
16+
import static org.hamcrest.Matchers.not;
17+
import static org.hamcrest.Matchers.nullValue;
1118

1219
/**
1320
* Unit test for {@link GitHub}.
@@ -56,6 +63,8 @@ public void testGitHubServerWithoutServer() throws Exception {
5663

5764
@Test
5865
public void testGitHubBuilderFromEnvironment() throws IOException {
66+
// we disable this test for JDK 16+ as the current hacks in setupEnvironment() don't work with JDK 16+
67+
Assume.assumeThat(Double.valueOf(System.getProperty("java.specification.version")), lessThan(16.0));
5968

6069
Map<String, String> props = new HashMap<String, String>();
6170

@@ -98,6 +107,9 @@ public void testGitHubBuilderFromEnvironment() throws IOException {
98107

99108
@Test
100109
public void testGitHubBuilderFromCustomEnvironment() throws IOException {
110+
// we disable this test for JDK 16+ as the current hacks in setupEnvironment() don't work with JDK 16+
111+
Assume.assumeThat(Double.valueOf(System.getProperty("java.specification.version")), lessThan(16.0));
112+
101113
Map<String, String> props = new HashMap<String, String>();
102114

103115
props.put("customEndpoint", "bogus endpoint url");

0 commit comments

Comments
 (0)