Skip to content

Commit

Permalink
Add lint test and format generated code (#4114)
Browse files Browse the repository at this point in the history
* Add lint Kokoro tests

* synthtool will now run the java formatter after generating the files
  • Loading branch information
chingor13 authored Nov 30, 2018
1 parent d642170 commit 8da11b0
Show file tree
Hide file tree
Showing 38 changed files with 583 additions and 257 deletions.
3 changes: 3 additions & 0 deletions .kokoro/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ test)
mvn test -B
bash $KOKORO_GFILE_DIR/codecov.sh
;;
lint)
mvn com.coveo:fmt-maven-plugin:check
;;
javadoc)
mvn javadoc:javadoc javadoc:test-javadoc
;;
Expand Down
13 changes: 13 additions & 0 deletions .kokoro/continuous/lint.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Configure the docker image for kokoro-trampoline.

env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/java8"
}

env_vars: {
key: "JOB_TYPE"
value: "lint"
}
13 changes: 13 additions & 0 deletions .kokoro/nightly/lint.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Configure the docker image for kokoro-trampoline.

env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/java8"
}

env_vars: {
key: "JOB_TYPE"
value: "lint"
}
13 changes: 13 additions & 0 deletions .kokoro/presubmit/lint.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Configure the docker image for kokoro-trampoline.

env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/java8"
}

env_vars: {
key: "JOB_TYPE"
value: "lint"
}
28 changes: 18 additions & 10 deletions google-cloud-clients/google-cloud-asset/synth.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,25 @@

import synthtool as s
import synthtool.gcp as gcp
import synthtool.languages.java as java

gapic = gcp.GAPICGenerator()
common_templates = gcp.CommonTemplates()

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

s.copy(v1beta1_library / 'gapic-google-cloud-asset-v1beta1/src', 'src')
s.copy(v1beta1_library / 'grpc-google-cloud-asset-v1beta1/src', '../../google-api-grpc/grpc-google-cloud-asset-v1beta1/src')
s.copy(v1beta1_library / 'proto-google-cloud-asset-v1beta1/src', '../../google-api-grpc/proto-google-cloud-asset-v1beta1/src')
for version in versions:
library = gapic.java_library(
service=service,
version=version,
config_path=config_pattern.format(version=version),
artman_output_name='')

s.copy(library / f'gapic-google-cloud-{service}-{version}/src', 'src')
s.copy(library / f'grpc-google-cloud-{service}-{version}/src', f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
s.copy(library / f'proto-google-cloud-{service}-{version}/src', f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')

java.format_code('./src')
java.format_code(f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
java.format_code(f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')
27 changes: 18 additions & 9 deletions google-cloud-clients/google-cloud-automl/synth.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,25 @@

import synthtool as s
import synthtool.gcp as gcp
import synthtool.languages.java as java

gapic = gcp.GAPICGenerator()
common_templates = gcp.CommonTemplates()

library = gapic.java_library(
service='automl',
version='v1beta1',
config_path='artman_automl_v1beta1.yaml',
artman_output_name='')
service = 'automl'
versions = ['v1beta1']
config_pattern = '/google/cloud/automl/artman_automl_{version}.yaml'

s.copy(library / 'gapic-google-cloud-automl-v1beta1/src', 'src')
s.copy(library / 'grpc-google-cloud-automl-v1beta1/src', '../../google-api-grpc/grpc-google-cloud-automl-v1beta1/src')
s.copy(library / 'proto-google-cloud-automl-v1beta1/src', '../../google-api-grpc/proto-google-cloud-automl-v1beta1/src')
for version in versions:
library = gapic.java_library(
service=service,
version=version,
config_path=config_pattern.format(version=version),
artman_output_name='')

s.copy(library / f'gapic-google-cloud-{service}-{version}/src', 'src')
s.copy(library / f'grpc-google-cloud-{service}-{version}/src', f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
s.copy(library / f'proto-google-cloud-{service}-{version}/src', f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')

java.format_code('./src')
java.format_code(f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
java.format_code(f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')
27 changes: 18 additions & 9 deletions google-cloud-clients/google-cloud-bigquerydatatransfer/synth.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,25 @@

import synthtool as s
import synthtool.gcp as gcp
import synthtool.languages.java as java

gapic = gcp.GAPICGenerator()
common_templates = gcp.CommonTemplates()

library = gapic.java_library(
service='bigquerydatatransfer',
version='v1',
config_path='/google/cloud/bigquery/datatransfer/artman_bigquerydatatransfer.yaml',
artman_output_name='')
service = 'bigquerydatatransfer'
versions = ['v1']
config_pattern = '/google/cloud/bigquery/datatransfer/artman_bigquerydatatransfer.yaml'

s.copy(library / 'gapic-google-cloud-bigquerydatatransfer-v1/src', 'src')
s.copy(library / 'grpc-google-cloud-bigquerydatatransfer-v1/src', '../../google-api-grpc/grpc-google-cloud-bigquerydatatransfer-v1/src')
s.copy(library / 'proto-google-cloud-bigquerydatatransfer-v1/src', '../../google-api-grpc/proto-google-cloud-bigquerydatatransfer-v1/src')
for version in versions:
library = gapic.java_library(
service=service,
version=version,
config_path=config_pattern.format(version=version),
artman_output_name='')

s.copy(library / f'gapic-google-cloud-{service}-{version}/src', 'src')
s.copy(library / f'grpc-google-cloud-{service}-{version}/src', f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
s.copy(library / f'proto-google-cloud-{service}-{version}/src', f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')

java.format_code('./src')
java.format_code(f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
java.format_code(f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')
22 changes: 15 additions & 7 deletions google-cloud-clients/google-cloud-bigquerystorage/synth.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,25 @@

import synthtool as s
import synthtool.gcp as gcp
import synthtool.languages.java as java

gapic = gcp.GAPICGenerator()
common_templates = gcp.CommonTemplates()

for version in ["v1beta1"]:
service = 'bigquerystorage'
versions = ['v1beta1']
config_pattern = '/google/cloud/bigquery/storage/artman_bigquerystorage_{version}.yaml'

for version in versions:
library = gapic.java_library(
service='bigquerystorage',
service=service,
version=version,
config_path=f'/google/cloud/bigquery/storage/artman_bigquerystorage_{version}.yaml',
config_path=config_pattern.format(version=version),
artman_output_name='')

s.copy(library / f'gapic-google-cloud-bigquerystorage-{version}/src', 'src')
s.copy(library / f'grpc-google-cloud-bigquerystorage-{version}/src', f'../../google-api-grpc/grpc-google-cloud-bigquerystorage-{version}/src')
s.copy(library / f'proto-google-cloud-bigquerystorage-{version}/src', f'../../google-api-grpc/proto-google-cloud-bigquerystorage-{version}/src')
s.copy(library / f'gapic-google-cloud-{service}-{version}/src', 'src')
s.copy(library / f'grpc-google-cloud-{service}-{version}/src', f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
s.copy(library / f'proto-google-cloud-{service}-{version}/src', f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')

java.format_code('./src')
java.format_code(f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
java.format_code(f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')
27 changes: 18 additions & 9 deletions google-cloud-clients/google-cloud-bigtable-admin/synth.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,25 @@

import synthtool as s
import synthtool.gcp as gcp
import synthtool.languages.java as java

gapic = gcp.GAPICGenerator()
common_templates = gcp.CommonTemplates()

library = gapic.java_library(
service='bigtable-admin',
version='v2',
config_path='/google/bigtable/admin/artman_bigtableadmin.yaml',
artman_output_name='')
service = 'bigtable-admin'
versions = ['v2']
config_pattern = '/google/bigtable/admin/artman_bigtableadmin.yaml'

s.copy(library / 'gapic-google-cloud-bigtable-admin-v2/src', 'src')
s.copy(library / 'grpc-google-cloud-bigtable-admin-v2/src', '../../google-api-grpc/grpc-google-cloud-bigtable-admin-v2/src')
s.copy(library / 'proto-google-cloud-bigtable-admin-v2/src', '../../google-api-grpc/proto-google-cloud-bigtable-admin-v2/src')
for version in versions:
library = gapic.java_library(
service=service,
version=version,
config_path=config_pattern.format(version=version),
artman_output_name='')

s.copy(library / f'gapic-google-cloud-{service}-{version}/src', 'src')
s.copy(library / f'grpc-google-cloud-{service}-{version}/src', f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
s.copy(library / f'proto-google-cloud-{service}-{version}/src', f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')

java.format_code('./src')
java.format_code(f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
java.format_code(f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')
27 changes: 18 additions & 9 deletions google-cloud-clients/google-cloud-bigtable/synth.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,25 @@

import synthtool as s
import synthtool.gcp as gcp
import synthtool.languages.java as java

gapic = gcp.GAPICGenerator()
common_templates = gcp.CommonTemplates()

library = gapic.java_library(
service='bigtable',
version='v2',
config_path='/google/bigtable/artman_bigtable.yaml',
artman_output_name='')
service = 'bigtable'
versions = ['v2']
config_pattern = '/google/bigtable/artman_bigtable.yaml'

s.copy(library / 'gapic-google-cloud-bigtable-v2/src', 'src')
s.copy(library / 'grpc-google-cloud-bigtable-v2/src', '../../google-api-grpc/grpc-google-cloud-bigtable-v2/src')
s.copy(library / 'proto-google-cloud-bigtable-v2/src', '../../google-api-grpc/proto-google-cloud-bigtable-v2/src')
for version in versions:
library = gapic.java_library(
service=service,
version=version,
config_path=config_pattern.format(version=version),
artman_output_name='')

s.copy(library / f'gapic-google-cloud-{service}-{version}/src', 'src')
s.copy(library / f'grpc-google-cloud-{service}-{version}/src', f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
s.copy(library / f'proto-google-cloud-{service}-{version}/src', f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')

java.format_code('./src')
java.format_code(f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
java.format_code(f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')
20 changes: 14 additions & 6 deletions google-cloud-clients/google-cloud-compute/synth.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,21 @@

import synthtool as s
import synthtool.gcp as gcp
import synthtool.languages.java as java

gapic = gcp.DiscoGAPICGenerator()

library = gapic.java_library(
service='compute',
version='v1',
config_path='artman_compute.yaml',
artman_output_name='')
service = 'compute'
versions = ['v1']
config_pattern = '/gapic/google/compute/artman_compute.yaml'

s.copy(library / 'gapic-google-cloud-compute-v1/src', 'src')
for version in versions:
library = gapic.java_library(
service=service,
version=version,
config_path=config_pattern.format(version=version),
artman_output_name='')

s.copy(library / f'gapic-google-cloud-{service}-{version}/src', 'src')

java.format_code('./src')
27 changes: 18 additions & 9 deletions google-cloud-clients/google-cloud-container/synth.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,25 @@

import synthtool as s
import synthtool.gcp as gcp
import synthtool.languages.java as java

gapic = gcp.GAPICGenerator()
common_templates = gcp.CommonTemplates()

library = gapic.java_library(
service='container',
version='v1',
config_path='/google/container/artman_container_v1.yaml',
artman_output_name='')
service = 'container'
versions = ['v1']
config_pattern = '/google/container/artman_container_{version}.yaml'

s.copy(library / 'gapic-google-cloud-container-v1/src', 'src')
s.copy(library / 'grpc-google-cloud-container-v1/src', '../../google-api-grpc/grpc-google-cloud-container-v1/src')
s.copy(library / 'proto-google-cloud-container-v1/src', '../../google-api-grpc/proto-google-cloud-container-v1/src')
for version in versions:
library = gapic.java_library(
service=service,
version=version,
config_path=config_pattern.format(version=version),
artman_output_name='')

s.copy(library / f'gapic-google-cloud-{service}-{version}/src', 'src')
s.copy(library / f'grpc-google-cloud-{service}-{version}/src', f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
s.copy(library / f'proto-google-cloud-{service}-{version}/src', f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')

java.format_code('./src')
java.format_code(f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
java.format_code(f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')
27 changes: 18 additions & 9 deletions google-cloud-clients/google-cloud-containeranalysis/synth.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,25 @@

import synthtool as s
import synthtool.gcp as gcp
import synthtool.languages.java as java

gapic = gcp.GAPICGenerator()
common_templates = gcp.CommonTemplates()

library = gapic.java_library(
service='container',
version='v1beta1',
config_path='/google/devtools/containeranalysis/artman_containeranalysis_v1beta1.yaml',
artman_output_name='')
service = 'containeranalysis'
versions = ['v1beta1']
config_pattern = '/google/devtools/containeranalysis/artman_containeranalysis_{version}.yaml'

s.copy(library / 'gapic-google-cloud-containeranalysis-v1beta1/src', 'src')
s.copy(library / 'grpc-google-cloud-containeranalysis-v1beta1/src', '../../google-api-grpc/grpc-google-cloud-containeranalysis-v1beta1/src')
s.copy(library / 'proto-google-cloud-containeranalysis-v1beta1/src', '../../google-api-grpc/proto-google-cloud-containeranalysis-v1beta1/src')
for version in versions:
library = gapic.java_library(
service=service,
version=version,
config_path=config_pattern.format(version=version),
artman_output_name='')

s.copy(library / f'gapic-google-cloud-{service}-{version}/src', 'src')
s.copy(library / f'grpc-google-cloud-{service}-{version}/src', f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
s.copy(library / f'proto-google-cloud-{service}-{version}/src', f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')

java.format_code('./src')
java.format_code(f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
java.format_code(f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')
22 changes: 15 additions & 7 deletions google-cloud-clients/google-cloud-dataproc/synth.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,25 @@

import synthtool as s
import synthtool.gcp as gcp
import synthtool.languages.java as java

gapic = gcp.GAPICGenerator()
common_templates = gcp.CommonTemplates()

for version in ["v1", "v1beta2"]:
service = 'dataproc'
versions = ['v1', 'v1beta2']
config_pattern = '/google/cloud/dataproc/artman_dataproc_{version}.yaml'

for version in versions:
library = gapic.java_library(
service='dataproc',
service=service,
version=version,
config_path=f'/google/cloud/dataproc/artman_dataproc_{version}.yaml',
config_path=config_pattern.format(version=version),
artman_output_name='')

s.copy(library / f'gapic-google-cloud-dataproc-{version}/src', 'src')
s.copy(library / f'grpc-google-cloud-dataproc-{version}/src', f'../../google-api-grpc/grpc-google-cloud-dataproc-{version}/src')
s.copy(library / f'proto-google-cloud-dataproc-{version}/src', f'../../google-api-grpc/proto-google-cloud-dataproc-{version}/src')
s.copy(library / f'gapic-google-cloud-{service}-{version}/src', 'src')
s.copy(library / f'grpc-google-cloud-{service}-{version}/src', f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
s.copy(library / f'proto-google-cloud-{service}-{version}/src', f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')

java.format_code('./src')
java.format_code(f'../../google-api-grpc/grpc-google-cloud-{service}-{version}/src')
java.format_code(f'../../google-api-grpc/proto-google-cloud-{service}-{version}/src')
Loading

0 comments on commit 8da11b0

Please sign in to comment.