Skip to content

Commit 5f7994c

Browse files
yoshi-automationchingor13
authored andcommitted
chore: update common templates (#26)
1 parent 7cc951b commit 5f7994c

File tree

11 files changed

+239
-15
lines changed

11 files changed

+239
-15
lines changed

.github/release-please.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
releaseType: java-yoshi
2+
bumpMinorPreMajor: true

.kokoro/build.sh

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ echo ${JOB_TYPE}
2727
mvn install -B -V \
2828
-DskipTests=true \
2929
-Dclirr.skip=true \
30+
-Denforcer.skip=true \
3031
-Dmaven.javadoc.skip=true \
3132
-Dgcloud.download.skip=true \
3233
-T 1C
@@ -38,23 +39,41 @@ fi
3839

3940
case ${JOB_TYPE} in
4041
test)
41-
mvn test -B -Dclirr.skip=true
42+
mvn test -B -Dclirr.skip=true -Denforcer.skip=true
4243
bash ${KOKORO_GFILE_DIR}/codecov.sh
4344
bash .kokoro/coerce_logs.sh
4445
;;
4546
lint)
46-
mvn com.coveo:fmt-maven-plugin:check
47+
mvn \
48+
-Penable-samples \
49+
com.coveo:fmt-maven-plugin:check
4750
;;
4851
javadoc)
4952
mvn javadoc:javadoc javadoc:test-javadoc
5053
;;
5154
integration)
52-
mvn -B ${INTEGRATION_TEST_ARGS} -DtrimStackTrace=false -Dclirr.skip=true -fae verify
55+
mvn -B ${INTEGRATION_TEST_ARGS} \
56+
-Penable-integration-tests \
57+
-DtrimStackTrace=false \
58+
-Dclirr.skip=true \
59+
-Denforcer.skip=true \
60+
-fae \
61+
verify
62+
bash .kokoro/coerce_logs.sh
63+
;;
64+
samples)
65+
mvn -B \
66+
-Penable-samples \
67+
-DtrimStackTrace=false \
68+
-Dclirr.skip=true \
69+
-Denforcer.skip=true \
70+
-fae \
71+
verify
5372
bash .kokoro/coerce_logs.sh
5473
;;
5574
clirr)
56-
mvn -B clirr:check
75+
mvn -B -Denforcer.skip=true clirr:check
5776
;;
5877
*)
5978
;;
60-
esac
79+
esac

.kokoro/continuous/samples.cfg

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Configure the docker image for kokoro-trampoline.
4+
env_vars: {
5+
key: "TRAMPOLINE_IMAGE"
6+
value: "gcr.io/cloud-devrel-kokoro-resources/java8"
7+
}
8+
9+
env_vars: {
10+
key: "JOB_TYPE"
11+
value: "samples"
12+
}
13+
14+
env_vars: {
15+
key: "GCLOUD_PROJECT"
16+
value: "gcloud-devel"
17+
}
18+
19+
env_vars: {
20+
key: "GOOGLE_APPLICATION_CREDENTIALS"
21+
value: "keystore/73713_java_it_service_account"
22+
}
23+
24+
before_action {
25+
fetch_keystore {
26+
keystore_resource {
27+
keystore_config_id: 73713
28+
keyname: "java_it_service_account"
29+
}
30+
}
31+
}

.kokoro/dependencies.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,9 @@ echo $JOB_TYPE
2323

2424
export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=128m"
2525

26-
mvn install -DskipTests=true -B -V
26+
# this should run maven enforcer
27+
mvn install -B -V \
28+
-DskipTests=true \
29+
-Dclirr.skip=true
30+
2731
mvn -B dependency:analyze -DfailOnWarning=true

.kokoro/nightly/samples.cfg

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Configure the docker image for kokoro-trampoline.
4+
env_vars: {
5+
key: "TRAMPOLINE_IMAGE"
6+
value: "gcr.io/cloud-devrel-kokoro-resources/java8"
7+
}
8+
9+
env_vars: {
10+
key: "JOB_TYPE"
11+
value: "samples"
12+
}
13+
14+
env_vars: {
15+
key: "GCLOUD_PROJECT"
16+
value: "gcloud-devel"
17+
}
18+
19+
env_vars: {
20+
key: "GOOGLE_APPLICATION_CREDENTIALS"
21+
value: "keystore/73713_java_it_service_account"
22+
}
23+
24+
before_action {
25+
fetch_keystore {
26+
keystore_resource {
27+
keystore_config_id: 73713
28+
keyname: "java_it_service_account"
29+
}
30+
}
31+
}

.kokoro/presubmit/samples.cfg

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Configure the docker image for kokoro-trampoline.
4+
env_vars: {
5+
key: "TRAMPOLINE_IMAGE"
6+
value: "gcr.io/cloud-devrel-kokoro-resources/java8"
7+
}
8+
9+
env_vars: {
10+
key: "JOB_TYPE"
11+
value: "samples"
12+
}
13+
14+
env_vars: {
15+
key: "GCLOUD_PROJECT"
16+
value: "gcloud-devel"
17+
}
18+
19+
env_vars: {
20+
key: "GOOGLE_APPLICATION_CREDENTIALS"
21+
value: "keystore/73713_java_it_service_account"
22+
}
23+
24+
before_action {
25+
fetch_keystore {
26+
keystore_resource {
27+
keystore_config_id: 73713
28+
keyname: "java_it_service_account"
29+
}
30+
}
31+
}

.kokoro/release/drop.cfg

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,3 @@ env_vars: {
44
key: "TRAMPOLINE_BUILD_FILE"
55
value: "github/java-spanner-jdbc/.kokoro/release/drop.sh"
66
}
7-
8-
# Download staging properties file.
9-
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/java/releases/java-spanner-jdbc"

.kokoro/release/promote.cfg

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,3 @@ env_vars: {
44
key: "TRAMPOLINE_BUILD_FILE"
55
value: "github/java-spanner-jdbc/.kokoro/release/promote.sh"
66
}
7-
8-
# Download staging properties file.
9-
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/java/releases/java-spanner-jdbc"
10-

.kokoro/release/publish_javadoc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ python3 -m pip install gcp-docuploader
3333
# compile all packages
3434
mvn clean install -B -DskipTests=true
3535

36-
NAME=spanner-jdbc
36+
NAME=google-cloud-spanner-jdbc
3737
VERSION=$(grep ${NAME}: versions.txt | cut -d: -f3)
3838

3939
# build the docs

CONTRIBUTING.md

Lines changed: 103 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,106 @@ information on using pull requests.
2525
## Community Guidelines
2626

2727
This project follows
28-
[Google's Open Source Community Guidelines](https://opensource.google.com/conduct/).
28+
[Google's Open Source Community Guidelines](https://opensource.google.com/conduct/).
29+
30+
## Building the project
31+
32+
To build, package, and run all unit tests run the command
33+
34+
```
35+
mvn clean verify
36+
```
37+
38+
### Running Integration tests
39+
40+
To include integration tests when building the project, you need access to
41+
a GCP Project with a valid service account.
42+
43+
For instructions on how to generate a service account and corresponding
44+
credentials JSON see: [Creating a Service Account][1].
45+
46+
Then run the following to build, package, run all unit tests and run all
47+
integration tests.
48+
49+
```bash
50+
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account.json
51+
mvn -Penable-integration-tests clean verify
52+
```
53+
54+
## Code Samples
55+
56+
Code Samples must be bundled in separate Maven modules, and guarded by a
57+
Maven profile with the name `enable-samples`.
58+
59+
The samples must be separate from the primary project for a few reasons:
60+
1. Primary projects have a minimum Java version of Java 7 whereas samples have
61+
a minimum Java version of Java 8. Due to this we need the ability to
62+
selectively exclude samples from a build run.
63+
2. Many code samples depend on external GCP services and need
64+
credentials to access the service.
65+
3. Code samples are not released as Maven artifacts and must be excluded from
66+
release builds.
67+
68+
### Building
69+
70+
```bash
71+
mvn -Penable-samples clean verify
72+
```
73+
74+
Some samples require access to GCP services and require a service account:
75+
76+
```bash
77+
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account.json
78+
mvn -Penable-samples clean verify
79+
```
80+
81+
### Profile Config
82+
83+
1. To add samples in a profile to your Maven project, add the following to your
84+
`pom.xml`
85+
86+
```xml
87+
<project>
88+
[...]
89+
<profiles>
90+
<profile>
91+
<id>enable-samples</id>
92+
<modules>
93+
<module>sample</module>
94+
</modules>
95+
</profile>
96+
</profiles>
97+
[...]
98+
</project>
99+
```
100+
101+
2. [Activate](#profile-activation) the profile.
102+
3. Define your samples in a normal Maven project in the `samples/` directory
103+
104+
### Profile Activation
105+
106+
To include code samples when building and testing the project, enable the
107+
`enable-samples` Maven profile.
108+
109+
#### Command line
110+
111+
To activate the Maven profile on the command line add `-Penable-samples` to your
112+
Maven command.
113+
114+
#### Maven `settings.xml`
115+
116+
To activate the Maven profile in your `~/.m2/settings.xml` add an entry of
117+
`enable-samples` following the instructions in [Active Profiles][2].
118+
119+
This method has the benefit of applying to all projects you build (and is
120+
respected by IntelliJ IDEA) and is recommended if you are going to be
121+
contributing samples to several projects.
122+
123+
#### IntelliJ IDEA
124+
125+
To activate the Maven Profile inside IntelliJ IDEA, follow the instructions in
126+
[Activate Maven profiles][3] to activate `enable-samples`.
127+
128+
[1]: https://cloud.google.com/docs/authentication/getting-started#creating_a_service_account
129+
[2]: https://maven.apache.org/settings.html#Active_Profiles
130+
[3]: https://www.jetbrains.com/help/idea/work-with-maven-profiles.html#activate_maven_profiles

0 commit comments

Comments
 (0)