Skip to content

Commit 89fa5fc

Browse files
author
Takashi Matsuo
authored
testing: migrate to trampoline_v2 (GoogleCloudPlatform#3860)
* testing: prototype trampoline_v2 * add RUN_TESTS_DIRS envvar * add a script for running tests locally * don't rely on git, remove noxfile.py only if we copied it * add TRAMPOLINE_IMAGE_UPLOAD envvar * add example * add .trampolinerc_tmpl * allow docker in docker * use /workspace for project root * use $PROJECT_ROOT instead of $PWD * also pass down KOKORO_KEYSTORE_DIR * pass down Kokoro dynamic variables * introduce TRAMPOLINE_CI and TRAMPOLINE_V2 envvar * use --entrypoint instead of giving the command * add kbuilder's uid as the default arg * do not show the docker commands by default * make the mount point configurable * change TRAMPOLINE_IMAGE_SOURCE to TRAMPOLINE_DOCKERFILE * only decrypt the secret when the key exists * also prevents decrypt-secrets.sh to override existing files. * remove secret if we used decrypt-secrets.sh before the test * add 2 more envvars for build cop bot * setup kokoro service account only on kokoro * address review comments * correctly report the exit value * remove unnecessary build args * use docker gid * download cloud_sql_proxy to ${HOME} again
1 parent 3fd5150 commit 89fa5fc

27 files changed

+695
-51
lines changed

.kokoro/docker/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,19 @@ ENV PATH /google-cloud-sdk/bin:$PATH
161161
# Enable redis-server on boot.
162162
RUN sudo systemctl enable redis-server.service
163163

164+
# Create a user and allow sudo
165+
166+
# kbuilder uid on the default Kokoro image
167+
ARG UID=1000
168+
ARG USERNAME=kbuilder
169+
170+
# Add a new user to the container image.
171+
# This is needed for ssh and sudo access.
172+
173+
# Add a new user with the caller's uid and the username.
174+
RUN useradd -d /h -u ${UID} ${USERNAME}
175+
176+
# Allow nopasswd sudo
177+
RUN echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
178+
164179
CMD ["python3.6"]

.kokoro/lint/common.cfg

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ env_vars: {
2424
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
2525

2626
# Use the trampoline script to run in docker.
27-
build_file: "python-docs-samples/.kokoro/trampoline.sh"
27+
build_file: "python-docs-samples/.kokoro/trampoline_v2.sh"
2828

2929
# Download secrets from Cloud Storage.
3030
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"
@@ -41,3 +41,8 @@ env_vars: {
4141
key: "RUN_TESTS_SESSION"
4242
value: "lint"
4343
}
44+
45+
env_vars: {
46+
key: "TRAMPOLINE_DOCKERFILE"
47+
value: ".kokoro/docker/Dockerfile"
48+
}

.kokoro/lint/continuous.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
# Tell the trampoline which build file to use.
1818
env_vars: {
1919
key: "TRAMPOLINE_BUILD_FILE"
20-
value: "github/python-docs-samples/.kokoro/tests/run_tests_diff_head.sh"
20+
value: ".kokoro/tests/run_tests_diff_head.sh"
2121
}

.kokoro/lint/periodic.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
# Tell the trampoline which build file to use.
1818
env_vars: {
1919
key: "TRAMPOLINE_BUILD_FILE"
20-
value: "github/python-docs-samples/.kokoro/tests/run_tests.sh"
20+
value: ".kokoro/tests/run_tests.sh"
2121
}

.kokoro/lint/presubmit.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
# Tell the trampoline which build file to use.
1818
env_vars: {
1919
key: "TRAMPOLINE_BUILD_FILE"
20-
value: "github/python-docs-samples/.kokoro/tests/run_tests_diff_master.sh"
20+
value: ".kokoro/tests/run_tests_diff_master.sh"
2121
}

.kokoro/python2.7/common.cfg

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ env_vars: {
2626
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
2727

2828
# Use the trampoline script to run in docker.
29-
build_file: "python-docs-samples/.kokoro/trampoline.sh"
29+
build_file: "python-docs-samples/.kokoro/trampoline_v2.sh"
3030

3131
# Download secrets from Cloud Storage.
3232
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"
@@ -44,9 +44,13 @@ env_vars: {
4444
value: "py-2.7"
4545
}
4646

47-
# Declare build specific Cloud project. It still uses the common one,
48-
# but we'll update the value once we have more Cloud projects.
47+
# Declare build specific Cloud project.
4948
env_vars: {
5049
key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
5150
value: "python-docs-samples-tests"
5251
}
52+
53+
env_vars: {
54+
key: "TRAMPOLINE_DOCKERFILE"
55+
value: ".kokoro/docker/Dockerfile"
56+
}

.kokoro/python2.7/continuous.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
# Tell the trampoline which build file to use.
1818
env_vars: {
1919
key: "TRAMPOLINE_BUILD_FILE"
20-
value: "github/python-docs-samples/.kokoro/tests/run_tests_diff_head.sh"
20+
value: ".kokoro/tests/run_tests_diff_head.sh"
2121
}

.kokoro/python2.7/periodic.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
# Tell the trampoline which build file to use.
1818
env_vars: {
1919
key: "TRAMPOLINE_BUILD_FILE"
20-
value: "github/python-docs-samples/.kokoro/tests/run_tests.sh"
20+
value: ".kokoro/tests/run_tests.sh"
2121
}
2222

2323
env_vars: {
2424
key: "REPORT_TO_BUILD_COP_BOT"
25-
value: "True"
25+
value: "true"
2626
}

.kokoro/python2.7/presubmit.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
# Tell the trampoline which build file to use.
1818
env_vars: {
1919
key: "TRAMPOLINE_BUILD_FILE"
20-
value: "github/python-docs-samples/.kokoro/tests/run_tests_diff_master.sh"
20+
value: ".kokoro/tests/run_tests_diff_master.sh"
2121
}

.kokoro/python3.6/common.cfg

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ env_vars: {
2626
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
2727

2828
# Use the trampoline script to run in docker.
29-
build_file: "python-docs-samples/.kokoro/trampoline.sh"
29+
build_file: "python-docs-samples/.kokoro/trampoline_v2.sh"
3030

3131
# Download secrets from Cloud Storage.
3232
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"
@@ -50,3 +50,8 @@ env_vars: {
5050
key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
5151
value: "python-docs-samples-tests-py36"
5252
}
53+
54+
env_vars: {
55+
key: "TRAMPOLINE_DOCKERFILE"
56+
value: ".kokoro/docker/Dockerfile"
57+
}

0 commit comments

Comments
 (0)