ããã«ã¡ã¯ã SRE ã® @suzuki-shunsuke ã§ãã Terraform Monorepo ã«å¯¾ãã Renovate ã®å¤§éã® Pull Request ãå¦çããããã®æè¡ã«ã¤ãã¦ç´¹ä»ãã¾ãã
èæ¯
éå»ããã°ã§ä½åº¦ãç´¹ä»ãã¦ããããã«ãå¼ãããã¯ãã§ã¯ Terraform ã® Monorepo ã管çãã¦ãã¾ãã å æ¥ã CI ã AWS CodeBuild ãã GitHub Actions + tfaction ã«ç§»è¡ãã¾ããã
working directory (state) ã®æ°ã¯ 400 è¿ãããã working directory ãã¨ã«ä»¥ä¸ã®ãã㪠tool ã®ãã¼ã¸ã§ã³ã管çãã¦ãã¾ãã
ãã以å¤ã«ã tfcmt ãªã©ã® tool ã®ãã¼ã¸ã§ã³ã¯ãªãã¸ããªåä½ã§ç®¡çãã¦ãã¾ãã
Renovate ã¯ããã©ã«ãã§ã¯åããã¼ã«ãä¸ã¤ã® Pull Request 㧠update ãã¾ããã additionalBranchPrefix ãè¨å®ãããã¨ã§ working directory ãã¨ã« Pull Request ãåããããã«ãã¦ãã¾ãã ããããã¨ãããã¼ã«ã update ããã㨠400 è¿ã Pull Request ããã¼ã¸ããå¿ è¦ãåºã¦ãã¾ãã Terraform ã® AWS Provider ãªã©ã¯æ¯é± update ãããã¾ããã Terraform æ¬ä½ãããããã®é »åº¦ã§ update ãããã¾ãã ãã®ãããªå¤§éã® Pull Request ã人éãä¸ã¤ä¸ã¤ã¬ãã¥ã¼ããã®ã¯å¤§å¤ã§ãããå´åã«è¦åãã¾ããã ãã®ããã tflint ãªã©ã® CI ãæåãã¦ãããã㤠terraform plan ã®çµæã No change ã§ããå ´åã¯ãèªå㧠merge ããããã¨ãæã¾ããã§ãã ä¸æ¥ãããã«ãã¼ã¸ã§ãã Pull Request ã®æ°ãå°ãªã㨠Pull Request ãå¦çããããªããªãããã¤ã¾ã§çµã£ã¦ã update ãããªããããªç¶æ ã«ããªã£ã¦ãã¾ãããã大éã® Pull Request ãçæéã§å¦çã§ããå¿ è¦ãããã¾ããã
解決æ¹æ³
- automerge ãæå¹ã«ãã
- platformAutomerge ãæå¹ã«ãã
- prHourlyLimit ã 0 ã«ãã
- prConcurrentLimit 㯠5 ã«å¶éãã
- base branch ã update ãã㦠automerge ã disabled ã«ãªã£ãããèªå㧠feature branch ã update ã㦠automerge ã enabled ã«ãã
- CI ã失æãããç´ãã« PR ã close ãã¦ãã©ã³ããåé¤ãã
- Terraform ã Terraform Provider 以å¤ã® update ã§ã¯ terraform plan, apply ã skip ãã
- Renovate Approve ã ãã§ãªãã Renovate Approve 2 ã install ãããã¨ã§ã approve æ¼ããé²ã
- Terraform ã AWS Provider ã®ãããªæ´æ°é »åº¦ãå¤ãã working directory ãã¨ã«ãã¼ã¸ã§ã³ç®¡çãã¦ãããã®ã® prPriority ãä¸ãã
- tfaction ã® inputs ã®
github_token
ããsecrets.GITHUB_TOKEN
ãã GitHub App ã® token ã«åãæ¿ãã rate limit ãé²ã
automerge ãæå¹ã«ãã
automerge ãæå¹ã«ãããã¨ã§ Renovate ãèªåã§ãã¼ã¸ãã¦ããã¾ãã approve ãå¿ è¦ãªå ´åã Renovate approve ã¨ãã GitHub App ã使ããã¨ã§èªåååºæ¥ã¾ãã
ãããã automerge ã«ãããã¼ã¸ã«ã¯çµæ§æéãããããã¨ãç¥ããã¦ãã¾ãã æ°æéããããã¨ãããã¾ãã ããã§ã platformAutomerge ãæå¹ã«ãã¾ãã
platformAutomerge ãæå¹ã«ãã
platformAutomerge ãæå¹ã«ããã¨ã GitHub ã®å ´å Automerge ãæå¹ã«ãããæ¡ä»¶ãæºããããç´ãã«ãã¼ã¸ããã¾ãã
GitHub ã® Automerge ã®æ³¨æç¹
ãã ãã GitHub ã® Automerge ã«ã¯æ³¨æãå¿ è¦ã§ãããæ°ãã¤ããªã㨠CI ã失æãã¦ããã®ã« Pull Request ããã¼ã¸ããã¦ãã¾ãã¾ãã
- ãªãã¸ããªã®è¨å®ã§ Allow auto-merge ãæå¹åããå¿ è¦ããã
- base branch ã« Branch Protection Rule ãè¨å®ããå¿
è¦ããã
Status checks that are required.
㧠status checks ãé¸æãããä¸ã¤ãé¸æããªãã¨ã Automerge ãæå¹åã§ããªã
Status checks that are required.
ã§ãã§ãã¯ãããã®ä»¥å¤ã失æãã¦ãã¦ã Pull Request ã¯ãã¼ã¸ããã¦ãã¾ããã¨ã«æ°ãã¤ãã¦ãã ããã
GitHub Actions ã® job ã if 㧠skip ããã¦å®è¡ããã¦ãªãå ´åããã¼ã¸ãããããã§ãã
å¼ãããã¯ãã§ã¯ tfaction ã«ãã£ã¦è¤æ°ã® state ã«å¯¾ãã CI ã build matrix ã§å®è¡ãã¦ãã¾ãããããã«ããå®è¡ããã job ãåçã«å¤ããããã Status checks that are required.
ã«è¨å®ããã®ãé£ããã¨ããåé¡ãããã¾ãã
ãã㧠build matrix ã«ä¾åãã job ã追å ãããã® job ã Status checks that are required.
ã«è¿½å ãã¦ãã¾ãã
ãã以å¤ã® workflow ã失æãã¦ããã¼ã¸ããã¦ãã¾ãã¾ãããæ» å¤ã«ãã®ãããªãã¨ã¯èµ·ãããªãããèµ·ãã£ãã¨ãã¦ãç´ãã°ããã®ã§è¨±å®¹ãã¦ãã¾ãã
prHourlyLimit ã 0 ã«ãã
Renovate ã«ã¯ Pull Request ä½æãå¶éããå¹¾ã¤ãã® Limit ãããã¾ãã 注æãå¿ è¦ãªã®ã¯ã default ã§ç¡å¶éã§ãã£ã¦ãã config:base ã¨ãã Preset ã§å¶éããã¦ããå ´åãããã¾ãã
config | default | config:base |
---|---|---|
prHourlyLimit | 0 | 2 |
prConcurrentLimit | 0 | 10 |
branchConcurrentLimit | prConcurrentLimit |
prHourlyLimit 㯠config:base
㧠2 ã«å¶éããã¦ããã 1 æéã« 2 ã¤ãã Pull Request ãä½ãããªããã¨ã«ãªã£ã¦ãã¾ãã
ãªã®ã§æ示çã« 0 ã«è¨å®ããç¡å¶éã« Pull Request ãä½ãããããã«ãã¾ãã
prConcurrentLimit 㯠5 ã«å¶éãã
Renovate ã¯ä¸è¨ã®å¶éå ã§ä½ããã ã Pull Request ãä½ããã¨ãã¾ãã Terraform ã® CI 㧠terraform plan, apply ãå®è¡ããå ´åãåæã«å¤§éã«å®è¡ããã¨é«ç¢ºç㧠API ã® rate limit ã«å¼ã£ãããã¾ãã ã¾ãã GitHub ã® Automerge 㯠base branch ãæ´æ°ãããã¨èªå㧠disable ããããã¨ãããã¾ãã
ãã®ããã prConcurrentLimit ã 5 ã«å¶éãã¦ãã¾ãã
branchConcurrentLimit ãå¶éãã
branchConcurrentLimit ã¯ãã©ã³ãã®æ°ã«ããå¶éã§ããå¥ã« branch ã®æ°ã§å¶éããå¿ è¦æ§ã¯ãªãã®ã§ã¯ã¨æã£ã¦ä¸åº¦ 0 ã«ãã¦ã¿ã¾ããããããã¯å¤±æã§ããã Pull Request ã¯ä½æãããªãã¦ã branch ã¯ä½æãããããã§ã 1000 以ä¸ã® branch ãç¡é§ã«ä½ããã¦ãã¾ãã¾ããã branchConcurrentLimit ã¯ããã©ã«ã㧠prConcurrentLimit ã¨åãã«ãªãã®ã§ã prConcurrentLimit ã ãæ示çã«è¨å®ã branchConcurrentLimit ã¯è¨å®ããªãããã«ãã¾ããã
CI ã失æãããç´ãã« PR ã close ãã¦ãã©ã³ããåé¤ãã
prConcurrentLimit, branchConcurrentLimit ãå¶éãã¦ãã以ä¸ã Renovate ã® Pull Request ã open ããã¾ã¾ã«ãã¦ããã¨ãæ°ãã«ä½æããã Pull Request ã®æ°ãå¶éããã¦ãã¾ãã¾ãã ããã§ã automerge ã§ããªãã£ã Pull Request ã close ããããã«ãããã©ã³ããåé¤ããããã«ãã¾ããã
README ã®ãµã³ãã«ã«ããããã«ã 15 åããã« workflow ãå®è¡ãã 10 å以ä¸åã«ä½æããã pull request ã close ãã¦ãã¾ãã
Close ãã Pull Request ã®ä¸è¦§ã¯ç°¡åãªã¯ã¨ãªã§åãã¾ããã Renovate ã® Dependency Dashboard ã«ãåºã¦ããã®ã§ãå¾ã§ç¢ºèªãã¦å¯¾å¿ããããã«ãã¦ãã¾ãã
is:pr is:unmerged author:app/renovate
base branch ã update ãã㦠automerge ã disabled ã«ãªã£ãããèªå㧠feature branch ã update ã㦠automerge ã enabled ã«ãã
GitHub ã® Automerge 㯠base branch ãæ´æ°ãããã¨èªå㧠disable ããã¦ãã¾ããã¨ãããã¾ãã
ããã§ã disable ããã event ãå ã« GitHub Actions ã® Workflow ãå®è¡ãã èªå㧠Pull Request ã® feature branch ã update ã㦠automerge ã enabled ã«ããããã«ãã¾ããã
Terraform ã Terraform Provider 以å¤ã® update ã§ã¯ terraform plan, apply ã skip ãã
tfaction ã§ã¯ terraform apply ã«ãã£ã¦å±éºãªå¤æ´ããããªãããã Renovate ã® Pull Request 㧠terraform plan ã®çµæã No Change ãããªãå ´åã CI ã失æããããã«ãªã£ã¦ãã¾ãã ãããããããã¨ããã blocker ã«ãªã£ã¦ tfsec ã tflint ã¨ãã£ããã¼ã«ã update ã§ããªããã¨ãããã¾ããã
æ¬æ¥ tfsec ã tflint 㯠terraform plan, apply ã¨ã¯ç¡é¢ä¿ã§ããããã update ããéã« terraform plan, apply ãå®è¡ããå¿ è¦ã¯ãªãã¯ãã§ãã
tfaction v0.4.9 ãã Renovate ã® Pull Request 㧠terraform plan, apply ã skip ã§ããããã«ãªã£ãã®ã§ãããã使ã£ã¦ãã¾ãã
terraform ã terraform provider ã® update ã§ã¯ plan, apply ãå®è¡ãããã以å¤ã® update ã§ã¯ skip ããããã«ãã¦ãã¾ãã ãããããã¨ã§ terraform plan ã®çµæã«ãã£ã¦ block ãããªããªãã ãã§ãªãã CI ãæ©ããªãã¾ãã API rate limit ã«ãå¼ã£ããããªããªãã¾ãã
Renovate Approve ã ãã§ãªãã Renovate Approve 2 ã install ãããã¨ã§ã approve æ¼ããé²ã
ãã¾ã«ã§ããã Renovate Approve ããªãã approve ãã¦ãããªããã¨ãããã¾ãã 1 approve ãå¿ é ã«ãã¦ããããã approve ãããªãã¨èªåã§ãã¼ã¸ãããã¾ããã ãã㧠Renovate Approve 2 ã¨ãã GitHub App ã install ãããã¨ã§ã approve æ¼ããèµ·ããã«ãããã¾ããã ãã® App ã¯æ¬æ¥ 2 approve ãå¿ è¦ãªå ´åã«ä½¿ããã®ã ã¨æãã¾ããã approve æ¼ããé²ãã®ã«ã使ãããã¨æãã¾ãã ä»ã®æ Renovate Approve 2 ãã¤ã³ã¹ãã¼ã«ãã¦ãã approve æ¼ãã¯èµ·ãã£ã¦ãã¾ããã
æ´æ°é »åº¦ãå¤ãã working directory ãã¨ã«ãã¼ã¸ã§ã³ç®¡çãã¦ãããã®ã® prPriority ãä¸ãã
Terraform ã AWS Provider ã®ããã«æ´æ°é »åº¦ãå¤ããã㤠working directory ãã¨ã«ãã¼ã¸ã§ã³ç®¡çãã¦ãããã®ã¯ä»ã®ãã¼ã«ã® update ãé·ãé block ãã¦ãã¾ããã¨ãããã¾ãã ããã§ãããã£ããã¼ã«ã® prPriority ãä¸ããããããã¯ãã以å¤ã® prPriority ãä¸ãããã¨ã«ãã£ã¦ block ãããã®ãé²ããã¨ãåºæ¥ã¾ãã
tfaction ã® inputs ã® github_token
ãã secrets.GITHUB_TOKEN
ãã GitHub App ã® token ã«åãæ¿ãã rate limit ãé²ã
tfaction ã®å¹¾ã¤ãã® action 㯠input ã¨ã㦠GitHub Access Token ã渡ããã®ãããã¾ãã
ããã©ã«ãã§ã¯ secrets.GITHUB_TOKEN
ã使ããã¾ããã 1 æéãããã® CI ã®åæ°ãå¢ãã㨠rate limit ã«å¼ã£ãããå¯è½æ§ãããã¾ãã
ãã㧠secrets.GITHUB_TOKEN
ããã rate limit ãå³ãããªã GitHub App ã® token ã«åãæ¿ãã¾ããã
åãæ¿ããé㯠GitHub App ã® permission ãä¿®æ£ãããã¨(issues: read ãå¿
è¦ã«ãªãã¯ã)ã¨ã github-comment hide ã§å¤ãã³ã¡ã³ããé表示ã«ãã¦ããå ´åã¯ãã¡ãã® GitHub Access Token ãåãæ¿ããå¿
è¦ãããã¾ã(github-comment hide ã¯åãã¦ã¼ã¶ã¼ã®ã³ã¡ã³ãããé表示ã«ããªããã)ã
- https://docs.github.com/en/rest/overview/resources-in-the-rest-api#requests-from-github-actions
- https://docs.github.com/en/developers/apps/building-github-apps/rate-limits-for-github-apps
çµæ
ä¸è¨ã®ãããªå¯¾å¿ãè¡ã£ãçµæãå¤ãã¨ãã«ã¯ 1 ã¤ã®ãªãã¸ããªã« 1 æ¥ã« 500 è¿ã Pull Request ãä½æã»ãã¼ã¸ãããã¨ãã§ããããã«ãªãã¾ããã ãã® 500 ã¨ããæ°åã¯ã¾ã æ¹åã®ä½å°ãããã¾ã(æ大 700 ãããã¯ãããæ°ããã¾ã)ããããã§ãç¾ç¶ååãªå¦çè½åã§ãã ä»ã¾ã§ã¯ open ãªã¾ã¾ã® Pull Request ãæã ãã§ãã¯ãã¦å¯¾å¿ããããã¦ã¾ãããã èªååã§ããé¨åã¯èªååãããã¨ã«ãã£ã¦æ¬å½ã«äººéã対å¿ããªãã¨ãããªãå ´åã®ã¿å¯¾å¿ããã°ãããªããè² æ ãæ¸ãã¾ããã
ãããã«
以ä¸ã Renovate ã«ãã£ã¦å¤§éã® Pull Request ãä½æããèªåã§å¦çããæè¡ãç´¹ä»ãã¾ããã
We are hiring!
ã¹ã¿ãã£ãµããªå°ã»ä¸ã»é«æ ¡è¬åº§ã大å¦åé¨è¬åº§ã§ã¯ã æè²ãµã¼ãã¹ãæ¹é©ããèªå·±å®çµåãã¼ã ãå®ç¾ãã SRE ãåéãã¦ãã¾ãã
ã¾ããæè¿ Security ã«ç¹åãããã¸ã·ã§ã³ããªã¼ãã³ããã®ã§ãã¡ãããããããããããã¾ãã