-
Notifications
You must be signed in to change notification settings - Fork 68
chore: add docker image for hermetic build scripts #2493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
683c31f
5807d4e
d4cc19a
a5f3c8e
6ca4360
7e111b2
80d73ee
1988bc5
f096c3c
bd81ca2
24b591b
6880df9
9c82bec
76965c2
bb95d9c
6ffde65
73ae31c
46ea110
720d5f0
e622ccb
b28fd30
70c5d82
5cbcdc6
ee1d5fd
f6e73ae
f39cb82
c7e30eb
6c43da9
f9894ba
3671aeb
5ab1d90
a14f407
91cc061
60fd188
ade90e4
77214c6
ed45a9c
fbf133b
19f75f9
460ded2
53d1fe4
fa23a3c
fbcf12e
0af136c
e204536
8029dc2
d26c5da
6248c2d
2717c54
c253f8d
ad79348
a4bf286
6ff386c
dc520fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright 2024 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
timeout: 7200s # 2 hours | ||
substitutions: | ||
_IMAGE_NAME: "gcr.io/cloud-devrel-public-resources/java-library-generation" | ||
_SHA_IMAGE_ID: "${_IMAGE_NAME}:${COMMIT_SHA}" | ||
_LATEST_IMAGE_ID: "${_IMAGE_NAME}:latest" | ||
steps: | ||
# Library generation build | ||
- name: gcr.io/cloud-builders/docker | ||
args: [ | ||
"build", | ||
"-t", "${_SHA_IMAGE_ID}", | ||
"-t", "${_LATEST_IMAGE_ID}", | ||
"--file", ".cloudbuild/library_generation.Dockerfile", "."] | ||
id: library-generation-build | ||
waitFor: ["-"] | ||
|
||
images: | ||
- ${_SHA_IMAGE_ID} | ||
- ${_LATEST_IMAGE_ID} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright 2024 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
timeout: 7200s # 2 hours | ||
substitutions: | ||
_TEST_IMAGE_ID: 'gcr.io/cloud-devrel-public-resources/java-library-generation:${COMMIT_SHA}' | ||
|
||
steps: | ||
# Library generation build | ||
- name: gcr.io/cloud-builders/docker | ||
args: ["build", "-t", "${_TEST_IMAGE_ID}", "--file", ".cloudbuild/library_generation.Dockerfile", "."] | ||
id: library-generation-build | ||
waitFor: ["-"] | ||
- name: ${_TEST_IMAGE_ID} | ||
entrypoint: bash | ||
args: [ './library_generation/test/container_integration_tests.sh' ] | ||
waitFor: [ "library-generation-build" ] | ||
env: | ||
- 'TEST_IMAGE_ID=${_TEST_IMAGE_ID}' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright 2024 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# build from the root of this repo: | ||
FROM gcr.io/cloud-devrel-public-resources/python | ||
|
||
# install tools | ||
RUN apt-get update && apt-get install -y \ | ||
unzip openjdk-17-jdk rsync maven \ | ||
&& apt-get clean | ||
|
||
COPY library_generation /src | ||
|
||
RUN rm $(which python3) | ||
RUN ln -s $(which python3.11) /usr/local/bin/python | ||
RUN ln -s $(which python3.11) /usr/local/bin/python3 | ||
RUN python -m pip install --upgrade pip | ||
RUN cd /src && python -m pip install -r requirements.in | ||
RUN cd /src && python -m pip install . | ||
|
||
# set dummy git credentials for empty commit used in postprocessing | ||
RUN git config --global user.email "cloud-java-bot@google.com" | ||
RUN git config --global user.name "Cloud Java Bot" | ||
|
||
WORKDIR /workspace | ||
RUN chmod 750 /workspace | ||
RUN chmod 750 /src/generate_repo.py | ||
|
||
CMD [ "/src/generate_repo.py" ] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
README.md | ||
**/__pycache__/ | ||
**/*.egg-info/ | ||
**/output/ | ||
**/build/ | ||
**/google-cloud-java/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
# This is a wrapper of integration_tests.py that sets up the environment to run | ||
# the script in a docker container | ||
|
||
set -xe | ||
if [[ -z "${TEST_IMAGE_ID}" ]]; then | ||
echo "required environemnt variable TEST_IMAGE_ID is not set" | ||
exit 1 | ||
fi | ||
|
||
if [[ ! -d google-cloud-java ]]; then | ||
git clone https://github.com/googleapis/google-cloud-java | ||
fi | ||
pushd google-cloud-java | ||
git reset --hard main | ||
popd | ||
|
||
# We use a volume to hold the google-cloud-java repository used in the | ||
# integration tests. This is because the test container creates a child | ||
# container using the host machine's docker socket, meaning that we can only | ||
# reference volumes created from within the host machine (i.e. the machine | ||
# running this script) | ||
# | ||
# To summarize, we create a special volume that can be referenced both in the | ||
# main container and in any child containers created by this one. | ||
if [[ $(docker volume inspect repo) != '[]' ]]; then | ||
docker volume rm repo | ||
fi | ||
docker volume create --name "repo" --opt "type=none" --opt "device=$(pwd)/google-cloud-java" --opt "o=bind" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Since this requires a bit of docker-specific knowledge, perhaps we can add a quick comment explaining what we're trying to do here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a comment explaining why we create this volume |
||
|
||
docker run --rm \ | ||
-v repo:/workspace \ | ||
-v /tmp:/tmp \ | ||
-v /var/run/docker.sock:/var/run/docker.sock \ | ||
-e "RUNNING_IN_DOCKER=true" \ | ||
-e "REPO_BINDING_VOLUME=repo" \ | ||
-w "/src" \ | ||
"${TEST_IMAGE_ID}" \ | ||
python -m unittest /src/test/integration_tests.py |
Uh oh!
There was an error while loading. Please reload this page.