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

ソフトウェア工学14 CI CD

ソフトウェア工学14 CI CD

CI/CD

継続的インテグレーション,継続的デリバリ,継続的デプロイ,DevOps,GitHub,Heroku,webアプリ

99b434b001cd93fe73322f764d73372c?s=128

Toru Tamaki

August 05, 2021
Tweet

Transcript

  1. ιϑτ΢ΣΞ޻ֶ nCI/CD • ܧଓతΠϯςάϨʔγϣϯɼܧଓతσϦόϦɼܧଓతσϓϩ ΠɼDevOpsɼGitHubɼHerokuɼwebΞϓϦ ۄ໦పʢ໊޻େʣ

  2. αΠΫϧΛ൐͏։ൃ

  3. ୅දతͳ։ൃϓϩηε nҰํ௨ߦͷ։ൃ • Ϟσϧ • ΢ΥʔλʔϑΥʔϧ • Vࣈ • ্ྲྀ͕ԼྲྀʹӨڹ

    • ऴΘΔ·Ͱ࢝ΊΒΕͳ͍ • ஗ΕͨΒ͠Θدͤ nαΠΫϧΛ൐͏։ൃ • Ϟσϧ • ϓϩτλΠϐϯά • εύΠϥϧ • ΞδϟΠϧ • ޻ఔΛԿ౓΋܁Γฦ͢ • ސ٬ͷҙݟΛ֬ೝ͠औΓೖΕΔ • ސ٬ʹ్தͷ੒Ռ෺ΛݟͤΔ • ϓϩτλΠϓ • ϞοΫΞοϓʢϞοΫʣ • ސ٬ͱͷ৴པؔ܎Λங͘
  4. γεςϜ։ൃΛӡ༻·ͰϧʔϓԽ͢Δ n։ൃϧʔϓ • ίʔσΟϯάɼϏϧυɼςετɼσϦόϦʢೲ඼ʣɾσϓϩΠʢӡ༻ʣ • ޮ཰ͷѱ͍෦෼ • Ϗϧυͱςετʹਓख͕͔͔Δ • σϓϩΠͷͨΊʹ࣮ՔಇγεςϜΛࢭΊͯߋ৽͠ͳ͚Ε͹ͳΒͳ͍

    nվળࡦ • ϏϧυͱςετͷࣗಈԽɿܧଓతΠϯςάϨʔγϣϯʢCIʣ • σϦόϦɾσϓϩΠͷࣗಈԽɿܧଓతσϦόϦʢCDʣܧଓతσϓϩΠʢCDʣ
  5. %FW0QT nhttps://ja.wikipedia.org/wiki/DevOps • ιϑτ΢ΣΞ։ൃख๏ͷҰͭ • ։ൃ (Development) ͱӡ༻ (Operations) Λ૊Έ߹Θͤͨޠ

    • ։ൃ୲౰ऀͱӡ༻୲౰ऀ͕࿈ܞͯ͠ڠྗ͢Δʢ͞Βʹ྆୲౰ऀͷڥ໨΋͍͋· ͍ʹ͢Δʣ։ൃख๏ • ιϑτ΢ΣΞΛਝ଎ʹϏϧυ͓Αͼςετ͢ΔจԽͱ؀ڥʹΑΓɺ࣮֬ͳ ϦϦʔεΛɺҎલΑΓ΋ਝ଎ʹߴ͍සൟͰՄೳͱ͢Δ૊৫ମ੍ͷߏஙΛ໨ ࢦ͢ nDevOpsΛ࣮ݱ͢ΔͨΊͷํ๏ • ΞδϟΠϧɾεΫϥϜɼCI/CD n೿ੜ • MLOpsɿػցֶशͷDevOps • AIOpsɿAIͷDevOps Illustration showing stages in a DevOps toolchainKharnagy - Own work CC BY-SA 4.0
  6. ܧଓతΠϯςάϨʔγϣϯ

  7. ܧଓతΠϯςάϨʔγϣϯʢ$*ʣ nCIʢContinuous Integrationʣ • ίʔυͷมߋΛఆظతʹதԝϦϙ δτϦͷϝΠϯϒϥϯνʹpush͢ Δ • ͢΂ͯͷ։ൃऀ͕ɼ1೔ʹ਺ճ ͔Β਺ेճ΋ߦ͏

    • push͞ΕͨΒϏϧυͱςετΛࣗ ಈ࣮ߦ • Ϗϧυͱςετ͕੒ޭͨ͠Βࣗ ಈϚʔδ nར఺ɿख໭Γ͕୹͍ • Τϥʔʹ͙͢ؾ͕෇͚Δ • ์ஔ͢Δ͜ͱ͕ͳ͍ nखॱ • ϩʔΧϧ • Ϗϧυͱςετʢࣗಈʣ • ςετ͕௨Ε͹࣍΁ • CIʹpush • CIଆͰϏϧυͱςετʢࣗಈʣ • ςετ͕௨Ε͹Ϛʔδ
  8. Ϋϥ΢υ$*αʔϏε nCIઐ༻αʔϏε • TravisCI • circleCI nϗεςΟϯάʴCIΠϯϑϥ • GitHub Actions

    https://github.co.jp/features/actions https://circleci.com https://www.travis-ci.com
  9. $*ʹΑΔ։ൃϧʔνϯ มߋ मਖ਼ ϩʔΧϧ ϦϙδτϦ ϦϞʔτ ϦϙδτϦ push CIαʔϏε ࣗಈϏϧυ

    ࣗಈςετ ݁Ռ ฦૹ τϦΨʔ CI͕OKͳΒ ӡ༻΁ల։
  10. ࣮ࡍͷ$*ͷྫ

  11. https://github.com/PointCloudLibrary/pcl/pull/4614 ͜͜Ͱ͸PRΛϚʔδ͢ Δͱ͖ʹCIΛ࢖͍ͬͯ Δ CIͷ݁Ռ͕͜Ε

  12. ଟ਺ͷ؀ڥͰϏϧυͰ ͖Δ͔֬ೝ͍ͯ͠Δ

  13. ͜ͷϏϧυʹ͍ͭͯ͸ ςετ͸100%ύε

  14. ͜ͷϏϧυ͸ࣦഊͯ͠ ͍Δʁ CIαʔϏεʹ͸MicrosoftͷAzure DevOpsΛ ར༻͍ͯ͠Δ

  15. ࣦഊ͍ͯ͠Δ৔ॴ͕੺ ʹͳ͍ͬͯΔ

  16. ৄ͍͠಺༰͸͜͜

  17. ϥΠϒϥϦͷϏϧυʹ ࣦഊ͍ͯ͠Δ͜ͱ͕Θ ͔ͬͨ

  18. ܧଓతσϦόϦ ܧଓతσϓϩΠ

  19. $*ʹΑΔ։ൃϧʔνϯ มߋ मਖ਼ ϩʔΧϧ ϦϙδτϦ ϦϞʔτ ϦϙδτϦ push CIαʔϏε ࣗಈϏϧυ

    ࣗಈςετ ݁Ռ ฦૹ τϦΨʔ CI͕OKͳΒ ӡ༻΁ల։ ͕͜͜ख࡞ۀ
  20. $%ʹΑΔ։ൃϧʔνϯ มߋ मਖ਼ ϩʔΧϧ ϦϙδτϦ ϦϞʔτ ϦϙδτϦ push CI/CDαʔϏε ࣗಈϏϧυ

    ࣗಈςετ OKͳΒ ࣗಈల։ τϦΨʔ ͜͜·Ͱࣗಈʂ nܧଓతσϓϩΠʢCDʣ • Ϗϧυͱςετ͕੒ޭ͠ ͨΒࣗಈతʹ࣮؀ڥ΁σ ϓϩΠ • Ϋϥ΢υαʔϏεʹద͠ ͍ͯΔ nܧଓతσϦόϦʢCDʣ • ࣮ࡍʹσϓϩΠ͢Δͷ͸ खಈ • ࠷ऴ֬ೝ͕Ͱ͖Δ
  21. $*$%͸౰ͨΓલ CI CD MarkdownͰCI/CD݁Ռ ΁ͷϦϯΫͱόφʔ͕ ຒΊࠐΊΔ

  22. https://github.com/pytorch/pytorch JenkinsͰCI

  23. https://github.com/tensorflow/tensorflow Google CloudͰCI

  24. $*$%Λ࣮ફͯ͠ΈΔ

  25. $%͸XFCΞϓϦʹ࠷ద nΫϥ΢υαʔϏεΛ։ൃɾσϓϩΠ͢Δ • ϩʔΧϧͰ։ൃ • ίʔσΟϯά • Ϗϧυͱςετ • ϩʔΧϧ؀ڥͰ࣮ߦ

    • CI/CDଆʹ౤͛Δ • ࣗಈϏϧυͱςετ • ੒ޭͨ͠ΒσϓϩΠ • webܦ༝Ͱར༻ՄೳʹͳΔ Webix provides a great number of JavaScript UI widgets with a pefect look and feel great on various devices. All of them can be effortlessly customized in accordance with your preferences thanks to the rich and clear API.Kelluvuus - Own work CC BY-SA 4.0
  26. TUSFBNMJUɿܰྔXFCΞϓϦ࡞੒ϥΠϒϥϦ ը૾Λμ΢ϯ ϩʔυ RGBͷώετά ϥϜΛܭࢉ ϥδΦϘμϯͰ RGBΛબ୒ http://localhost:8501/ ʹΞΫηεͨ͠ը໘ main.py

  27. ࠓ͔Βߦ͏$*$%ͷ֓ཁ https://github.com/logos มߋ मਖ਼ ϩʔΧϧ ϦϙδτϦ clone push ϦϞʔτϦ ϙδτϦ

    https://brand.heroku.com web ΞϓϦ • खಈͰσϓϩΠ • push͞ΕͨΒࣗಈσϓϩΠ • push͞ΕͯCI͕passͨ͠Βࣗ ಈσϓϩΠ ࿈ܞ
  28. )FSPLVɿ1BB4 n֤छݴޠͷwebΞϓϦΛσϓϩ ΠͰ͖Δ • ݄550࣌ؒ·Ͱ͸ແྉͰར༻Մೳ • ΫϨδοτΧʔυΛొ࿥͢Δͱߋ ʹ450࣌ؒ/݄·Ͱར༻Մೳ • ʢ2021/Aprͷ৘ใʣ

    https://www.heroku.com
  29. ·ͣϑΥʔΫ https://github.com/tttamaki/show_img_hist

  30. ͦΕΛΫϩʔϯ ͜͜͸ࣗ෼ͷΞΧ΢ϯτ ໊ʹͳΔ ϑΥʔΫͨࣗ͠෼ͷϦϙ δτϦͷsshͷURLΛ ࢖͍ͬͯͩ͘͞

  31. ͦΕΛΫϩʔϯ ϑΥʔΫͨࣗ͠෼ͷϦϙ δτϦͷsshͷURLΛࢦ ఆ͍ͯͩ͘͠͞ ࣗ෼ͰϑΥʔΫͨ͠ϦϙδτϦURL

  32. ·ͣ͸EPDLFSͰϩʔΧϧ࣮ߦ

  33. ·ͣ͸EPDLFSͰϩʔΧϧ࣮ߦ ίϯςφͷ8501 ϙʔτΛ ϗετͷ8501 ϙʔτ΁సૹ͠ ͍ͯΔ ίϯςφΛىಈ ίϯςφ৘ใΛ ݟΔͱ docker-compose.yml

  34. ·ͣ͸EPDLFSͰϩʔΧϧ࣮ߦ streamlitαʔόΛى ಈ͢ΔίϚϯυ streamlitΛ࢖ͬͨ pythonεΫϦϓτ http://localhost:8501/ʹ ΞΫηε͢Ε͹OK ࢭΊΔͱ͖ʹ͸ Ctrl+c •

    ͜ͷIP͸ίϯςφ಺෦ͷΞυϨ εʢ֎෦͔Β͸ΞΫηεͰ͖ͳ ͍ʣ • ͦͷ୅ΘΓʹdocker- compose.ymlͰϙʔτϚοϐϯ άΛࢦఆ͍ͯ͠ΔͷͰɼ localhostͷϙʔτ͕ར༻Ͱ͖Δ ͜ͷIPΞυϨε͸ແࢹ
  35. )FSPLV΁σϓϩΠ ͢ΔͨΊͷ४උ nHerokuΞΧ΢ϯτͷ࡞੒ • https://blog.proglus.jp/1438/ • https://itstudio.co/2020/11/29/111 61/

  36. heroku.com΁ ߦͬͯ ͔͜͜ΒϢʔ βʔొ࿥

  37. Ϣʔβʔ৘ใΛ ຒΊΔ

  38. ֶੜͰOK ͜ΕΛԡ͢ͱొ ࿥

  39. ͜ͷը໘ʹͳΔ ͢Δͱ͜ͷϝʔϧ͕ಧ͘ͷ Ͱɼϝʔϧ಺ͷURLΛΫ ϦοΫ

  40. ύεϫʔυΛઃ ఆͯ͠ ϝʔϧ͕ෆཁͳΒνΣο ΫΛ֎͢

  41. ͜ΕͰOKɽ ͔͜͜Βελʔτ

  42. ϥΠηϯεΛಡΜͰ ͔Βঝ୚

  43. XFCΞϓϦ࡞੒ nGitHubͱ࿈ܞ

  44. create new app ͔ΒwebΞϓϦΛ࡞ ੒

  45. webΞϓϦʹ໊લΛ͚ͭΔ ஫ҙɿ͢Ͱʹ͜ͷ໊લ͸͜ͷαϯϓϧ Λ࡞Δͱ͖ʹ࢖͍ͬͯ·͢ɽଞͷ໊લ Λ͚͍ͭͯͩ͘͞ʢଞਓͱಉ͡΋ͷ͸ ࢖͑ͳ͍ʣ ͜ΕΛԡ͢ͱ࡞ ੒͞ΕΔ

  46. ࣍ʹGitHubͱ࿈ܞ ͢ΔͨΊʹ͜͜Λԡ ͢

  47. ͜͜Λԡ͢ͱɼGitHubͷ ࿈ܞ֬ೝϖʔδ͕ग़Δͷ Ͱɼͦ͜Ͱ࿈ܞΛঝ୚͢ Δ

  48. ࿈ܞ͞ΕΔͱ GitHubΞΧ΢ϯτ ͕ग़ΔͷͰɼ ϦϙδτϦ໊Ͱݕࡧ ͯ͠ ͜ͷwebΞϓϦʹ࿈ܞ͞ ͤΔϦϙδτϦΛબ୒͠ ͯConnectΛԡ͢

  49. appͷ໊લΛॏෳ͠ͳ͍ผͷ΋ͷʹ มߋ͍ͯͩ͘͠͞ʢ͜ͷ໊લ͸͜ ͷεϥΠυΛ࡞੒͢Δ࣌ʹ࢖ͬͯ ͍·͢ͷͰɼଞͷਓ͸࢖͑ͳ͍͸ ͣʣ

  50. खಈσϓϩΠ

  51. ·ͣ͸खಈͰσϓϩΠ ࿈ܞ͞ΕͨΒɼ·ͣ͸ खಈͰσϓϩΠͯ͠Έ ΔɽͦͷͨΊʹʯ͜͜ Λԡ͢

  52. σϓϩΠ͕࢝·Δɽ ऴΘΔ·Ͱʹ਺෼͔ ͔ΔͷͰ࢑͘଴ͭ

  53. σϓϩΠͳͲͷΞΫ ςΟϏςΟ͸͔͜͜ Β֬ೝͰ͖Δ ͔͜͜ΒϏϧυϩά ͕֬ೝͰ͖Δ

  54. ͜͏ͳΕ͹OKɽ͜ ͷURL͔ΒΞΫηε Ͱ͖Δ ͜͜Λԡͯ͠΋web ΞϓϦʹΞΫηεͰ ͖Δ

  55. Mount Fuji from Mount AinoAlpsdake - Own work CC BY-SA

    3.0 URL͔Β෼͔ΔΑ͏ʹɼͲ ͔͜ΒͰ΋ΞΫηεͰ͖Δ webΞϓϦ͕׬੒ͨ͠
  56. XFCΞϓϦͷ ఀࢭํ๏

  57. XFCΞϓϦͷఀࢭํ๏ ϦιʔεΛݟΔ ͜Ε͕ʮ࣮ߦதʯ ʢ݄500࣌ؒ·Ͱແྉʣ ఀࢭ͢Δʹ͸͜͜ ࢖Θͳ͍ͱ͖ʹ͸ఀࢭ͢Δ͜ͱʂ

  58. XFCΞϓϦͷఀࢭํ๏ ϦιʔεΛݟΔ Φϑʢࠨʣʹͯ͠ ConfirmΛԡ͢

  59. XFCΞϓϦͷఀࢭํ๏ ϦιʔεΛݟΔ ͜ΕͰఀࢭͨ͠ ࠶ͼىಈ͢Δʹ͸ಉ ͡खॱͰONʹ͢Δ ͜ͱ

  60. ࣗಈσϓϩΠ

  61. (JU)VC΁ͷQVTIͱ࿈ಈͨࣗ͠ಈσϓϩΠ ͜ΕΛԡ͢ͱ GitHub΁pushͨ͠ Βࣗಈతʹσϓϩ͞ ΕΕΔ ࣗಈσϓϩΠΛࢭΊ ͍ͨͱ͖͸΋͏Ұ౓ ԡ͢

  62. ίʔυΛमਖ਼ • ίʔυதͷදࣔ͢Δը૾URLΛมߋ͠ ͯΈΑ͏ • http://localhost:8501/ʹΞΫηεͯ͠ ϩʔΧϧͰͷ࣮ߦΛ֬ೝ͓ͯ͜͠͏

  63. मਖ਼ͨ͠ΒQVTI ࣗ෼ͰϑΥʔΫͨ͠ϦϙδτϦURL add, commit, push

  64. QVTIͰ$% GitHub΁ͷpush͕ ࣗಈతʹݕ஌͞Εͯ σϓϩΠ͕࢝·Δ σϓϩΠऴྃ ΞϓϦΛ։͘

  65. ஫ɿ͖ͬ͞ఀࢭͨ͠ͳΒ࠶։͓ͯ͘͠ ։͘લʹɼwebΞϓϦΛ ఀࢭ͍ͯͨ͠ͳΒ࠶։͠ ͓ͯ͘

  66. Mt Fuji at Nihondaira CC දࣔ 3.0 ͔ͨ͠ʹมߋ͞Ε͍ͯΔ

  67. $*$% nGitHub΁push nGitHub ActionsͰCI n੒ޭͨ͠ΒHeroku΁CD

  68. (JU)VCͰ$*͕੒ޭͨ͠Β)FSPLV΁σϓϩΠ ͜ΕΛνΣοΫ͢Δͱɼ GitHubͷCI͕੒ޭͨ͠ ΒࣗಈσϓϩΠ͢Δ ʢνΣοΫͳ͠ͳΒɼ ແ৚݅ͰࣗಈσϓϩΠɽ ίʔυ͕ؒҧ͍ͬͯͨ ΒαʔϏε͕ఀࢭͯ͠ ͠·͏ʣ

  69. ࣗ෼ͰϑΥʔΫͨ͠ϦϙδτϦͷActions΁ߦ͘ ৭ʑ͋Δ͕ɼ͜͜Ͱ ͸Python package Λར༻ɽ͜ΕΛԡ͢ GitHub Actionsͱ͸ GitHubͷCIαʔϏε

  70. ͜ͷϑΝΠϧ͕࡞੒ ͞ΕΔ

  71. ࠓճ͸pytest͸࢖Θ ͳ͍ͷͰɼ͜ͷ3ߦ Λ࡟আ͢Δʂ flake8Λ࢖ͬͯϑΥʔϚοτ νΣοΫ͢Δઃఆɽflake8͕ ੒ޭͨ͠ΒCI͸੒ޭͨ͜͠ͱ ʹ͢Δ ฤूͨ͠Βɼ͜͜Λԡͯ͠ commitΛ࡞੒ʢActionΛ࡞ Δͷ΋commitʣ

    commitͷλΠτ ϧͱ಺༰Λॻ͍ ͯ commitΛ࡞੒
  72. ͜͜ʹ࡞੒͞Εͨ

  73. Ͱ͸ɼΘ͟ͱίʔυ Λؒҧ͑ͯΈΔ ʢflake8͕ݕग़Ͱ͖ ΔߏจΤϥʔʣ

  74. ؒҧͬͨ··ίʔ υΛadd, commit, pushͯ͠ΈΑ͏ ʢ౰વͰ͖ͯ͠· ͏ʣ ࣗ෼ͰϑΥʔΫͨ͠ϦϙδτϦURL

  75. ActionsΛΈΔͱ ActionͷymlΛ௥Ճͨ͠ commit͸࡞੒͍ͯ͠Δ͕ pushͨ͠ίϛοτͰ͸ࣦഊ ͍ͯ͠Δɽৄࡉ͸͜͜ΛΫ ϦοΫ

  76. Ͳͷpythonͷόʔ δϣϯͰ΋ࣦഊ

  77. ͜͜Λԡ͢ͱ flake8νΣοΫͰࣦഊ͍ͯ͠Δ͜ͱ ͕෼͔Δʢ༧૝௨ΓͰ͢Ͷʣ ͜͜ͰCI͕ࣦഊ͍ͯ͠ΔͷͰɼ heroku΁͸σϓϩΠ͞Ε͍ͯͳ͍

  78. ίʔυΛमਖ਼ͯ͠ɼ add, commit, push ͠ͳ͓͢ ࣗ෼ͰϑΥʔΫͨ͠ϦϙδτϦURL

  79. ࠓ౓͸CI͕੒ޭ͍ͯ͠Δɽ heroku΁΋σϓϩΠ͞Ε͍ͯΔ

  80. σϓϩΠઌ͸githubͷϦ ϙδτϦʹ΋ه࿥͕࢒Δ ͔͜͜Βweb ΞϓϦ͕ىಈ Ͱ͖Δ

  81. None
  82. ՝୊ nࠓճͷwebΞϓϦΛ࡞੒ͤΑ • εϥΠυͷखॱʹैͬͯ • localhostͷwebΞϓϦʹΞΫηεͰ͖Δ͜ͱΛ֬ೝ͢Δ • HerokuΞϓϦΛ࡞੒͠ɼGitHubͱ࿈ܞͯ͠खಈͰσϓϩΠ͢Δ • ϒϥ΢βͰHerokuΞϓϦʹΞΫηεͰ͖Δ͜ͱΛ֬ೝ͢Δ

    • CI/CDΛମݧ͢Δ • GitHub ActionsΛઃఆ͢Δ • ίʔυΛमਖ਼ɼcommitͯ͠GitHub΁push͢Δ • HerokuʹࣗಈσϓϩΠ͞Ε͍ͯΔ͜ͱΛ֬ೝ͢Δ • HerokuΞϓϦΛऴྃ͢ΔͷΛ๨Εͳ͍͜ͱ nʢ্ڃऀฤʣΞϓϦΛमਖ਼ʢ΋͘͠͸ࣗ࡞ʣͯ͠ΈΑ͏
  83. ૝ఆࢼݧ໰୊ nDevOpsͱ͸Կ͔Λઆ໌ͤΑ nCIͱ͸Կ͔Λઆ໌ͤΑ nCDͱ͸Կ͔Λઆ໌ͤΑ nCI/CDͷ঎༻αʔϏεʹ͸Կ͕͋Δͷ͔ΛྻڍͤΑ nHerokuͱ͸ͲͷΑ͏ͳαʔϏεͳͷ͔Λड़΂Α