# 用 commit 生成編年史、構築世界再到多重宇宙 - 蕭晊莛(Jrting Shiau) {%hackmd @HWDC/BJOE4qInR %} >#### 》[議程介紹](https://hwdc.ithome.com.tw/2024/session-page/3167) >#### 》[填寫議程滿意度問卷|回饋建言給辛苦的講者](https://forms.gle/927LofdvsUKs2mja6) # 簡報網址 https://speakerdeck.com/neokn/from-commit-to-mulitverse ------------ ### conventional commits conventional 帶來的自動化 ...微服務 ### 不會講的 什麼是 conventional commits 什麼是 整合測試 什麼是 做好微服務 ## 開發會遇到的情況 1. bug 變 feature -> git blame 找到最後發現 (可能是自己寫的 ?) 2. 奇怪的 code 不敢動 - blame - fix issue 3. rollback - roll 回哪一版 ? ( last release ) K8s rollout undo deployment ... rollback 整個 service broken Service Mesh -> Service Creash 當工程師 好難 以上 -> commit 寫好都可以避免 ### Conventional Commits 每個commits 你期待看到什麼 5W1H Why is the change need ? What doee the commit aim to address Who -> git log When -> git log Where -> git log How -> git log Go Jira ### 解決大家認同的問題 commit 時加上 jira 編號 ex: HW-1012 add awesome feature 不過就是加個 Jira 能做什麼 ? 但現在有 convention ? Human Friendly & Matchine Readable -> machine can read -> automation #### commits 後 Jira 偵測到對應單號有新增 commits - Jira Web links - Git diff commit 冒號後面要空白 ### DevEx - 我們只改變 branch name ? - Feat/FT-1984-ooxx - 有 convention 就有自動化 - JetBrains Pluguib: Jira id commit message #### 如果是 test / try 的情況 還需要走 convention Option 2: 先merge 再檢查 ## 小結 - 建立 Convention 的時候一次不要太多 - 先解決最在乎的 Why , What - 盡量貼近成員現在的習慣降低摩擦力提升 DevEx ## 生成編年史 feat & fix ``` npx commit-and-tag-version ``` changelog.md Jira Link & Git diff Auto Semver Compare revisions v1.3.0 vs v1.2.0 ## 這樣真的完美了嗎 ? 訊息該怎麼寫 -> gitlabbot 有個容易檢視交付變化的地方 就會有人開始改變習慣 小小改變大 有自動化就不會改變大家的工作流程 CHANGELOG 很容易看出改變的過程 Continuous Integration -> Continuous 把 Image:Ver 帶入 structured logging 把 Service /Ver 帶入 request 在header 補上 User-Agent 讓 Service 知道是哪一個服 ## 小結 - 即使有貫穿Services 的 log tracing 還是不知道當下的版本 - 有 SemVer 能更貼近真實情況 - release 新版本以前能整合,要rollback - 在任何環境都能重現 ### 多重宇宙 用 docker compose After Semver: 很容易閱讀以及可以看出是否有 breaking change Local K3s CI docker compose Staging K8s Production K8s ### 總結 - 帶入convention 重在 why, what - 找到利大於弊的槓桿 - changelog 是一個方便查閱變更的地方 - 不用人工維護,commits 品質會更好
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up