From b40a346b2ceeee75d98b1d527d65984c2cb32b0c Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Tue, 22 Sep 2020 12:20:23 -0700 Subject: [PATCH] chore: regenerate templates (#346) * changes without context autosynth cannot find the source of changes triggered by earlier changes in this repository, or by version upgrades to tools such as linters. * chore(java_templates): add lint/static analysis presubmit checks for samples * chore(java_templates): add lint/static analysis presubmit checks for samples * chore: fix trailing whitespace Source-Author: Jeff Ching Source-Date: Mon Aug 17 14:29:16 2020 -0700 Source-Repo: googleapis/synthtool Source-Sha: c3caf0704f25a0c365f1c315e804a30b87c62a75 Source-Link: https://github.com/googleapis/synthtool/commit/c3caf0704f25a0c365f1c315e804a30b87c62a75 * chore(java_templates): stop running pmd/spotbugs checks for samples This was creating too much noise. We will revisit with other options and/or tune these checks. Source-Author: Jeff Ching Source-Date: Wed Aug 19 12:26:49 2020 -0700 Source-Repo: googleapis/synthtool Source-Sha: 9602086c6c5b05db77950c7f7495a2a3868f3537 Source-Link: https://github.com/googleapis/synthtool/commit/9602086c6c5b05db77950c7f7495a2a3868f3537 * fix: temporarily disable reporting to unblock releases Source-Author: Stephanie Wang Source-Date: Tue Aug 25 13:05:26 2020 -0400 Source-Repo: googleapis/synthtool Source-Sha: 968465a1cad496e1292ef4584a054a35f756ff94 Source-Link: https://github.com/googleapis/synthtool/commit/968465a1cad496e1292ef4584a054a35f756ff94 * build(java): switch to release-publish app for notifying GitHub of release status Source-Author: Jeff Ching Source-Date: Wed Aug 26 21:48:06 2020 -0700 Source-Repo: googleapis/synthtool Source-Sha: 019c7168faa0e56619f792693a8acdb30d6de19b Source-Link: https://github.com/googleapis/synthtool/commit/019c7168faa0e56619f792693a8acdb30d6de19b * build(ci): enable auto-release for dependency-update-only releases Automatically perform a Java client library release when: 1. Only dependency updates are going out in the release since any releases containing bug fixes, build changes or new features should be supervised; 2. There are no outstanding/open dependency update pull requests in the repo. This is to avoid multiple/redundant releases; 3. It is a SNAPSHOT release which is automatically generated post regular release -- this requires no human supervision. Testing done in 5 java-bigquery* client library repos. Example: [chore: release 0.3.4 ](https://github.com/googleapis/java-bigqueryconnection/pull/130) [chore: release 0.3.5-SNAPSHOT](https://github.com/googleapis/java-bigqueryconnection/pull/131) Source-Author: Stephanie Wang Source-Date: Thu Sep 17 15:30:02 2020 -0400 Source-Repo: googleapis/synthtool Source-Sha: 538a68019eb4a36a0cdfa4021f324dd01b784395 Source-Link: https://github.com/googleapis/synthtool/commit/538a68019eb4a36a0cdfa4021f324dd01b784395 * chore(java): set yoshi-java as default CODEOWNER Source-Author: Jeff Ching Source-Date: Mon Sep 21 09:00:06 2020 -0700 Source-Repo: googleapis/synthtool Source-Sha: 80003a3de2d8a75f5b47cb2e77e018f7f0f776cc Source-Link: https://github.com/googleapis/synthtool/commit/80003a3de2d8a75f5b47cb2e77e018f7f0f776cc Co-authored-by: Jeff Ching --- .github/CODEOWNERS | 1 + .github/workflows/auto-release.yaml | 69 +++++++++++++++++++++++++++++ .github/workflows/samples.yaml | 14 ++++++ .kokoro/release/stage.cfg | 31 ++----------- synth.metadata | 4 +- 5 files changed, 90 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/auto-release.yaml create mode 100644 .github/workflows/samples.yaml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 63122a26b..0bcf47a66 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -5,6 +5,7 @@ # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax # The @googleapis/api-pubsub is the default owner for changes in this repo +* @googleapis/yoshi-java @googleapis/api-pubsub **/*.java @googleapis/api-pubsub # The java-samples-reviewers team is the default owner for samples changes diff --git a/.github/workflows/auto-release.yaml b/.github/workflows/auto-release.yaml new file mode 100644 index 000000000..d26427e46 --- /dev/null +++ b/.github/workflows/auto-release.yaml @@ -0,0 +1,69 @@ +on: + pull_request: +name: auto-release +jobs: + approve: + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v3.0.0 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + debug: true + script: | + // only approve PRs from release-please[bot] + if (context.payload.pull_request.user.login !== "release-please[bot]") { + return; + } + + // only approve PRs like "chore: release " + if ( !context.payload.pull_request.title.startsWith("chore: release") ) { + return; + } + + // trigger auto-release when + // 1) it is a SNAPSHOT release (auto-generated post regular release) + // 2) there are dependency updates only + // 3) there are no open dependency update PRs in this repo (to avoid multiple releases) + if ( + context.payload.pull_request.body.includes("Fix") || + context.payload.pull_request.body.includes("Build") || + context.payload.pull_request.body.includes("Documentation") || + context.payload.pull_request.body.includes("BREAKING CHANGES") || + context.payload.pull_request.body.includes("Features") + ) { + console.log( "Not auto-releasing since it is not a dependency-update-only release." ); + return; + } + + const promise = github.pulls.list.endpoint({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open' + }); + const open_pulls = await github.paginate(promise) + + if ( open_pulls.length > 1 && !context.payload.pull_request.title.includes("SNAPSHOT") ) { + for ( const pull of open_pulls ) { + if ( pull.title.startsWith("deps: update dependency") ) { + console.log( "Not auto-releasing yet since there are dependency update PRs open in this repo." ); + return; + } + } + } + + // approve release PR + await github.pulls.createReview({ + owner: context.repo.owner, + repo: context.repo.repo, + body: 'Rubber stamped release!', + pull_number: context.payload.pull_request.number, + event: 'APPROVE' + }); + + // attach kokoro:force-run and automerge labels + await github.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.pull_request.number, + labels: ['kokoro:force-run', 'automerge'] + }); \ No newline at end of file diff --git a/.github/workflows/samples.yaml b/.github/workflows/samples.yaml new file mode 100644 index 000000000..a1d500730 --- /dev/null +++ b/.github/workflows/samples.yaml @@ -0,0 +1,14 @@ +on: + pull_request: +name: samples +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v1 + with: + java-version: 8 + - name: Run checkstyle + run: mvn -P lint --quiet --batch-mode checkstyle:check + working-directory: samples/snippets diff --git a/.kokoro/release/stage.cfg b/.kokoro/release/stage.cfg index a27131cf4..587130b55 100644 --- a/.kokoro/release/stage.cfg +++ b/.kokoro/release/stage.cfg @@ -13,32 +13,7 @@ action { } } -# Fetch the token needed for reporting release status to GitHub -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "yoshi-automation-github-key" - } - } -} - -# Fetch magictoken to use with Magic Github Proxy -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "releasetool-magictoken" - } - } -} - -# Fetch api key to use with Magic Github Proxy -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "magic-github-proxy-api-key" - } - } +env_vars: { + key: "SECRET_MANAGER_KEYS" + value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem" } diff --git a/synth.metadata b/synth.metadata index 17b6bfcaa..3fbc23417 100644 --- a/synth.metadata +++ b/synth.metadata @@ -19,7 +19,7 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "f8823dec98277a9516f2fb6fae9f58b3a59a23e1" + "sha": "80003a3de2d8a75f5b47cb2e77e018f7f0f776cc" } } ], @@ -42,7 +42,9 @@ ".github/PULL_REQUEST_TEMPLATE.md", ".github/release-please.yml", ".github/trusted-contribution.yml", + ".github/workflows/auto-release.yaml", ".github/workflows/ci.yaml", + ".github/workflows/samples.yaml", ".kokoro/build.bat", ".kokoro/build.sh", ".kokoro/coerce_logs.sh",