Skip to content

feat: codeowners-analysis action#1218

Merged
erikburt merged 13 commits intomainfrom
feat/codeowners-analysis
Sep 17, 2025
Merged

feat: codeowners-analysis action#1218
erikburt merged 13 commits intomainfrom
feat/codeowners-analysis

Conversation

@erikburt
Copy link
Copy Markdown
Contributor

@erikburt erikburt commented Sep 12, 2025

This adds a codeowners-review-analysis action which helps PR authors understand the CODEOWNERS review requirements for their changes.

High-level overview

This action does the following:

  1. Gets a list of changed files for a PR
  2. Gets the CODEOWNERS file from the default branch
  3. Gets the "current PR review state" by
    • Using GQL query to get review events in reverse chronological order, to build up the current review state for a PR
  4. Figures out which codeowners entries are relevant to this PR via pattern matching of entries, and list of changed files
  5. Cross references current review state with relevant codeowners entries to figure out which entries are satisfied
  6. Creates full summary for workflow summary, and partial pending-only summary as a PR comment

Testing

I tested here: https://github.com/smartcontractkit/releng-test/pull/138#issuecomment-3286728832 (and locally using scripts/test.sh)

Triggering

I did some preliminary testing via org-wide ruleset here: smartcontractkit/gha-org-workflows#17

Basically you can only operate on top-level pull_request events, not sub events like pr.labeled, or different top-level events issue_comment. So if this is implemented org-wide it won't be seamless to trigger.

Current Flow w/ Org-wide ruleset:

  • User adds analyze-reviews label to their PR and pushes a new commit.
  • Anytime they want to refresh the review analysis,
    • They need to rerun the workflow (cli command added as part of the pr comment) OR
    • Push an empty commit (to not dismiss current reviews), but this would cause all of CI to retrigger.

This could look better if we added the workflow at the repo level, as we could have it trigger via comments, or labels, but then we need to maintain it to some degree. This is feasible because there's not that many repos where shared ownership makes codeowners hunting difficult.

  • We could have a reusable workflow in this repository, and then individual workflows reference the reusable one (makes it a bit easier to maintain). This would allow us to setup more usable triggers.

Notes

Include minimal unit tests - will follow up w/ these in another PR.


DX-1787

@erikburt erikburt self-assigned this Sep 12, 2025
@erikburt erikburt force-pushed the feat/codeowners-analysis branch 3 times, most recently from 9189ac8 to ef0ae7e Compare September 12, 2025 03:39
@erikburt erikburt force-pushed the feat/codeowners-analysis branch from ef0ae7e to 1746039 Compare September 12, 2025 03:42
@erikburt erikburt marked this pull request as ready for review September 12, 2025 21:44
@erikburt erikburt requested a review from a team as a code owner September 12, 2025 21:44
@erikburt erikburt requested a review from chainchad September 12, 2025 21:46
@erikburt erikburt force-pushed the feat/codeowners-analysis branch from 95a3c84 to 76392de Compare September 12, 2025 22:55
@chainchad chainchad requested a review from Copilot September 15, 2025 14:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new codeowners-review-analysis action that helps PR authors understand the CODEOWNERS review requirements for their changes by analyzing changed files against patterns and current review status.

  • Adds a complete GitHub Action that parses CODEOWNERS files and matches them against PR changed files
  • Implements CODEOWNERS pattern matching logic translated from the hmarr/codeowners Go library
  • Provides both workflow summary and optional PR comment outputs showing review status

Reviewed Changes

Copilot reviewed 22 out of 26 changed files in this pull request and generated no comments.

Show a summary per file
File Description
actions/codeowners-review-analysis/action.yml Action definition with post-comment input parameter
actions/codeowners-review-analysis/src/run.ts Main orchestration logic that coordinates file analysis and review status
actions/codeowners-review-analysis/src/codeowners-pattern.ts CODEOWNERS pattern matching implementation translated from Go
actions/codeowners-review-analysis/src/github-gql.ts GraphQL queries to fetch PR review status and decisions
actions/codeowners-review-analysis/src/strings.ts Markdown formatting functions for summary and PR comments
actions/codeowners-review-analysis/src/review-status.ts Review state management and precedence logic
actions/codeowners-review-analysis/src/github.ts REST API interactions for files, comments, and repository data
actions/codeowners-review-analysis/src/codeowners.ts CODEOWNERS file parsing and file-to-pattern matching
actions/codeowners-review-analysis/src/run-inputs.ts Input parsing and context validation
actions/codeowners-review-analysis/src/index.ts Entry point that calls the main run function
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (2)

actions/codeowners-review-analysis/src/run-inputs.ts:1

  • Typo in 'currrent' should be 'current'.
import * as core from "@actions/core";

actions/codeowners-review-analysis/src/run.ts:1

  • Typo in 'currrent' should be 'current'.
import * as github from "@actions/github";

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

on paths."

runs:
using: "node20"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
using: "node20"
using: node24

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not tested anything w/ node24 yet. Will leave this as node20 for now, and maybe we can update most of our actions to node24 in one big swoop.

@erikburt erikburt enabled auto-merge (squash) September 17, 2025 19:32
@erikburt erikburt merged commit 8f3a6ec into main Sep 17, 2025
19 checks passed
@erikburt erikburt deleted the feat/codeowners-analysis branch September 17, 2025 19:34
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.

4 participants