-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add automated PR watchdog for codelab parameters #4206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+67
−0
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
110a5df
yml file
aasthabharill 5f000c7
yml file
aasthabharill e87f833
changes
aasthabharill 080ac0d
deps: update Python dependencies (#4194)
github-actions[bot] 9546a81
[SpannerToSourceDb] Reverse replication Integration test with SSL bas…
darshan-sj 70ea652
add auto-close dependabot step for requirements*.txt type files (#4220)
derrickaw c46910a
add delta lake to iceberg blueprint and IT (#4103)
derrickaw 6138536
fix naming determination (#4210)
derrickaw 074e68d
Refactor pipeline parameter options to seperate Options.java file (#4…
aasthabharill a5424b3
change+test
aasthabharill 056bcff
Merge branch 'main' into codelab-updates2
aasthabharill 9ef9a46
revert test changes
aasthabharill File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| name: Codelab Parameter Watchdog | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened, edited] | ||
| paths: | ||
| - '**/SourceDbToSpannerOptions.java' | ||
| - '**/DataStreamToSpannerOptions.java' | ||
| - '**/SpannerToSourceDbOptions.java' | ||
|
|
||
| jobs: | ||
| enforce-codelab-bug: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| pull-requests: write | ||
| steps: | ||
| - name: Checkout Code | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
|
|
||
| - name: Validate Parameter Changes and PR Description | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| REPO: ${{ github.repository }} | ||
| PR_BODY: ${{ github.event.pull_request.body }} | ||
| run: | | ||
| echo "⚠️ Template parameter changes detected." | ||
| MARKER="<!-- codelab-watchdog-comment -->" | ||
| COMMENT_URL=$(gh api "repos/$REPO/issues/$PR_NUMBER/comments" -q ".[] | select(.user.login == \"github-actions[bot]\" and (.body | contains(\"$MARKER\"))) | .url" | head -n 1) | ||
|
|
||
| if printf "%s\n" "$PR_BODY" | grep -E -q 'CODELAB_BUG=b/[0-9]+'; then | ||
| echo "✅ Found CODELAB_BUG tag in PR description. Workflow unblocked." | ||
|
|
||
| # If we previously left a warning comment, gracefully update it to green. | ||
| if [ -n "$COMMENT_URL" ]; then | ||
| echo "$MARKER" > comment.md | ||
| echo "✅ **Codelab Update Reminder Assured**" >> comment.md | ||
| echo "A \`CODELAB_BUG\` reference was found. Thank you for tracking the DevSite Codelab documentation updates!" >> comment.md | ||
| echo "" >> comment.md | ||
| echo "Please follow the step-by-step instructions in [go/update-migrations-codelabs](http://go/update-migrations-codelabs) to update the codelabs with your changes." >> comment.md | ||
| gh api -X PATCH "$COMMENT_URL" -F body=@comment.md || true | ||
| fi | ||
| exit 0 | ||
| fi | ||
|
|
||
| # If CODELAB_BUG is missing, post the warning and fail | ||
| echo "❌ Missing CODELAB_BUG=b/XXXX in PR description." | ||
| echo "$MARKER" > comment.md | ||
| echo "🚨 **Codelab Update Required** 🚨" >> comment.md | ||
| echo "This PR modifies pipeline parameters documented in the Spanner Migration Codelabs." >> comment.md | ||
| echo "" >> comment.md | ||
| echo "**Action Required:**" >> comment.md | ||
| echo "To unblock this PR, please add a bug tracker reference to the PR description (e.g., \`CODELAB_BUG=b/12345678\`) confirming there is a ticket to update the codelabs." >> comment.md | ||
| echo "" >> comment.md | ||
| echo "Please follow the step-by-step instructions in [go/update-migrations-codelabs](http://go/update-migrations-codelabs) to update the codelabs with your changes." >> comment.md | ||
|
|
||
| # If the COMMENT_URL variable is not empty, it means we found an existing comment created by this bot. | ||
| # We PATCH (update) the existing comment to avoid spamming the PR with duplicate comments. | ||
| # If it is empty, we use 'gh pr comment' to create a brand new comment. | ||
| if [ -n "$COMMENT_URL" ]; then | ||
| gh api -X PATCH "$COMMENT_URL" -F body=@comment.md || true | ||
| else | ||
| gh pr comment "$PR_NUMBER" --body-file comment.md --repo "$REPO" || true | ||
| fi | ||
|
|
||
| echo "::error title=Codelab Update Required::This PR modifies pipeline parameters. To unblock this PR, add a bug tracker reference to the PR description (e.g., CODELAB_BUG=b/123456). Follow instructions in go/update-migrations-codelabs to update the documentation." | ||
| exit 1 | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.