chore: Ensure newly created files have a reasonable owner (#2465)

This commit is contained in:
Daniel Azuma 2021-01-21 17:53:52 -08:00 committed by GitHub
parent 82d85805a8
commit 405800782c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -15,8 +15,16 @@ end
# so any previously created files don't pollute this and subsequent synth runs.
execute "git clean -df"
Dir.chdir "google-apis-generator"
# This script is generally run as a superuser in a container. As a result,
# newly generated files will have a superuser owner, and cannot easily be
# removed by the caller. Thus, we must ensure any files generated during this
# run are given a reasonable owner before the script exits.
at_exit do
user_group = ENV["USER_GROUP"]
execute "chown -R #{user_group} #{DIR}/generated" if user_group
end
Dir.chdir "google-apis-generator"
execute "bundle install"
if ARGV.empty?

View File

@ -31,6 +31,7 @@ command = [
f"-v{os.getcwd()}:/workspace",
"-v/var/run/docker.sock:/var/run/docker.sock",
"-w", "/workspace",
"-e", f"USER_GROUP={os.getuid()}:{os.getgid()}",
"--entrypoint", "script/synth.rb",
"gcr.io/cloud-devrel-kokoro-resources/yoshi-ruby/autosynth"]
if extra_args():