Skip to content

Commit 912b77e

Browse files
authored
Merge branch 'main' into release-please--branches--main
2 parents b94b00e + 29abcfd commit 912b77e

File tree

13 files changed

+125
-30
lines changed

13 files changed

+125
-30
lines changed

.github/release-please.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ bumpMinorPreMajor: true
33
handleGHRelease: true
44
primaryBranch: main
55
manifest: true
6-
extraFiles: ["WORKSPACE", ".cloudbuild/graalvm/cloudbuild.yaml", ".cloudbuild/graalvm/cloudbuild-test-a.yaml", ".cloudbuild/graalvm/cloudbuild-test-b.yaml", ".cloudbuild/library_generation/cloudbuild-library-generation-release.yaml" ]
6+
extraFiles: ["WORKSPACE", ".cloudbuild/graalvm/cloudbuild.yaml", ".cloudbuild/graalvm/cloudbuild-test-a.yaml", ".cloudbuild/graalvm/cloudbuild-test-b.yaml", ".cloudbuild/library_generation/cloudbuild-library-generation-release.yaml", "generation_config.yaml"]

.github/workflows/ci.yaml

+35-8
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ jobs:
2222
run: |
2323
mvn test --batch-mode --no-transfer-progress -Dcheckstyle.skip \
2424
-Dfmt.skip -DenableTestCoverage
25+
# The `envVarTest` profile runs tests that require an environment variable
26+
- name: Env Var Tests
27+
run: |
28+
mvn test --batch-mode --no-transfer-progress -Dcheckstyle.skip \
29+
-Dfmt.skip -DenableTestCoverage -PenvVarTest
30+
# Set the Env Var for this step only
31+
env:
32+
GOOGLE_CLOUD_UNIVERSE_DOMAIN: random.com
2533
- run: bazelisk version
2634
- name: Install Maven modules
2735
run: |
@@ -63,7 +71,15 @@ jobs:
6371
- name: Unit Tests
6472
run: |
6573
mvn test --batch-mode --no-transfer-progress -Dcheckstyle.skip \
66-
74+
-Dfmt.skip -DenableTestCoverage
75+
# The `envVarTest` profile runs tests that require an environment variable
76+
- name: Env Var Tests
77+
run: |
78+
mvn test --batch-mode --no-transfer-progress -Dcheckstyle.skip \
79+
-Dfmt.skip -DenableTestCoverage -PenvVarTest
80+
# Set the Env Var for this step only
81+
env:
82+
GOOGLE_CLOUD_UNIVERSE_DOMAIN: random.com
6783
- run: bazelisk version
6884
- name: Install Maven modules
6985
run: |
@@ -95,14 +111,25 @@ jobs:
95111
export PATH=${JAVA_HOME}/bin:$PATH
96112
# Maven surefire plugin lets us to specify the JVM when running tests via
97113
# the "jvm" system property.
98-
mvn org.apache.maven.plugins:maven-surefire-plugin:test \
99-
verify \
100-
--batch-mode \
101-
--no-transfer-progress \
102-
-Dcheckstyle.skip \
114+
mvn verify --batch-mode --no-transfer-progress -Dcheckstyle.skip \
103115
-Dfmt.skip \
104-
-Djvm="${JAVA8_HOME}/bin/java" \
105-
-DargLine="-Djava.util.logging.SimpleFormatter.format='%1$tY %1$tl:%1$tM:%1$tS.%1$tL %2$s %4$s: %5$s%6$s%n'"
116+
-Djvm="${JAVA8_HOME}/bin/java"
117+
# The `envVarTest` profile runs tests that require an environment variable
118+
- name: Compile with Java 17 and run tests with Java 8 (Env Var Tests)
119+
shell: bash
120+
run: |
121+
set -x
122+
export JAVA_HOME=$JAVA_HOME
123+
export PATH=${JAVA_HOME}/bin:$PATH
124+
# Maven surefire plugin lets us to specify the JVM when running tests via
125+
# the "jvm" system property.
126+
export GOOGLE_CLOUD_UNIVERSE_DOMAIN=random.com
127+
mvn test --batch-mode --no-transfer-progress -Dcheckstyle.skip \
128+
-Dfmt.skip -DenableTestCoverage -Dsurefire.failIfNoSpecifiedTests=false \
129+
-PenvVarTest
130+
# Set the Env Var for this step only
131+
env:
132+
GOOGLE_CLOUD_UNIVERSE_DOMAIN: random.com
106133

107134
build-java8-gapic-generator-java:
108135
name: "build(8) for gapic-generator-java"

.github/workflows/sonar.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ jobs:
4747
tar -xf showcase-*
4848
./gapic-showcase run &
4949
cd -
50+
# Intentionally do not run the Env Var Tests (no -PenvVarTests) as setting the Env Var
51+
# may alter the results for other tests that use Env Var in the logic. Adding a Sonar
52+
# step for a few tests (env var tests) may be overkill and should be better covered
53+
# when we can upgrade to JUnit 5 (https://github.com/googleapis/sdk-platform-java/issues/1611#issuecomment-1970079325)
5054
- name: Build and analyze for full test coverage
5155
env:
5256
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any

gapic-generator-java-pom-parent/pom.xml

+17
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,23 @@
182182
</plugins>
183183
</build>
184184
</profile>
185+
<profile>
186+
<id>envVarTest</id>
187+
<build>
188+
<plugins>
189+
<plugin>
190+
<groupId>org.apache.maven.plugins</groupId>
191+
<artifactId>maven-surefire-plugin</artifactId>
192+
<configuration>
193+
<!-- Unless overriden in the submodules, this profile run no tests in a submodule -->
194+
<excludes>
195+
<exclude>**/*.java</exclude>
196+
</excludes>
197+
</configuration>
198+
</plugin>
199+
</plugins>
200+
</build>
201+
</profile>
185202
</profiles>
186203
<repositories>
187204
<repository>

gax-java/dependencies.properties

-1
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,3 @@ maven.net_bytebuddy_byte_buddy=net.bytebuddy:byte-buddy:1.14.16
8888
maven.org_objenesis_objenesis=org.objenesis:objenesis:2.6
8989
maven.org_junit_jupiter_junit_jupiter_api=org.junit.jupiter:junit-jupiter-api:5.10.2
9090
maven.org_junit_jupiter_junit_jupiter_params=org.junit.jupiter:junit-jupiter-params:5.10.2
91-
maven.org_junit_pioneer_junit_pioneer=org.junit-pioneer:junit-pioneer:2.2.0

gax-java/gax/BUILD.bazel

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ _TEST_COMPILE_DEPS = [
4141
"@net_bytebuddy_byte_buddy//jar",
4242
"@org_objenesis_objenesis//jar",
4343
"@com_googlecode_java_diff_utils_diffutils//jar",
44-
"@org_junit_pioneer_junit_pioneer//jar",
4544
]
4645

4746
java_library(

gax-java/gax/pom.xml

+22-8
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,32 @@
9999
</configuration>
100100
</plugin>
101101
<plugin>
102+
<!-- Troubleshooting a flaky test in https://github.com/googleapis/sdk-platform-java/issues/1931 -->
102103
<groupId>org.apache.maven.plugins</groupId>
103104
<artifactId>maven-surefire-plugin</artifactId>
104105
<configuration>
105-
<argLine>
106-
-Djava.util.logging.SimpleFormatter.format="%1$tY %1$tl:%1$tM:%1$tS.%1$tL %2$s %4$s: %5$s%6$s%n"
107-
<!-- workaround setup for using junit-pioneer with Java 17 or above,
108-
see https://junit-pioneer.org/docs/environment-variables/#warnings-for-reflective-access -->
109-
--add-opens java.base/java.util=ALL-UNNAMED
110-
--add-opens java.base/java.lang=ALL-UNNAMED
111-
</argLine>
106+
<argLine>-Djava.util.logging.SimpleFormatter.format="%1$tY %1$tl:%1$tM:%1$tS.%1$tL %2$s %4$s: %5$s%6$s%n"</argLine>
107+
<!-- These tests require an Env Var to be set. Use -PenvVarTest to ONLY run these tests -->
108+
<test>!EndpointContextTest#endpointContextBuild_universeDomainEnvVarSet+endpointContextBuild_multipleUniverseDomainConfigurations_clientSettingsHasPriority</test>
112109
</configuration>
113110
</plugin>
114111
</plugins>
115112
</build>
116-
</project>
113+
114+
<profiles>
115+
<profile>
116+
<id>envVarTest</id>
117+
<build>
118+
<plugins>
119+
<plugin>
120+
<groupId>org.apache.maven.plugins</groupId>
121+
<artifactId>maven-surefire-plugin</artifactId>
122+
<configuration>
123+
<test>EndpointContextTest#endpointContextBuild_universeDomainEnvVarSet+endpointContextBuild_multipleUniverseDomainConfigurations_clientSettingsHasPriority</test>
124+
</configuration>
125+
</plugin>
126+
</plugins>
127+
</build>
128+
</profile>
129+
</profiles>
130+
</project>

gax-java/gax/src/test/java/com/google/api/gax/rpc/EndpointContextTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import java.io.IOException;
4141
import org.junit.jupiter.api.BeforeEach;
4242
import org.junit.jupiter.api.Test;
43-
import org.junitpioneer.jupiter.SetEnvironmentVariable;
4443
import org.mockito.Mockito;
4544

4645
class EndpointContextTest {
@@ -338,8 +337,8 @@ void endpointContextBuild_gdchFlow_noUniverseDomain_customEndpoint() throws IOEx
338337

339338
// This Universe Domain should match the `GOOGLE_CLOUD_UNIVERSE_DOMAIN` Env Var
340339
// For this test running locally or in CI, check that the Env Var is set properly.
340+
// This test should only run when the maven profile `EnvVarTest` is enabled.
341341
@Test
342-
@SetEnvironmentVariable(key = EndpointContext.GOOGLE_CLOUD_UNIVERSE_DOMAIN, value = "random.com")
343342
void endpointContextBuild_universeDomainEnvVarSet() throws IOException {
344343
String envVarUniverseDomain = "random.com";
345344
EndpointContext endpointContext =
@@ -353,10 +352,11 @@ void endpointContextBuild_universeDomainEnvVarSet() throws IOException {
353352

354353
// This Universe Domain should match the `GOOGLE_CLOUD_UNIVERSE_DOMAIN` Env Var
355354
// For this test running locally or in CI, check that the Env Var is set properly.
355+
// This test should only run when the maven profile `EnvVarTest` is enabled.
356356
@Test
357-
@SetEnvironmentVariable(key = EndpointContext.GOOGLE_CLOUD_UNIVERSE_DOMAIN, value = "random.com")
358357
void endpointContextBuild_multipleUniverseDomainConfigurations_clientSettingsHasPriority()
359358
throws IOException {
359+
// This test has `GOOGLE_CLOUD_UNIVERSE_DOMAIN` = `random.com`
360360
String clientSettingsUniverseDomain = "clientSettingsUniverseDomain.com";
361361
EndpointContext endpointContext =
362362
defaultEndpointContextBuilder

gax-java/pom.xml

-6
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,6 @@
205205
</exclusions>
206206
<scope>test</scope>
207207
</dependency>
208-
<dependency>
209-
<groupId>org.junit-pioneer</groupId>
210-
<artifactId>junit-pioneer</artifactId>
211-
<version>2.2.0</version>
212-
<scope>test</scope>
213-
</dependency>
214208
</dependencies>
215209

216210
<build>

generation_config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
gapic_generator_version: 2.40.2-SNAPSHOT
1+
gapic_generator_version: 2.40.2-SNAPSHOT # {x-version-update:gapic-generator-java:current}
22
googleapis_commitish: 3d50414a7ff3f0b8ffe8ad7858257396e4f18131
33
template_excludes:
44
- .github/*

library_generation/generate_pr_description.py

+9
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
from library_generation.utils.commit_message_formatter import format_commit_message
2323
from library_generation.utils.commit_message_formatter import wrap_override_commit
2424

25+
EMPTY_MESSAGE = ""
26+
2527

2628
def generate_pr_descriptions(
2729
config: GenerationConfig,
@@ -62,6 +64,10 @@ def generate_pr_descriptions(
6264
is_monorepo=config.is_monorepo(),
6365
)
6466

67+
if description == EMPTY_MESSAGE:
68+
print("Empty commit messages, skip creating pull request description.")
69+
return
70+
6571
description_file = f"{description_path}/pr_description.txt"
6672
print(f"Writing pull request description to {description_file}")
6773
with open(description_file, "w+") as f:
@@ -115,6 +121,9 @@ def get_commit_messages(
115121
break
116122
commit = commit_parents[0]
117123
shutil.rmtree(tmp_dir, ignore_errors=True)
124+
if len(qualified_commits) == 0:
125+
return EMPTY_MESSAGE
126+
118127
return __combine_commit_messages(
119128
current_commit=current_commit,
120129
baseline_commit=baseline_commit,

library_generation/test/generate_pr_description_unit_tests.py

+25
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,28 @@ def test_generate_pr_description_with_same_googleapis_commits(self):
7070
description_path=cwd,
7171
)
7272
self.assertFalse(os.path.isfile(f"{cwd}/pr_description.txt"))
73+
74+
def test_generate_pr_description_does_not_create_pr_description_without_qualified_commit(
75+
self,
76+
):
77+
# committed on May 22nd, 2024
78+
old_commit_sha = "30717c0b0c9966906880703208a4c820411565c4"
79+
# committed on May 23rd, 2024
80+
new_commit_sha = "eeed69d446a90eb4a4a2d1762c49d637075390c1"
81+
cwd = os.getcwd()
82+
generate_pr_descriptions(
83+
config=GenerationConfig(
84+
gapic_generator_version="",
85+
googleapis_commitish=new_commit_sha,
86+
libraries_bom_version="",
87+
template_excludes=[],
88+
grpc_version="",
89+
protoc_version="",
90+
# use empty libraries to make sure no qualified commit between
91+
# two commit sha.
92+
libraries=[],
93+
),
94+
baseline_commit=old_commit_sha,
95+
description_path=cwd,
96+
)
97+
self.assertFalse(os.path.isfile(f"{cwd}/pr_description.txt"))

release-please-config.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@
55
"group-pull-request-title-pattern": "chore(${branch}): release ${version}",
66
"packages": {
77
".": {
8-
"extra-files": ["WORKSPACE", ".cloudbuild/graalvm/cloudbuild.yaml", ".cloudbuild/graalvm/cloudbuild-test-a.yaml", ".cloudbuild/graalvm/cloudbuild-test-b.yaml", ".cloudbuild/library_generation/cloudbuild-library-generation-release.yaml"]
8+
"extra-files": [
9+
"WORKSPACE",
10+
".cloudbuild/graalvm/cloudbuild.yaml",
11+
".cloudbuild/graalvm/cloudbuild-test-a.yaml",
12+
".cloudbuild/graalvm/cloudbuild-test-b.yaml",
13+
".cloudbuild/library_generation/cloudbuild-library-generation-release.yaml",
14+
"generation_config.yaml"
15+
]
916
}
1017
}
1118
}

0 commit comments

Comments
 (0)