chore: Clean up after creating new gems during autosynth (#2343)

This commit is contained in:
Daniel Azuma 2021-01-09 11:16:24 -08:00 committed by GitHub
parent db94d2b9cb
commit 863409162b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 0 deletions

35
.toys/generate.rb Normal file
View File

@ -0,0 +1,35 @@
desc "Run standard Google client generation."
optional_arg :api, desc: "API name (optional). Generates all APIs if omitted."
optional_arg :version, desc: "API version. Required if the API name is given."
include :bundler, gemfile_path: "#{context_directory}/google-apis-generator/Gemfile"
include :exec, e: true
def run
Dir.chdir "#{context_directory}/google-apis-generator"
case api
when "clean"
exec ["bin/generate-api", "gen",
"#{context_directory}/generated",
"--clean"]
when nil
p exec ["bin/generate-api", "gen",
"#{context_directory}/generated",
"--from-discovery",
"--no-preferred-only",
"--spot-check",
"--names=#{context_directory}/api_names.yaml",
"--names-out=#{context_directory}/api_names_out.yaml"],
in: [:string, "a\n"]
else
raise "Version is required if an API is given" unless version
exec ["bin/generate-api", "gen",
"#{context_directory}/generated",
"--api=#{api}.#{version}",
"--spot-check",
"--names=#{context_directory}/api_names.yaml",
"--names-out=#{context_directory}/api_names_out.yaml"],
in: [:string, "a\n"]
end
end

View File

@ -9,6 +9,12 @@ def execute cmd
abort unless system cmd
end
# In an autosynth (multi-library) run, a previous library synth may have
# created a new library. If so, autosynth doesn't clean up those newly created
# files (i.e. it runs git reset --hard but not git clean). Do that ourselves,
# so any previously created files don't pollute this and subsequent synth runs.
execute "git clean -df"
Dir.chdir "google-apis-generator"
execute "bundle install"