diff --git a/.github/workflows/release-verify.yaml b/.github/workflows/release-verify.yaml index 1f5d15f4c09..a0d8478c6be 100644 --- a/.github/workflows/release-verify.yaml +++ b/.github/workflows/release-verify.yaml @@ -2,6 +2,10 @@ name: Verify Releases on: schedule: - cron: '0 9 * * *' + # zizmor: ignore[dangerous-triggers] -- triggered only by maintainer-dispatched Release Components and checks out default branch + workflow_run: + workflows: ["Release Components"] + types: [completed] workflow_dispatch: inputs: tag: @@ -41,13 +45,32 @@ jobs: ./dev/google-cloud release:verify "$TAG" --update-release -t "$GH_TOKEN" || FAILED=1 done exit $FAILED - - name: Create issue if previous step fails + - name: Create or update issue if previous step fails if: ${{ failure() && github.ref == 'refs/heads/main' }} - uses: googleapis/librarian/.github/actions/create-issue-on-failure@3c8cc1528686a089cace64bec5f29642c328e3b8 # v0.51.0 - with: - title: "Release verification failed" - body: | - `release:verify` failed for a recent release. - - Please check the logs: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - mention: "@googleapis/cloud-sdk-php-team" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + run: | + ROW="| $(date -u +'%Y-%m-%d %H:%M UTC') | [#$GITHUB_RUN_ID]($GITHUB_SERVER_URL/$GH_REPO/actions/runs/$GITHUB_RUN_ID) |" + ISSUE=$(gh issue list --repo "$GH_REPO" --search '"Release verification failed" in:title' --state open --json number,body --jq '.[0] // empty') + if [ -z "$ISSUE" ]; then + BODY=$(printf '`release:verify` failed for a recent release.\n\n@googleapis/cloud-sdk-php-team\n\n| Date | Workflow Run |\n| --- | --- |\n%s' "$ROW") + gh issue create \ + --repo "$GH_REPO" \ + --title "Release verification failed" \ + --label ":rotating_light: critical" \ + --body "$BODY" + else + NUM=$(jq -r '.number' <<<"$ISSUE") + BODY=$(jq -r '.body' <<<"$ISSUE") + [[ "$BODY" == *"| Date | Workflow Run |"* ]] || BODY="$BODY"$'\n\n| Date | Workflow Run |\n| --- | --- |' + gh api "repos/$GH_REPO/issues/$NUM" -X PATCH -f body="$BODY"$'\n'"$ROW" + fi + - name: Close issue if previous step succeeds + if: ${{ success() && github.ref == 'refs/heads/main' }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + run: | + gh issue list --repo "$GH_REPO" --search '"Release verification failed" in:title' --state open --json number --jq '.[0].number // empty' \ + | xargs -r -I{} gh issue close {} --repo "$GH_REPO" --comment "Release verification passed. Logs: $GITHUB_SERVER_URL/$GH_REPO/actions/runs/$GITHUB_RUN_ID" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9ea117f4de9..7d6f519746f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -72,14 +72,3 @@ jobs: --packagist-username="${VARS_PACKAGIST_USERNAME}" \ --packagist-token="$PACKAGIST_TOKEN" \ --packagist-safe-token="$PACKAGIST_SAFE_TOKEN" - - name: Verify all releases made it to Packagist - env: - RELEASE_TAG: ${{ inputs.tag != '' && inputs.tag || steps.getTag.outputs.tag }} - SPLIT_TOKEN: ${{ secrets.SPLIT_TOKEN }} - uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0 - with: - command: | - ./dev/google-cloud release:verify "$RELEASE_TAG" -t "$SPLIT_TOKEN" - timeout_minutes: 1 - max_attempts: 3 - retry_wait_seconds: 30 diff --git a/dev/src/Command/ReleaseVerifyCommand.php b/dev/src/Command/ReleaseVerifyCommand.php index 927db3aafc8..3a58da57ae0 100644 --- a/dev/src/Command/ReleaseVerifyCommand.php +++ b/dev/src/Command/ReleaseVerifyCommand.php @@ -42,6 +42,10 @@ class ReleaseVerifyCommand extends Command private const TABLE_HEADERS = ['Component', 'Version', 'Packagist', 'Docs']; private const VERIFY_MARKER_START = ''; private const VERIFY_MARKER_END = ''; + private const IGNORED_CHECK_RUNS = [ + 'Split and Release Components', + 'Verify Releases', + ]; private Client $httpClient; @@ -307,6 +311,9 @@ private function verifyReleaseCheckRuns( $checkRuns = $github->getCheckRuns(self::REPO_ID, $tag) ?? []; foreach ($checkRuns as $run) { $runName = $run['name'] ?? 'Unknown'; + if (in_array($runName, self::IGNORED_CHECK_RUNS, true)) { + continue; + } $runUrl = $run['html_url'] ?? ''; $markdownLabel = $runUrl ? sprintf('[%s](%s)', $runName, $runUrl) : $runName; diff --git a/dev/src/Command/RepoComplianceCommand.php b/dev/src/Command/RepoComplianceCommand.php index 83a0fec5f66..7bda12ae227 100644 --- a/dev/src/Command/RepoComplianceCommand.php +++ b/dev/src/Command/RepoComplianceCommand.php @@ -106,7 +106,8 @@ protected function execute(InputInterface $input, OutputInterface $output) } $repoCheck = $packagistCheck = $webhookCheck = $teamsCheck = true; if (!$this->checkSettingsCompliance($component, $details)) { - $repoCheck = false; + // New components are configured by repo:split on first release. + $repoCheck = $isNewComponent ? 'skipped' : false; $refreshDetails |= $this->askFixSettingsCompliance($input, $output, $component, $details); } if (!$this->checkWebhookCompliance($details)) { diff --git a/dev/tests/Unit/Command/ReleaseVerifyCommandTest.php b/dev/tests/Unit/Command/ReleaseVerifyCommandTest.php index 3aba369db6c..201b77ac760 100644 --- a/dev/tests/Unit/Command/ReleaseVerifyCommandTest.php +++ b/dev/tests/Unit/Command/ReleaseVerifyCommandTest.php @@ -67,6 +67,18 @@ public function testVerifyTagSuccess() 'conclusion' => 'success', 'html_url' => 'https://github.com/googleapis/google-cloud-php/actions/runs/1/job/1', ], + [ + 'name' => 'Verify Releases', + 'status' => 'in_progress', + 'conclusion' => null, + 'html_url' => 'https://github.com/googleapis/google-cloud-php/actions/runs/2/job/1', + ], + [ + 'name' => 'Split and Release Components', + 'status' => 'completed', + 'conclusion' => 'failure', + 'html_url' => 'https://github.com/googleapis/google-cloud-php/actions/runs/3/job/1', + ], ], ]))); @@ -125,6 +137,8 @@ public function testVerifyTagSuccess() $display = $commandTester->getDisplay(); $this->assertStringContainsString('v0.349.0', $display); $this->assertStringContainsString('Coding Standards', $display); + $this->assertStringNotContainsString('Verify Releases', $display); + $this->assertStringNotContainsString('Split and Release Components', $display); $this->assertStringContainsString('google/cloud-billing-budgets', $display); $this->assertStringContainsString('google/cloud-build', $display); $this->assertStringContainsString('google/common-protos', $display);