Repository navigation
ci: keep the station copies in the commit that changes them - #294
Merged
Merged
Conversation
whes1015
force-pushed
the
ci/station-copies-in-pr
branch
from
October 11, 2026 16:22
0521dac to
35d5e39
Compare
Member
Author
|
在草稿 PR #295(疊在這個分支上,只改了
另外修正了一個問題:這個 PR 原本的 commit 訊息內文引用了 bot 的 commit 標題,裡面含有 |
station.csv and station.json are generated from their -dev files. The bot did that after a merge, pushing a "chore: update station.csv from station-dev.csv" commit straight to main with CI skipped, so every station fix landed as two commits: 95 of the last 300 on main were the bot's. Do it inside the pull request instead. When a same-repository pull request opens or moves, the bot reruns both generators in each of its commits, amends any copy that changed into that commit (author kept, committer github-actions[bot]) and pushes the branch back with a lease on the head it saw. The push goes out with PAT_TOKEN, because commits pushed with GITHUB_TOKEN start no workflow run and the required checks would never report. A rebase merge then lands one commit per change. A copy is still never written by hand, and that is now enforced before a merge instead of reverted after one. station-csv-check and station-json-check fail any pull request whose copy differs from what the generator makes of its -dev file. A pull request that leaves the copy alone passes even if it is stale: a fork gets no secrets, so the bot cannot push to it, and its copies are generated on main after the merge as before. On main, a copy that does not match is regenerated and pushed, which covers a direct push by a ruleset bypass actor. That replaces protect-station-*.yml, which let a hand edit merge and then force-pushed a revert to main, judging commits by author name and email: any GitHub noreply address passed, and a push with CI skipped in its message never ran it at all. All four workflows become one, so the two jobs cannot race to push to main. station-csv-check and station-json-check keep their names, which the ruleset requires, and pass a pull request that does not touch the -dev file or the copy, as before.
whes1015
force-pushed
the
ci/station-copies-in-pr
branch
from
October 11, 2026 16:45
35d5e39 to
87e2df2
Compare
Member
Author
|
補強副本的保護(已 force-push,commit 訊息同步更新):原本 PR 手改副本時檢查只發 warning,在 bot 改寫不了的情況下(fork、分支裡有 merge commit),手改的副本可以合併進 main。現在 在草稿 PR #296 實測,已關閉並刪除分支:
本機另外用從 workflow 抽出來的腳本測過:沒動到 station 檔、只改 dev(fork 的情況)、dev 加上產生的副本、dev 加上產生後又手改、dev 不合法,五種結果都符合預期。 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
這個 PR 做了什麼
讓 bot 把
station.csv/station.json這兩個副本直接改進 PR 自己的 commit,main 上不再出現 bot 補的chore: update station.csv from station-dev.csv [skip ci]。rebase 合併之後,每次修改就是一個 commit,跟 DPIP、TREM-Lite 一樣乾淨。目前前 300 個 commit 裡,有 95 個是 bot 補的副本 commit,每個
fix: station後面都跟著一個。流程
station-dev.*github-actions[bot]),再用--force-with-lease推回 PR 分支station-*-check失敗station-csv-check、station-json-check-dev檔和副本都沒動到就直接通過,跟以前一樣幾個設計上的重點:
station.yml。 以前 csv 和 json 兩個 job 都可能同時推 main,後推的那個會被拒絕;現在在同一個 job 裡依序處理。副本的保護
副本仍然只能是產生器的輸出,而且現在是合併前就擋下,不是合併後才 revert。判斷規則是看 PR 合併後的副本:
resource/station.csv。改變的是 git 紀錄。副本現在跟著貢獻者的 commit 進 main,所以
git log -- resource/station.csv看到的 author 是貢獻者,committer 才是github-actions[bot]。內容仍然百分之百由產生器產生。要讓 main 歷史乾淨,這一點沒辦法同時保留。還剩兩個管道能影響副本:
對貢獻者的影響
bot 改寫之後,PR 分支的 commit SHA 會變。用 GitHub 網頁編輯的不受影響;在本機繼續改的話,要先同步遠端:
怎麼驗
在 scratchpad 用這個 repo 的副本,模擬 bot 的 rebase(腳本是直接從
station.yml抽出來的那一段):station-dev.csv:無關那個 SHA 不變;改了 dev 的那個併入station.csv,作者仍是原作者。再跑一次,HEAD 不變,不會無限改寫。actionlint 1.7.12沒有警告。真正的「推回 PR 分支、PAT 觸發新 run」要在 GitHub 上才驗得到,我會另開一個草稿 PR 實測,結果補在下面的留言。