Repository navigation
chore: prepare Drips Wave contributor operations #234
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
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
aee8a4d
docs: define official Drips contribution flow
dDevAhmed 5a524df
ci: route Wave claims through Drips
dDevAhmed df53e50
ci: use Wave-length stale escalation
dDevAhmed bef86d9
ci: align Wave PR guard with Drips assignment
dDevAhmed 25e5cd7
docs: add Drips Wave operations runbook
dDevAhmed 26e8d2e
ci: label green Wave PRs for review
dDevAhmed 673189a
test: lock Wave operations safeguards
dDevAhmed b41554e
style: format Wave operations test
dDevAhmed 667e5e6
fix: reconcile readiness for fork pull requests
dDevAhmed 60c12c7
fix: measure contributor activity accurately
dDevAhmed fed7008
test: cover Wave automation edge cases
dDevAhmed c00aaef
style: format Wave edge-case tests
dDevAhmed 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
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
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,150 @@ | ||
| name: Wave PR Readiness | ||
|
|
||
| on: | ||
| workflow_run: | ||
| workflows: | ||
| - CI | ||
| - CodeQL | ||
| - Dependency Review | ||
| - E2E Smoke | ||
| - Contributor PR Guard | ||
| types: [completed] | ||
|
|
||
| permissions: | ||
| actions: read | ||
| contents: read | ||
| issues: write | ||
| pull-requests: read | ||
|
|
||
| concurrency: | ||
| group: wave-pr-readiness-${{ github.event.workflow_run.head_sha }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| readiness: | ||
| name: Mark green Wave PRs ready for review | ||
| if: github.event.workflow_run.event == 'pull_request' | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| steps: | ||
| - name: Reconcile review readiness | ||
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9 | ||
| with: | ||
| script: | | ||
| const owner = context.repo.owner; | ||
| const repo = context.repo.repo; | ||
| const labelName = 'review: ready'; | ||
| const requiredWorkflows = new Set([ | ||
| 'CI', | ||
| 'CodeQL', | ||
| 'Dependency Review', | ||
| 'E2E Smoke', | ||
| 'Contributor PR Guard', | ||
| ]); | ||
|
|
||
| try { | ||
| await github.rest.issues.getLabel({ owner, repo, name: labelName }); | ||
| } catch (error) { | ||
| if (error.status !== 404) throw error; | ||
| await github.rest.issues.createLabel({ | ||
| owner, | ||
| repo, | ||
| name: labelName, | ||
| color: '0e8a16', | ||
| description: 'Current PR head passed the required automated Wave checks', | ||
| }); | ||
| } | ||
|
|
||
| const run = context.payload.workflow_run; | ||
| let pullRefs = run.pull_requests || []; | ||
| if (!pullRefs.length) { | ||
| const openPulls = await github.paginate(github.rest.pulls.list, { | ||
| owner, repo, state: 'open', per_page: 100, | ||
| }); | ||
| pullRefs = openPulls.filter((pull) => pull.head.sha === run.head_sha); | ||
| } | ||
|
|
||
| for (const pullRef of pullRefs) { | ||
| const { data: pr } = await github.rest.pulls.get({ | ||
| owner, repo, pull_number: pullRef.number, | ||
| }); | ||
| const prLabels = new Set(pr.labels.map((label) => label.name)); | ||
|
|
||
| const removeReadyLabel = async () => { | ||
| if (!prLabels.has(labelName)) return; | ||
| try { | ||
| await github.rest.issues.removeLabel({ | ||
| owner, repo, issue_number: pr.number, name: labelName, | ||
| }); | ||
| } catch (error) { | ||
| if (error.status !== 404) throw error; | ||
| } | ||
| }; | ||
|
|
||
| if (pr.state !== 'open' || pr.draft) { | ||
| await removeReadyLabel(); | ||
| continue; | ||
| } | ||
|
|
||
| const ref = (pr.body || '').match( | ||
| /(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s+#(\d+)/i, | ||
| ); | ||
| if (!ref) { | ||
| await removeReadyLabel(); | ||
| continue; | ||
| } | ||
|
|
||
| let issue; | ||
| try { | ||
| ({ data: issue } = await github.rest.issues.get({ | ||
| owner, repo, issue_number: Number(ref[1]), | ||
| })); | ||
| } catch { | ||
| await removeReadyLabel(); | ||
| continue; | ||
| } | ||
| if (!issue.labels.some((label) => label.name === 'Stellar Wave')) { | ||
| await removeReadyLabel(); | ||
| continue; | ||
| } | ||
| if (!issue.assignees.some((assignee) => assignee.login === pr.user.login)) { | ||
| await removeReadyLabel(); | ||
| continue; | ||
| } | ||
|
|
||
| const runs = await github.paginate( | ||
| github.rest.actions.listWorkflowRunsForRepo, | ||
| { | ||
| owner, | ||
| repo, | ||
| head_sha: pr.head.sha, | ||
| event: 'pull_request', | ||
| per_page: 100, | ||
| }, | ||
| ); | ||
| const latestByWorkflow = new Map(); | ||
| for (const run of runs) { | ||
| if (!requiredWorkflows.has(run.name)) continue; | ||
| const current = latestByWorkflow.get(run.name); | ||
| if (!current || new Date(run.created_at) > new Date(current.created_at)) { | ||
| latestByWorkflow.set(run.name, run); | ||
| } | ||
| } | ||
|
|
||
| const green = [...requiredWorkflows].every((name) => { | ||
| const run = latestByWorkflow.get(name); | ||
| return run?.status === 'completed' && run?.conclusion === 'success'; | ||
| }); | ||
|
|
||
| if (!green) { | ||
| await removeReadyLabel(); | ||
| continue; | ||
| } | ||
|
|
||
| if (!prLabels.has(labelName)) { | ||
| await github.rest.issues.addLabels({ | ||
| owner, repo, issue_number: pr.number, labels: [labelName], | ||
| }); | ||
| } | ||
| core.info('Wave PR #' + pr.number + ' is ready for maintainer review.'); | ||
| } |
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
Oops, something went wrong.
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.