Upgrade to Pro — share decks privately, control downloads, hide ads and more …

GitLab CI 從團隊導入到運用

mouson(墨嗓)
September 27, 2020

GitLab CI 從團隊導入到運用

這份簡報分為兩個部分:

第一部分怎麼讓一個完全沒有原始碼版本控制的大型專案,逐步的轉變,陸續導入 GitLab 的各種功能,直到現在專案已經有了自己的 CI/CD 流程。這期間期間當然包含了一些政治面、商業面的因素,但整體經歷了哪些事情呢?在這部分會跟大家聊聊這段故事。

第二部分,在使用及導入 GitLab 的過程中,隨著專案演進 .gitlab.yml 定義的流水線 pipeline 上有越來越多工作,怎麼讓工作流程進行的更快一些呢?又,可以怎麼整理 .gitlab.yml 檔,讓他更簡潔一些?在這部分將跟大家分享一些小技巧。

內容中所用到的 source code 如下:
https://gitlab.com/mouson-gitlab-playground/gitlab-ci-demo-sample

可透過切換分支進行查看

mouson(墨嗓)

September 27, 2020
Tweet

More Decks by mouson(墨嗓)

Other Decks in Technology

Transcript

  1. ⽯器時代 - 考古遺跡 • PHP 4.1.2 / Apache 1.3 •

    單 PHP 原始碼超過 1,000隻,總⾏數超過 20 萬 • 核⼼為 C 編寫的 PHP Extension • 使⽤非常⾒的商⽤資料庫
  2. 銅器時代 - 時代記憶 • Issue Tracking System - Redmine •

    版本控制系統 - GitLab • 沒有系統⽂件 • 部分執⾏程式沒有原始碼
  3. 機器時代 - 考古遺跡 • 導入單元測試,以測試描述規格 • 導入 TDD 進⾏功能開發 •

    持續針對核⼼演算法重構、補上測試 • 透過 GitLab CI/CD 完成⾃動化測試 • 增加線上 Code Review 流程
  4. .gitlab-ci.yml Job Job Job Job Job Job Job Queue Runner

    Server Runner Server Runner Server Runner Runner Runner Runner
  5. .gitlab-ci.yml Job Job Job Job Job Job Job Queue Runner

    Server Runner Server Runner Server Runner Runner Runner Runner Run Job ____________________________
  6. ⼯作花太久時間等待進 Queue? • 套⽤ DAG 機制 (GitLab 12.2) build test

    deploy build_a test_a deploy_a build_b test_b deploy_b build_c test_c deploy_c build_b
  7. ⼯作花太久時間等待進 Queue? • 套⽤ DAG 機制 (GitLab 12.2) build test

    deploy build_a test_a deploy_a build_b test_b deploy_b build_c test_c deploy_c build_b
  8. ⼯作花太久時間等待進 Queue? • 套⽤ DAG 機制 (GitLab 12.2) build test

    deploy build_a test_a deploy_a build_b test_b deploy_b build_c test_c deploy_c build_b
  9. .gitlab-ci.yml Job Job Job Job Job Job Job Queue Runner

    Server Runner Server Runner Server Runner Runner Runner Runner
  10. Job Job Job Job Job Job Job Queue Runner Server

    Runner Server Runner Server Runner Runner Runner Runner
  11. Job Job Job Job Job Job Job Queue Runner Server

    Runner Server Runner Server Runner Runner Runner Runner
  12. •可以取得⼯作的 Runner 夠 嗎? Job Job Job Job Job Job

    Job Queue Runner Server Runner Server Runner Server Runner Runner Runner Runner
  13. •可以取得⼯作的 Runner 夠 嗎? •可以有更多 Runner 嗎? Job Job Job

    Job Job Job Job Queue Runner Server Runner Server Runner Server Runner Runner Runner Runner
  14. •可以取得⼯作的 Runner 夠 嗎? •可以有更多 Runner 嗎? •Runner Server 可以同步執

    ⾏ Runner 嗎? Job Job Job Job Job Job Job Queue Runner Server Runner Server Runner Server Runner Runner Runner Runner
  15. Job Job Job Job Job Job Job Queue Runner Server

    Runner Server Runner Server Runner Runner Runner Runner
  16. Job Job Job Job Job Job Job Queue Runner Server

    Runner Server Runner Server Runner Runner Runner Runner Run Job ____________________________
  17. Runner Server Runner Server Runner Server Runner Runner Runner Runner

    Run Job ____________________________ * pull docker image
  18. Runner Server Runner Server Runner Server Runner Runner Runner Runner

    Run Job ____________________________ * pull docker image * git repo fetch
  19. Runner Server Runner Server Runner Server Runner Runner Runner Runner

    Run Job ____________________________ * pull docker image * git repo fetch * package install
  20. Runner Server Runner Server Runner Server Runner Runner Runner Runner

    Run Job ____________________________ * pull docker image * git repo fetch * package install * download artifacts
  21. Runner Server Runner Server Runner Server Runner Runner Runner Runner

    Run Job ____________________________ * pull docker image * git repo fetch * package install * download artifacts * script execute
  22. Runner Server Runner Server Runner Server Runner Runner Runner Runner

    Run Job ____________________________ * pull docker image * git repo fetch * package install * download artifacts * script execute •Network Performance ?
  23. Runner Server Runner Server Runner Server Runner Runner Runner Runner

    Run Job ____________________________ * pull docker image * git repo fetch * package install * download artifacts * script execute •Network Performance ? •Docker image size ?
  24. Runner Server Runner Server Runner Server Runner Runner Runner Runner

    Run Job ____________________________ * pull docker image * git repo fetch * package install * download artifacts * script execute •Network Performance ? •Docker image size ? •Git Repo Size ?
  25. Runner Server Runner Server Runner Server Runner Runner Runner Runner

    Run Job ____________________________ * pull docker image * git repo fetch * package install * download artifacts * script execute •Network Performance ? •Docker image size ? •Git Repo Size ? •Programming Language Dependence Package Size ?
  26. Runner Server Runner Server Runner Server Runner Runner Runner Runner

    Run Job ____________________________ * pull docker image * git repo fetch * package install * download artifacts * script execute •Network Performance ? •Docker image size ? •Git Repo Size ? •Programming Language Dependence Package Size ? •Artifacts Size ?
  27. Runner Server Runner Server Runner Server Runner Runner Runner Runner

    Run Job ____________________________ * pull docker image * git repo fetch * package install * download artifacts * script execute •Network Performance ? •Docker image size ? •Git Repo Size ? •Programming Language Dependence Package Size ? •Artifacts Size ? •Script Performance ?
  28. Runner Server Runner Server Runner Server Runner Runner Runner Runner

    Run Job ____________________________ * pull docker image * git repo fetch * package install * download artifacts * script execute
  29. .gitlab-ci.yml Job Job Job Job Job Job Job Queue Runner

    Server Runner Server Runner Server Runner Runner Runner Runner Run Job ____________________________ * pull docker image * git repo fetch * package install * download artifacts * script execute
  30. Recap • 第⼀招:利⽤ default stage 整理所有 job 都共同的 • 第⼆招:萃取出變數

    • 第三招:利⽤ .hidden 建立模板⼯作,並⽤繼承使⽤ • 第四招:利⽤ Parallel Matrix 功能 • Sample Source Code: https://bit.ly/3mTiBgJ