Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 34 additions & 9 deletions .github/workflows/release-verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ name: Verify Releases
on:
schedule:
- cron: '0 9 * * *'
# Triggered after Release Components completes to verify the release (including Packagist).
# Release Components is workflow_dispatch-only (maintainers) and this workflow only checks out the default branch.
# zizmor: ignore[dangerous-triggers]
workflow_run:
workflows: ["Release Components"]
types: [completed]
workflow_dispatch:
inputs:
tag:
Expand Down Expand Up @@ -41,13 +47,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@c54791693e09a76a7403f3dc81c7c97782908b3d # v0.53.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"
11 changes: 0 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 11 additions & 0 deletions dev/src/Command/ReleaseVerifyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ class ReleaseVerifyCommand extends Command
private const VERIFY_MARKER_START = '<!-- RELEASE_VERIFY_START -->';
private const VERIFY_MARKER_END = '<!-- RELEASE_VERIFY_END -->';

/**
* Skip the "Verify Releases" check run itself — otherwise it can block verification
* by appearing as PENDING while running, or FAILED if an earlier run failed.
*/
private const IGNORED_CHECK_RUNS = [
'Verify Releases',
];

private Client $httpClient;

/**
Expand Down Expand Up @@ -307,6 +315,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;

Expand Down
3 changes: 2 additions & 1 deletion dev/src/Command/RepoComplianceCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
7 changes: 7 additions & 0 deletions dev/tests/Unit/Command/ReleaseVerifyCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ 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',
],
],
])));

Expand Down Expand Up @@ -125,6 +131,7 @@ public function testVerifyTagSuccess()
$display = $commandTester->getDisplay();
$this->assertStringContainsString('v0.349.0', $display);
$this->assertStringContainsString('Coding Standards', $display);
$this->assertStringNotContainsString('Verify Releases', $display);
$this->assertStringContainsString('google/cloud-billing-budgets', $display);
$this->assertStringContainsString('google/cloud-build', $display);
$this->assertStringContainsString('google/common-protos', $display);
Expand Down
Loading