From ccf677d446b8c4e610dc805e9377b2c71e870bb2 Mon Sep 17 00:00:00 2001 From: Daniel Azuma Date: Tue, 8 Feb 2022 23:19:17 -0800 Subject: [PATCH] chore: Set up autoapprove and delete synth scripts (#8311) --- .github/workflows/autoapprove.yml | 4 +-- script/synth.rb | 39 ----------------------------- synth.py | 41 ------------------------------- 3 files changed, 2 insertions(+), 82 deletions(-) delete mode 100755 script/synth.rb delete mode 100644 synth.py diff --git a/.github/workflows/autoapprove.yml b/.github/workflows/autoapprove.yml index f6cbf2c3161..fab35e37442 100644 --- a/.github/workflows/autoapprove.yml +++ b/.github/workflows/autoapprove.yml @@ -10,7 +10,7 @@ on: jobs: auto-approve: runs-on: ubuntu-latest - if: contains(github.head_ref, 'autosynth') + if: contains(github.head_ref, 'gen/') env: ENABLE_AUTO_APPROVE: ${{ secrets.ENABLE_AUTO_APPROVE }} steps: @@ -19,7 +19,7 @@ jobs: with: github-token: ${{secrets.YOSHI_APPROVER_TOKEN}} script: | - if (context.payload.sender.login != "yoshi-automation") { + if (context.payload.sender.login != "yoshi-code-bot") { core.error("AutoApprove: Not running for this sender."); return; } diff --git a/script/synth.rb b/script/synth.rb deleted file mode 100755 index 46b55792b5e..00000000000 --- a/script/synth.rb +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env ruby - -require "fileutils" - -DIR = File.dirname __dir__ - -def execute cmd - puts 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" - -# 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? - execute "echo a | bundle exec bin/generate-api gen #{DIR}/generated --from-discovery --no-preferred-only --names=#{DIR}/api_names.yaml --names-out=#{DIR}/api_names_out.yaml --spot-check" -elsif ARGV == ["--clean"] || ARGV == ["clean"] - execute "bundle exec bin/generate-api gen #{DIR}/generated --clean" -elsif ARGV.size == 2 - api, version = ARGV - execute "echo a | bundle exec bin/generate-api gen #{DIR}/generated --api=#{api}.#{version} --names=#{DIR}/api_names.yaml --names-out=#{DIR}/api_names_out.yaml --spot-check" -else - abort "Bad arguments: #{ARGV}" -end diff --git a/synth.py b/synth.py deleted file mode 100644 index 469360520f1..00000000000 --- a/synth.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2020 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. - -"""This script is used to synthesize generated parts of this library.""" - -from synthtool.__main__ import extra_args -import synthtool as s -import synthtool.log as log -import synthtool.shell as shell -import logging -import os - -logging.basicConfig(level=logging.DEBUG) -s.metadata.set_track_obsolete_files(False) # TODO: enable again. - -command = [ - "docker", - "run", - "--rm", - 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(): - command.extend(extra_args()) - -log.debug(f"Running: {' '.join(command)}") -shell.run(command, hide_output=False)