Skip to content

Commit 8da11b0

Browse files
authored
Add lint test and format generated code (#4114)
* Add lint Kokoro tests * synthtool will now run the java formatter after generating the files
1 parent d642170 commit 8da11b0

File tree

38 files changed

+583
-257
lines changed

38 files changed

+583
-257
lines changed

.kokoro/build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ test)
3333
mvn test -B
3434
bash $KOKORO_GFILE_DIR/codecov.sh
3535
;;
36+
lint)
37+
mvn com.coveo:fmt-maven-plugin:check
38+
;;
3639
javadoc)
3740
mvn javadoc:javadoc javadoc:test-javadoc
3841
;;

.kokoro/continuous/lint.cfg

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Configure the docker image for kokoro-trampoline.
4+
5+
env_vars: {
6+
key: "TRAMPOLINE_IMAGE"
7+
value: "gcr.io/cloud-devrel-kokoro-resources/java8"
8+
}
9+
10+
env_vars: {
11+
key: "JOB_TYPE"
12+
value: "lint"
13+
}

.kokoro/nightly/lint.cfg

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Configure the docker image for kokoro-trampoline.
4+
5+
env_vars: {
6+
key: "TRAMPOLINE_IMAGE"
7+
value: "gcr.io/cloud-devrel-kokoro-resources/java8"
8+
}
9+
10+
env_vars: {
11+
key: "JOB_TYPE"
12+
value: "lint"
13+
}

.kokoro/presubmit/lint.cfg

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Configure the docker image for kokoro-trampoline.
4+
5+
env_vars: {
6+
key: "TRAMPOLINE_IMAGE"
7+
value: "gcr.io/cloud-devrel-kokoro-resources/java8"
8+
}
9+
10+
env_vars: {
11+
key: "JOB_TYPE"
12+
value: "lint"
13+
}

google-cloud-clients/google-cloud-asset/synth.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,25 @@
1616

1717
import synthtool as s
1818
import synthtool.gcp as gcp
19+
import synthtool.languages.java as java
1920

2021
gapic = gcp.GAPICGenerator()
21-
common_templates = gcp.CommonTemplates()
2222

23-
# tasks has two product names, and a poorly named artman yaml
24-
v1beta1_library = gapic.java_library(
25-
service='asset',
26-
version='v1beta1',
27-
config_path='artman_cloudasset_v1beta1.yaml',
28-
artman_output_name='')
23+
service = 'asset'
24+
versions = ['v1beta1']
25+
config_pattern = '/google/cloud/asset/artman_cloudasset_{version}.yaml'
2926

30-
s.copy(v1beta1_library / 'gapic-google-cloud-asset-v1beta1/src', 'src')
31-
s.copy(v1beta1_library / 'grpc-google-cloud-asset-v1beta1/src', '../../google-api-grpc/grpc-google-cloud-asset-v1beta1/src')
32-
s.copy(v1beta1_library / 'proto-google-cloud-asset-v1beta1/src', '../../google-api-grpc/proto-google-cloud-asset-v1beta1/src')
27+
for version in versions:
28+
library = gapic.java_library(
29+
service=service,
30+
version=version,
31+
config_path=config_pattern.format(version=version),
32+
artman_output_name='')
33+
34+
s.copy(library / f'gapic-google-cloud-{service}-{version}/src', 'src')
35+
s.copy(library / f'grpc-google-cloud-{service}-{version}/src', f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
36+
s.copy(library / f'proto-google-cloud-{service}-{version}/src', f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')
37+
38+
java.format_code('./src')
39+
java.format_code(f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
40+
java.format_code(f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')

google-cloud-clients/google-cloud-automl/synth.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,25 @@
1616

1717
import synthtool as s
1818
import synthtool.gcp as gcp
19+
import synthtool.languages.java as java
1920

2021
gapic = gcp.GAPICGenerator()
21-
common_templates = gcp.CommonTemplates()
2222

23-
library = gapic.java_library(
24-
service='automl',
25-
version='v1beta1',
26-
config_path='artman_automl_v1beta1.yaml',
27-
artman_output_name='')
23+
service = 'automl'
24+
versions = ['v1beta1']
25+
config_pattern = '/google/cloud/automl/artman_automl_{version}.yaml'
2826

29-
s.copy(library / 'gapic-google-cloud-automl-v1beta1/src', 'src')
30-
s.copy(library / 'grpc-google-cloud-automl-v1beta1/src', '../../google-api-grpc/grpc-google-cloud-automl-v1beta1/src')
31-
s.copy(library / 'proto-google-cloud-automl-v1beta1/src', '../../google-api-grpc/proto-google-cloud-automl-v1beta1/src')
27+
for version in versions:
28+
library = gapic.java_library(
29+
service=service,
30+
version=version,
31+
config_path=config_pattern.format(version=version),
32+
artman_output_name='')
33+
34+
s.copy(library / f'gapic-google-cloud-{service}-{version}/src', 'src')
35+
s.copy(library / f'grpc-google-cloud-{service}-{version}/src', f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
36+
s.copy(library / f'proto-google-cloud-{service}-{version}/src', f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')
37+
38+
java.format_code('./src')
39+
java.format_code(f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
40+
java.format_code(f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')

google-cloud-clients/google-cloud-bigquerydatatransfer/synth.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,25 @@
1616

1717
import synthtool as s
1818
import synthtool.gcp as gcp
19+
import synthtool.languages.java as java
1920

2021
gapic = gcp.GAPICGenerator()
21-
common_templates = gcp.CommonTemplates()
2222

23-
library = gapic.java_library(
24-
service='bigquerydatatransfer',
25-
version='v1',
26-
config_path='/google/cloud/bigquery/datatransfer/artman_bigquerydatatransfer.yaml',
27-
artman_output_name='')
23+
service = 'bigquerydatatransfer'
24+
versions = ['v1']
25+
config_pattern = '/google/cloud/bigquery/datatransfer/artman_bigquerydatatransfer.yaml'
2826

29-
s.copy(library / 'gapic-google-cloud-bigquerydatatransfer-v1/src', 'src')
30-
s.copy(library / 'grpc-google-cloud-bigquerydatatransfer-v1/src', '../../google-api-grpc/grpc-google-cloud-bigquerydatatransfer-v1/src')
31-
s.copy(library / 'proto-google-cloud-bigquerydatatransfer-v1/src', '../../google-api-grpc/proto-google-cloud-bigquerydatatransfer-v1/src')
27+
for version in versions:
28+
library = gapic.java_library(
29+
service=service,
30+
version=version,
31+
config_path=config_pattern.format(version=version),
32+
artman_output_name='')
33+
34+
s.copy(library / f'gapic-google-cloud-{service}-{version}/src', 'src')
35+
s.copy(library / f'grpc-google-cloud-{service}-{version}/src', f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
36+
s.copy(library / f'proto-google-cloud-{service}-{version}/src', f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')
37+
38+
java.format_code('./src')
39+
java.format_code(f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
40+
java.format_code(f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')

google-cloud-clients/google-cloud-bigquerystorage/synth.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,25 @@
1515

1616
import synthtool as s
1717
import synthtool.gcp as gcp
18+
import synthtool.languages.java as java
1819

1920
gapic = gcp.GAPICGenerator()
20-
common_templates = gcp.CommonTemplates()
2121

22-
for version in ["v1beta1"]:
22+
service = 'bigquerystorage'
23+
versions = ['v1beta1']
24+
config_pattern = '/google/cloud/bigquery/storage/artman_bigquerystorage_{version}.yaml'
25+
26+
for version in versions:
2327
library = gapic.java_library(
24-
service='bigquerystorage',
28+
service=service,
2529
version=version,
26-
config_path=f'/google/cloud/bigquery/storage/artman_bigquerystorage_{version}.yaml',
30+
config_path=config_pattern.format(version=version),
2731
artman_output_name='')
2832

29-
s.copy(library / f'gapic-google-cloud-bigquerystorage-{version}/src', 'src')
30-
s.copy(library / f'grpc-google-cloud-bigquerystorage-{version}/src', f'../../google-api-grpc/grpc-google-cloud-bigquerystorage-{version}/src')
31-
s.copy(library / f'proto-google-cloud-bigquerystorage-{version}/src', f'../../google-api-grpc/proto-google-cloud-bigquerystorage-{version}/src')
33+
s.copy(library / f'gapic-google-cloud-{service}-{version}/src', 'src')
34+
s.copy(library / f'grpc-google-cloud-{service}-{version}/src', f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
35+
s.copy(library / f'proto-google-cloud-{service}-{version}/src', f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')
36+
37+
java.format_code('./src')
38+
java.format_code(f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
39+
java.format_code(f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')

google-cloud-clients/google-cloud-bigtable-admin/synth.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,25 @@
1616

1717
import synthtool as s
1818
import synthtool.gcp as gcp
19+
import synthtool.languages.java as java
1920

2021
gapic = gcp.GAPICGenerator()
21-
common_templates = gcp.CommonTemplates()
2222

23-
library = gapic.java_library(
24-
service='bigtable-admin',
25-
version='v2',
26-
config_path='/google/bigtable/admin/artman_bigtableadmin.yaml',
27-
artman_output_name='')
23+
service = 'bigtable-admin'
24+
versions = ['v2']
25+
config_pattern = '/google/bigtable/admin/artman_bigtableadmin.yaml'
2826

29-
s.copy(library / 'gapic-google-cloud-bigtable-admin-v2/src', 'src')
30-
s.copy(library / 'grpc-google-cloud-bigtable-admin-v2/src', '../../google-api-grpc/grpc-google-cloud-bigtable-admin-v2/src')
31-
s.copy(library / 'proto-google-cloud-bigtable-admin-v2/src', '../../google-api-grpc/proto-google-cloud-bigtable-admin-v2/src')
27+
for version in versions:
28+
library = gapic.java_library(
29+
service=service,
30+
version=version,
31+
config_path=config_pattern.format(version=version),
32+
artman_output_name='')
33+
34+
s.copy(library / f'gapic-google-cloud-{service}-{version}/src', 'src')
35+
s.copy(library / f'grpc-google-cloud-{service}-{version}/src', f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
36+
s.copy(library / f'proto-google-cloud-{service}-{version}/src', f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')
37+
38+
java.format_code('./src')
39+
java.format_code(f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
40+
java.format_code(f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')

google-cloud-clients/google-cloud-bigtable/synth.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,25 @@
1616

1717
import synthtool as s
1818
import synthtool.gcp as gcp
19+
import synthtool.languages.java as java
1920

2021
gapic = gcp.GAPICGenerator()
21-
common_templates = gcp.CommonTemplates()
2222

23-
library = gapic.java_library(
24-
service='bigtable',
25-
version='v2',
26-
config_path='/google/bigtable/artman_bigtable.yaml',
27-
artman_output_name='')
23+
service = 'bigtable'
24+
versions = ['v2']
25+
config_pattern = '/google/bigtable/artman_bigtable.yaml'
2826

29-
s.copy(library / 'gapic-google-cloud-bigtable-v2/src', 'src')
30-
s.copy(library / 'grpc-google-cloud-bigtable-v2/src', '../../google-api-grpc/grpc-google-cloud-bigtable-v2/src')
31-
s.copy(library / 'proto-google-cloud-bigtable-v2/src', '../../google-api-grpc/proto-google-cloud-bigtable-v2/src')
27+
for version in versions:
28+
library = gapic.java_library(
29+
service=service,
30+
version=version,
31+
config_path=config_pattern.format(version=version),
32+
artman_output_name='')
33+
34+
s.copy(library / f'gapic-google-cloud-{service}-{version}/src', 'src')
35+
s.copy(library / f'grpc-google-cloud-{service}-{version}/src', f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
36+
s.copy(library / f'proto-google-cloud-{service}-{version}/src', f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')
37+
38+
java.format_code('./src')
39+
java.format_code(f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
40+
java.format_code(f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')

0 commit comments

Comments
 (0)