Skip to content

workflows: add per-formula command-not-found DB entry update#272976

Open
ooye-sanket wants to merge 4 commits intoHomebrew:mainfrom
ooye-sanket:add-command-not-found-db-entry-workflow
Open

workflows: add per-formula command-not-found DB entry update#272976
ooye-sanket wants to merge 4 commits intoHomebrew:mainfrom
ooye-sanket:add-command-not-found-db-entry-workflow

Conversation

@ooye-sanket
Copy link
Copy Markdown

@ooye-sanket ooye-sanket commented Mar 18, 2026

Implements the approach discussed in Homebrew/brew#20752.

Replaces the daily batch brew which-update job with a lightweight per-formula workflow that triggers on each push to main that touches a formula file.

For each changed formula it:

  1. Reads sh.brew.path_exec_files from the bottle manifest
  2. Pulls executables.txt via oras
  3. Updates only that formula's single line or removes it if the formula is disabled, deprecated, or deleted
  4. Pushes the updated file back via oras

Key design decisions:

  • cancel-in-progress: false so rapid merges queue rather than clobber each other (per Rylan12's spec in Remove brew which-update brew#20752)
  • Uses github.sha^..github.sha diff-tree range to correctly handle merge commits
  • No-ops if the formula's entry is already up to date

Partial implementation of Homebrew/brew#20752 brew which-update removal in homebrew/brew is a separate follow-up.

@MikeMcQuaid can you please review it!!

  • Have you followed the guidelines for contributing?
  • Have you ensured that your commits follow the commit style guide?
  • Have you checked that there aren't other open pull requests for the same formula update/change?
  • Have you built your formula locally with HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>, where <formula> is the name of the formula you're submitting?
  • Is your test running fine brew test <formula>, where <formula> is the name of the formula you're submitting?
  • Does your build pass brew audit --strict <formula> (after doing HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>)? If this is a new formula, does it pass brew audit --new <formula>?

  • AI was used to generate or assist with generating this PR. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes.

@ooye-sanket ooye-sanket requested review from a team and MikeMcQuaid as code owners March 18, 2026 13:30
@github-actions github-actions Bot added automerge-skip `brew pr-automerge` will skip this pull request workflows PR modifies GitHub Actions workflow files labels Mar 18, 2026
Comment thread .github/workflows/command-not-found-db-entry.yml Fixed
Copy link
Copy Markdown
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Great work so far @ooye-sanket!

Comment thread .github/workflows/command-not-found-db-entry.yml Outdated
Comment thread .github/workflows/command-not-found-db-entry.yml Outdated
Comment thread .github/workflows/command-not-found-db-entry.yml Outdated
Comment thread .github/workflows/command-not-found-db-entry.yml Outdated
Comment thread .github/workflows/command-not-found-db-entry.yml Outdated
@ooye-sanket
Copy link
Copy Markdown
Author

Thanks for the review @MikeMcQuaid! I've addressed all the feedback:

  • Moved all the shell logic into a new brew which-entry command in
    homebrew/brew: Add which entry command brew#21790
  • Replaced custom git diff-tree logic with brew test-bot --only-formulae-detect
  • Simplified all if: conditions to single lines
  • Removed run: | where possible
  • Fixed zizmor template injection by moving ${{ }} expressions to env: vars
  • Added missing newline at end of file

Copy link
Copy Markdown
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Looks better! Let's get Homebrew/brew#21790 merged first.

Comment thread .github/workflows/command-not-found-db-entry.yml Outdated
@ooye-sanket
Copy link
Copy Markdown
Author

@MikeMcQuaid Added the has-changes boolean step as suggested — all 5 repeated if: conditions now reference steps.has-changes.outputs.result == 'true'. All CI checks are passing. Ready for re-review!

@ooye-sanket ooye-sanket requested a review from MikeMcQuaid April 13, 2026 08:30
Copy link
Copy Markdown
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Thanks @ooye-sanket, let's try this out!

@MikeMcQuaid MikeMcQuaid requested a review from Rylan12 April 14, 2026 13:47
Copy link
Copy Markdown
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Actually holding merge until https://github.com/Homebrew/brew/pull/21790/changes is in!

Copy link
Copy Markdown
Member

@Rylan12 Rylan12 left a comment

Choose a reason for hiding this comment

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

This seems good as a first pass to me, and I think we can merge this.

I wonder if a different approach could be even better:

Instead of having this run as its own job, what if we tack this on to the publish-commit-bottles.yml job. That job already runs pr-pull to download the bottles, so I wonder if we could use actions/cache or actions/upload to very easily transfer those to a separate job that updates the actual executables file in ORAS.

Since we'd already have the bottle manifest available, we could probably skip the ruby command and just use bash's sed and sort.

shasum --algorithm=256 executables.txt > executables.txt.sha256
rm -f executables.txt
oras pull ghcr.io/homebrew/command-not-found/executables:latest
shasum --algorithm=256 --check executables.txt.sha256
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@ooye-sanket
Copy link
Copy Markdown
Author

@Rylan12 Thanks! I'll add the delete-old-versions job. Should I model it exactly after the existing job in command-not-found-db-update.yml#L81-94, or adapt it to run only for the changed formulae?

@MikeMcQuaid
Copy link
Copy Markdown
Member

Instead of having this run as its own job, what if we tack this on to the publish-commit-bottles.yml job. That job already runs pr-pull to download the bottles, so I wonder if we could use actions/cache or actions/upload to very easily transfer those to a separate job that updates the actual executables file in ORAS.

Agreed with putting in an existing job.

I don't feel strongly about whether it's Ruby or Bash. Unless the Bash is very very simple Ruby is probably preferable.

@Rylan12
Copy link
Copy Markdown
Member

Rylan12 commented Apr 18, 2026

@Rylan12 Thanks! I'll add the delete-old-versions job. Should I model it exactly after the existing job in command-not-found-db-update.yml#L81-94, or adapt it to run only for the changed formulae?

I think it only needs to run if the executables file actually gets an update pushed to github packages, but it should run every time that happens

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge-skip `brew pr-automerge` will skip this pull request workflows PR modifies GitHub Actions workflow files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants