Skip to content
Open
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
41 changes: 32 additions & 9 deletions .github/workflows/release-verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"
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
7 changes: 7 additions & 0 deletions dev/src/Command/ReleaseVerifyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ class ReleaseVerifyCommand extends Command
private const TABLE_HEADERS = ['Component', 'Version', 'Packagist', 'Docs'];
private const VERIFY_MARKER_START = '<!-- RELEASE_VERIFY_START -->';
private const VERIFY_MARKER_END = '<!-- RELEASE_VERIFY_END -->';
private const IGNORED_CHECK_RUNS = [
'Split and Release Components',
'Verify Releases',
];

private Client $httpClient;

Expand Down Expand Up @@ -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;

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
14 changes: 14 additions & 0 deletions dev/tests/Unit/Command/ReleaseVerifyCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
],
])));

Expand Down Expand Up @@ -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);
Expand Down
Loading