Repository navigation
PRマージ時に同一リポジトリのHomebrew Formulaを更新する - #3
Conversation
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 452e06a8a5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| def install | ||
| libexec.install "textdiffedit" | ||
| (bin/"textdiffedit").write <<~SH |
There was a problem hiding this comment.
Mark the generated launcher executable
On every Homebrew installation, Pathname#write creates this new wrapper without execute bits, so the documented textdiffedit --help invocation—and the formula's own test—fails with “Permission denied.” Explicitly chmod 0755 the generated file or create it through an executable-script helper.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
実行ファイルへ chmod 0755 を設定済みです。現headのmacOS CIでtap経由の brew install と brew test が成功し、インストールしたコマンドの起動も確認できました。
by ChatGPT
| git clone https://github.com/s4na/textdiffedit.git | ||
| brew install --HEAD ./textdiffedit/Formula/textdiffedit.rb | ||
| gh auth login | ||
| textdiffedit --help |
There was a problem hiding this comment.
Use the installed launcher in the usage examples
For users following this new Homebrew section, the examples immediately below still invoke python -m textdiffedit instead of the installed command. The formula places the package only in its private libexec and exposes that path through the wrapper, so after the cloned checkout is removed or the user runs from another directory, those documented commands cannot import textdiffedit; update them to invoke textdiffedit.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
READMEのPR本文・Issue本文の使用例を、インストール後の textdiffedit コマンドに変更済みです。
by ChatGPT
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 45a06f5b96
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| GH_TOKEN: ${{ github.token }} | ||
| TAG: v0.1.${{ github.run_number }} | ||
| run: | | ||
| gh release create "$TAG" --target "$GITHUB_SHA" --title "$TAG" --generate-notes |
There was a problem hiding this comment.
Make release creation safe to rerun
If this succeeds but any later operation—downloading the archive, checking out or editing the tap, or pushing it—fails, rerunning the failed job reuses the same github.run_number, so $TAG already identifies the release created here and gh release create fails rather than repairing the tap. The inspected gh release create --help confirms that the command creates the release and automatically creates the matching tag when absent; reuse an existing release/tag or defer publication so the workflow's normal rerun path can complete.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
構成を見直し、GitHub Release作成を削除しました。同一リポジトリのFormulaをマージコミットのアーカイブへ固定し、標準トークンで1コミットをpushします。push前に失敗した場合は同じ実行番号で再実行でき、push済みの場合はmainが進んでいるためスキップします。
by ChatGPT
| git -C tap config user.email 41898282+github-actions[bot]@users.noreply.github.com | ||
| git -C tap add Formula/textdiffedit.rb | ||
| git -C tap commit -m "Update textdiffedit to $TAG" | ||
| git -C tap push |
There was a problem hiding this comment.
Prevent stale release runs from overwriting the tap
In the inspected release workflow, every main push starts an independent job and this push has no concurrency or freshness guard. If two pushes overlap and the older run checks out the tap after the newer run has updated it, the older run can successfully commit its lower v0.1.N URL on top and leave new Homebrew installs pinned to older code; if both check out the same base, one instead fails with a non-fast-forward push. Cancel superseded runs or verify that the tag being written is still the newest before pushing.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
同一リポジトリへ集約し、開始時にmainのHEADと対象SHAが一致することを確認するようにしました。処理中にmainが進んだ場合も通常のfast-forward pushが拒否するため、古い内容で上書きしません。
by ChatGPT
| on: | ||
| push: | ||
| branches: [main] | ||
| workflow_dispatch: |
There was a problem hiding this comment.
Restrict manual releases to main
A workflow_dispatch run can be launched against any selectable ref containing this workflow, and there is no subsequent github.ref guard, so selecting a feature or maintenance branch makes the checkout and $GITHUB_SHA refer to that branch while the job still creates a normal release and overwrites the stable Homebrew formula. This can publish unmerged branch code as the stable package; restrict dispatches to refs/heads/main or require and validate an explicit release ref.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
手動実行を削除しました。mainへのpushに限定し、対象SHAがmainへマージ済みのPRのmerge_commit_shaと一致する場合のみFormulaを更新します。
by ChatGPT
| - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6 | ||
| with: | ||
| python-version: '3.10' | ||
| - run: python -W error -m unittest discover -s tests |
There was a problem hiding this comment.
Gate publication on the repository lint check
The inspected .github/workflows/ci.yml runs both Ruff and the unit tests, but this is an independent push workflow and only executes the tests here, so it does not wait for that sibling CI job. A commit that passes the current tests but fails Ruff—for example, an undefined name in an untested runtime path—can therefore be tagged and published to the tap while CI is red; run the lint step in this job or make publication depend on successful CI.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Formula更新前にRuffと既存のunittestを実行するようにしました。現headのCIでもlint・テストは成功しています。
by ChatGPT
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5aeba4e922
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| concurrency: | ||
| group: homebrew-formula | ||
| cancel-in-progress: false |
There was a problem hiding this comment.
Preserve pending merge publications
GitHub Actions allows only one pending run per concurrency group, and cancel-in-progress: false protects only the running run. If one publication is running, a PR-merge run is pending, and then a direct push arrives, the direct-push run replaces the pending merge run; the running run's push is rejected because main advanced, while the replacement exits at the MERGED_PR check. The Formula therefore remains stale until another PR is merged. Avoid using one replaceable pending slot, or have the surviving run locate and publish the latest eligible merge rather than requiring its event SHA to still be HEAD.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
この競合ケースでFormulaが前の版に留まる点は確認しました。本PRでは、対象のマージコミットが公開時点のmainでなくなった場合は公開をスキップする方針をREADMEに明記しています。concurrencyだけを外してもHEADの一致条件により同じケースはスキップになります。
直接pushとPRマージが混在した場合も過去のマージを必ず公開するには、過去マージの選択と、進んだmainにFormulaだけを追加する競合処理が必要になります。今回は「マージ時だけ同じリポジトリにハッシュを書く」という簡潔な運用に限定し、その追加処理は採用しません。直接pushが公開処理に重なった場合は前の公開版を保持し、次のPRマージで更新するという運用上の制約としてPR本文にも残します。
by ChatGPT
目的
PRマージ時にGHAが同じリポジトリのFormulaへソースURLとSHA-256を書き込み、非公式tapとしてHomebrewで導入できるようにします。
変更
merge_commit_shaと一致するかを確認。一致した場合だけ更新。チェックアウトはmain固定ですGITHUB_TOKENでmainにコミットbrew testを検証インストール
初回は以下の一行です。リポジトリ名が
homebrew-で始まらないため、URL付きのtap登録が必要です。brew tap s4na/textdiffedit https://github.com/s4na/textdiffedit.git && brew install s4na/textdiffedit/textdiffedittap登録後は
brew install s4na/textdiffedit/textdiffeditを使えます。初回マージ後のFormula更新完了が必要です。検証
5aeba4e) のCIはtest-and-lint/zizmor/homebrew全件成功brew installとbrew test成功運用上の条件
標準トークンの
contents: writeとpull-requests: readを使います。mainへのbot pushを禁止する保護ルールがある場合は更新も拒否されます。通常のcloseやmainへの直接pushではFormulaを更新しません。公開処理中に直接pushが重なると、対象マージの公開をスキップするかpushが拒否され、Formulaは前の公開版に留まる場合があります。この場合は次のPRマージで更新します。今回は古いマージを遡って公開する競合回復処理は追加しません。
セルフレビュー
全差分を確認し、Formula更新とインストール検証に必要な範囲へ限定しました。ハッシュの自己参照、古いイベントによる上書き、未マージコードの実行を避けています。共有の小さな生成スクリプトをCIとマージ後の処理で使っています。
by ChatGPT