Skip to content
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

chore: update hermetic build docker volume usage #10770

Closed
2 changes: 1 addition & 1 deletion .github/workflows/hermetic_library_generation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
library_generation:
runs-on: ubuntu-latest
env:
library_generation_image_tag: 2.39.0
library_generation_image_tag: 2.40.0
steps:
- uses: actions/checkout@v4
with:
Expand Down
24 changes: 4 additions & 20 deletions generation/hermetic_library_generation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ if [ -z "${generation_config}" ]; then
echo "Use default generation config: ${generation_config}"
fi

volume_name="repo"
workspace_name="/workspace/repo"
repo_volumes="${volume_name}:${workspace_name}"
workspace_name="/workspace"
baseline_generation_config="baseline_generation_config.yaml"
message="chore: generate libraries at $(date)"

Expand All @@ -89,28 +87,14 @@ fi
git show "${target_branch}":"${generation_config}" > "${baseline_generation_config}"
config_diff=$(diff "${generation_config}" "${baseline_generation_config}")

# bind docker volume to include the repository in docker running environment.
if [[ $(docker volume inspect ${volume_name}) != '[]' ]]; then
docker volume rm ${volume_name}
fi
docker volume create \
--name ${volume_name} \
--opt "type=none" \
--opt "device=$(pwd)" \
--opt "o=bind"
# run hermetic code generation docker image.
docker run \
--rm \
-v "${repo_volumes}" \
-v /tmp:/tmp \
-v /var/run/docker.sock:/var/run/docker.sock \
-e "RUNNING_IN_DOCKER=true" \
-e "REPO_BINDING_VOLUMES=-v ${repo_volumes}" \
-u "$(id -u):$(id -g)" \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is the command enables us to modify/delete the docker generated files?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, including ownership takeover performed by the container

-v "$(pwd):${workspace_name}" \
gcr.io/cloud-devrel-public-resources/java-library-generation:"${image_tag}" \
python /src/cli/entry_point.py generate \
--baseline-generation-config-path="${workspace_name}/${baseline_generation_config}" \
--current-generation-config-path="${workspace_name}/${generation_config}" \
--repository-path="${workspace_name}"
--current-generation-config-path="${workspace_name}/${generation_config}"
# commit the change to the pull request.
git add java-* pom.xml gapic-libraries-bom/pom.xml versions.txt
changed_files=$(git diff --cached --name-only)
Expand Down
18 changes: 5 additions & 13 deletions generation/new_client_hermetic_build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,11 @@ was modified (or the script exited because the library already existed).

The last step you need is to `cd` into the root of `google-cloud-java` and run
```
docker volume create --name "repo-google-cloud-java" --opt "type=none" --opt "device=$(pwd)" --opt "o=bind"
repo_volumes="-v repo-google-cloud-java:/workspace/google-cloud-java"
docker run --rm \
${repo_volumes} \
-v /tmp:/tmp \
-v /var/run/docker.sock:/var/run/docker.sock \
-e "RUNNING_IN_DOCKER=true" \
-e "REPO_BINDING_VOLUMES=${repo_volumes}" \
gcr.io/cloud-devrel-public-resources/java-library-generation:latest \
python /src/generate_repo.py generate \
--generation-config-yaml=/workspace/google-cloud-java/generation_config.yaml \
--repository-path=/workspace/google-cloud-java \
--target-library-names=<library_name if specified; otherwise api_shortname>
docker run --rm -u $(id -u):$(id -g) -v $(pwd):/workspace --entrypoint \
python gcr.io/cloud-devrel-public-resources/java-library-generation:latest \
/src/generate_repo.py generate \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change this command to use entry_point.py because the cli in generate_repo.py will be removed soon.

--target-library-names=contentwarehouse \
--generation-config-yaml=/workspace/generation_config.yaml

```

Expand Down
Loading