Skip to content

Add OWNERS file, maintainer-approval workflow, and rewrite suggest-reviewers in JS#4912

Merged
simonfaltum merged 4 commits intomainfrom
simonfaltum/maintainer-approval
Apr 8, 2026
Merged

Add OWNERS file, maintainer-approval workflow, and rewrite suggest-reviewers in JS#4912
simonfaltum merged 4 commits intomainfrom
simonfaltum/maintainer-approval

Conversation

@simonfaltum
Copy link
Copy Markdown
Member

@simonfaltum simonfaltum commented Apr 8, 2026

Why

GitHub's CODEOWNERS auto-assigns all matching owners on every PR. There's no setting to disable this. Our * catch-all means all 6 core team members get auto-assigned on every single PR.

We want core team approval to be required, but nobody should get auto-assigned. This PR adds the new enforcement mechanism (maintainer-approval workflow) and rewrites the suggest-reviewers script from Python to JavaScript, so both workflow scripts share a common OWNERS parsing module and we can drop the uv/Python dependency from the suggest-reviewers workflow.

This is Step 1 of replacing CODEOWNERS. CODEOWNERS stays for now so existing auto-assignment behavior is unchanged. Step 2 will delete CODEOWNERS.

Changes

Before: CODEOWNERS auto-assigns all owners. suggest-reviewers runs via Python/uv. No merge gate for core team approval.

Now: A new maintainer-approval check blocks merge without core team approval. suggest-reviewers is rewritten in JS using Octokit (no more Python/uv dependency). Both scripts share an OWNERS parsing module. A round-robin fallback picks a reviewer when git history has no signal.

New files

  1. .github/OWNERS: Copy of CODEOWNERS with /cmd/bundle/ widened to cover the whole directory (was /cmd/bundle/bundle.go). Both workflow scripts read this file.

  2. .github/scripts/owners.js: Shared module for OWNERS file parsing, pattern matching, and owner resolution. Exports parseOwnersFile, ownersMatch, findOwners, getCoreTeam. Supports an { includeTeams: true } option for the suggest-reviewers use case.

  3. .github/workflows/maintainer-approval.yml + .js: GitHub Actions workflow that triggers on pull_request_target and pull_request_review. Blocks merge unless a core team member has approved. Includes exemption logic for domain-specific owners.

  4. .github/workflows/suggest-reviewers.js: JS port of tools/suggest_reviewers.py. Uses Octokit for all GitHub API calls (authenticated, with built-in retries and pagination). Uses child_process.execSync for git log only (no Octokit equivalent for per-path history). Includes a round-robin fallback that queries review counts via the GitHub search API.

Modified files

  1. .github/workflows/suggest-reviewers.yml: Drops astral-sh/setup-uv step. Uses actions/github-script instead of uv run tools/suggest_reviewers.py. Keeps fetch-depth: 0 (needed for git log), custom runner group, and draft/fork checks.

Deleted files

  1. tools/suggest_reviewers.py: Replaced by the JS version.

Manual step after merge

Add "Maintainer approval" as a required status check in branch protection for main.

Test plan

  • After merge, open a test PR and verify the maintainer-approval check fails (no approval yet)
  • Have a core team member approve, verify the check passes
  • Verify suggest-reviewers posts a comment with the correct format (suggested reviewers, eligible reviewers, confidence level)
  • Open a PR touching only new files (no git history), verify round-robin fallback picks a reviewer
  • Once confident, proceed with Step 2 (delete CODEOWNERS)

Add a GitHub Actions workflow that blocks merge unless a core team
member has approved. This is Step 1 of replacing CODEOWNERS with
OWNERS. CODEOWNERS stays for now so existing behavior is unchanged.

The OWNERS file is an exact copy of CODEOWNERS. The maintainer-approval
workflow reads it at runtime to determine the core team from the *
catch-all rule, then checks if any core team member has approved the PR.

Domain-specific exemption: if all changed files are owned by non-core
owners that include the PR author, any approval suffices.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

Eligible reviewers

Could not determine reviewers from git history. Based on CODEOWNERS, these people or teams could review:

@andrewnester, @anton-107, @denik, @pietern, @shreyas-goenka

Suggestions based on git history of 3 changed files (0 scored). See CODEOWNERS for path-specific ownership rules.

Fix null user destructuring in maintainer-approval.js that would crash
on reviews from deleted GitHub accounts. Add empty file list guard in
the exemption check. Add success output for debugging.

Add round-robin fallback to suggest_reviewers.py: when git history
can't determine a reviewer, query the GitHub search API for each
eligible reviewer's review count over the last 30 days and pick the
person with the fewest reviews. Falls back to random if the API fails.

Also fix yamlfmt: script block uses |- instead of |.
The CODEOWNERS entry only covered the single file. The intent was to
include lennartkats-db on all bundle command changes, not just the
root registration file. Since OWNERS is our new file and CODEOWNERS
stays unchanged for now, we can fix this here.
Replace tools/suggest_reviewers.py with a JavaScript version that runs
via actions/github-script. This drops the uv/Python dependency from the
suggest-reviewers workflow.

Extract shared OWNERS parsing into .github/scripts/owners.js, imported
by both maintainer-approval.js and suggest-reviewers.js. Both scripts
now read .github/OWNERS instead of .github/CODEOWNERS.

The JS version uses Octokit for all GitHub API calls (no gh CLI) and
child_process.execSync for git log only. Includes round-robin fallback:
when git history can't determine a reviewer, queries the GitHub search
API for recent review counts and picks the person with fewest reviews.
@simonfaltum simonfaltum changed the title Add maintainer-approval workflow and OWNERS file Add OWNERS file, maintainer-approval workflow, and rewrite suggest-reviewers in JS Apr 8, 2026
@simonfaltum simonfaltum added this pull request to the merge queue Apr 8, 2026
@simonfaltum simonfaltum removed this pull request from the merge queue due to a manual request Apr 8, 2026
@simonfaltum simonfaltum added this pull request to the merge queue Apr 8, 2026
Merged via the queue into main with commit 2634aa6 Apr 8, 2026
18 checks passed
@simonfaltum simonfaltum deleted the simonfaltum/maintainer-approval branch April 8, 2026 12:37
simonfaltum added a commit that referenced this pull request Apr 8, 2026
Simon is already covered by the * catch-all rule. Listing him
explicitly on /cmd/bundle/ is redundant.

This PR also serves to verify the maintainer-approval and
suggest-reviewers workflows added in #4912.
github-merge-queue bot pushed a commit that referenced this pull request Apr 8, 2026
## Why

The maintainer-approval workflow from #4912 used `ubuntu-latest` (GitHub
public runners), which can't make API calls against the `databricks` org
due to the IP allow-list. Also, `@simonfaltum` was listed on the
`/cmd/bundle/` OWNERS rule but isn't on the bundle team.

## Changes

1. Switch `maintainer-approval.yml` from `ubuntu-latest` to the
`databricks-deco-testing-runner-group` custom runner, matching all other
workflows in the repo.
2. Remove `@simonfaltum` from `/cmd/bundle/` in `.github/OWNERS` since
he's not on the bundle team.

## Test plan

- [x] `suggest-reviewers / suggest-reviewers` fired and posted a
reviewer suggestion comment with round-robin fallback
- [ ] After merge, verify `Maintainer approval / check` runs on the
custom runner (requires a new PR since `pull_request_target` reads
workflows from the base branch)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants