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

Git & GitLab & コードレビューって? / about Git, GitLab, CodeReview

Taiju Aoki
February 21, 2020

Git & GitLab & コードレビューって? / about Git, GitLab, CodeReview

Study Slide for Git Newbie

Taiju Aoki

February 21, 2020
Tweet

More Decks by Taiju Aoki

Other Decks in Programming

Transcript

  1. Git & GitLab & ίʔυϨϏϡʔͬͯʁ @blue_1617

  2. ࢲ͸୭ʁ blue (@blue_1617) https://blue0513.github.io/show_room/ 2 Rails, JavaScript, Scala etc ΤϜεϦʔ:

    Ϋϥ΢υిࢠΧϧςνʔϜॴଐ ͨ·ʹ C# ͱ͔ DevOps ΋΍ΔΑ GitHubͱ͔ ‣ slackdeck-proto : Slack ͷ TweetDeck ෩ Viewer ‣ minideck : TweetDeck ͷ͍͍ײ͡ͷ Viewer ‣ phantom-inline-comment: Emacs ͷ package ‣ point-history: Emacs ͷ package ‣ instant-maximized-window: Emacs ͷ package
  3. ͜ͷࢿྉ͸ʁ 3 Git ΍ GitLabɺίʔυϨϏϡʔͷʮ֓೦ʯ Λ཈͑Δ͜ͱ͕໨త ʢৄࡉͳίϚϯυͷୟ͖ํͳͲ͸આ໌͠ͳ͍ʣ ‣ Git ͬͯԿ͕خ͍͠ͷʁ

    ‣ GitLab ͰԿ͕Ͱ͖Δͷʁ ‣ ίʔυϨϏϡʔͬͯԿΛ͢Δͷʁ
  4. લఏ৚݅ 4 υϯυϯ࣭໰ͪ͠Ό͍ͬͯͩ͘͞ʂ ‣ Ұํతͳߨٛ͡Όͳ͍Ͱ͢ ؒҧͬͯͨΒڭ͍͑ͯͩ͘͞ʂ ‣ blue ΋·ͩۦ͚ग़͠ͷΤϯδχΞͰ͢ ଞͷҙݟ΋͍ͬͺ͍͋Δͱࢥ͍·͢

    ‣ ઈରతͳՁ஋ج४Ͱ͸ͳ͍Ͱ͢ ΤϯδχΞ͸ֶͼଓ͚Δ࢟੎͕ඞཁͩͱࢥ͍·͢ ‣ ͜ͷษڧձΛ੒௕ͷ͖͔͚ͬʹ͍ͯͩ͘͠͞
  5. Git ͬͯͳʹ͕خ͍͠ͷʁ

  6. ͦ΋ͦ΋ Git ͬͯԿ͕Ͱ͖Δͷʁ 6 Git is a free and open

    source distributed version control system designed to handle everything from small to very large projects with speed and efficiency https://git-scm.com/
  7. ͦ΋ͦ΋ Git ͬͯԿ͕Ͱ͖Δͷʁ 7 Git is a free and open

    source distributed version control system designed to handle everything from small to very large projects with speed and efficiency https://git-scm.com/ Branching & Merging Data Assurance Staging Area
  8. Branching & Merging 8 ෳ਺ͷ Branch Λ·͕ͨͬͯ։ൃͰ͖Δ ʢBranch: ֤ʑಠཱͨ͠ workspaceʣ

    ‣ Master branch ‣ Develop branch ‣ Topic branch ຊ൪؀ڥʹσϓϩΠ͢Δ/ͨ͠ branch Topic branch Λ·ͱΊͨ౷߹ branch ݕূ؀ڥͳͲʹ͋͛ͯ QA ͞ΕΔ ػೳ։ൃͷ branch ػೳ͝ͱʹ࡞ΒΕΔͨΊɺ࠷΋਺͕ଟ͍ https://git-scm.com/about/branching-and-merging
  9. Branching & Merging 9 ෳ਺ͷ Branch Λ·͕ͨͬͯ։ൃͰ͖Δ ʢBranch: ֤ʑಠཱͨ͠ workspaceʣ

    ‣ Master branch ‣ Develop branch ‣ Topic branch ຊ൪؀ڥʹσϓϩΠ͢Δ/ͨ͠ branch Topic branch Λ·ͱΊͨ౷߹ branch ݕূ؀ڥͳͲʹ͋͛ͯ QA ͞ΕΔ ػೳ։ൃͷ branch ػೳ͝ͱʹ࡞ΒΕΔͨΊɺ࠷΋਺͕ଟ͍ Topic into Develop Develop into Master https://git-scm.com/about/branching-and-merging
  10. Branching & Merging 10 ΋͠΋ Master branch ҰຊͰӡ༻͢Δͱʁ 1. Ͳͷ

    commit ·Ͱ͕ຊ൪؀ڥʹσϓϩΠ͞Ε͍ͯΔ͔ෆ໌ 2. ۓٸमਖ਼൛ΛϦϦʔε͢Δͱ͖ʹɺະ QA ͷ΋ͷ͕ࠞ͡Δ etc etc .... 3. ϨϏϡʔΛ͢Δͷ͕೉͍͠ ੡඼ͷΫΦϦςΟΛ୲อͰ͖ͳ͍ʂ
  11. Staging Area 11 ‣ Working Directory ‣ Staging Area ‣

    Repository มߋΛ֬ఆ͢Δલͷஈ֊͕ଘࡏ͢Δ (commit) ࡞ۀதͷۭؒ var temp = 'DEBUG' ͱ͔ͯ͠΋OK มߋ֬ఆલͷۭؒ มߋ͕ଥ౰ͳ΋ͷ͔ΛνΣοΫ͢Δ มߋ֬ఆޙͷۭؒ git add file git commit -m "msg" https://git-scm.com/about/staging-area
  12. Staging Area 12 ‣ Working Directory ‣ Staging Area ‣

    Repository มߋΛ֬ఆ͢Δલͷஈ֊͕ଘࡏ͢Δ (commit) ཤྺʹ࢒͢/࢒͞ͳ͍มߋΛબ୒Ͱ͖Δ https://git-scm.com/about/staging-area commit ͷཻ౓Λ؆୯ʹௐ੔Ͱ͖Δ
  13. Data Assurance 13 commit ͨ͠಺༰ͦͷ΋ͷ͕อ࣋͞ΕΔ ޙʑมߋ͢Δ͜ͱ͕ʢࣄ্࣮ʣෆՄೳ 1. Project ಺༰Λ commit

    ͳ͠ʹมߋ͢Δ͜ͱ͕ෆՄ 2. ୭͕ clone ͯ͠΋ಉ݁͡ՌʹͳΔ 3. ྺ࢙Λ׬શʹอ࣋͢ΔʢVersion Controlʣ https://git-scm.com/about/info-assurance
  14. Data Assurance 14 commit ͨ͠಺༰ͦͷ΋ͷ͕อ࣋͞ΕΔ ޙʑมߋ͢Δ͜ͱ͕ʢࣄ্࣮ʣෆՄೳ 1. Project ಺༰Λ commit

    ͳ͠ʹมߋ͢Δ͜ͱ͕ෆՄ 2. ୭͕ clone ͯ͠΋ಉ݁͡ՌʹͳΔ 3. ྺ࢙Λ׬શʹอ࣋͢ΔʢVersion Controlʣ ෳ਺ਓͰͷ։ൃ͕ඇৗʹ༰қ https://git-scm.com/about/info-assurance
  15. Git ͬͯͳʹ͕خ͍͠ͷʁ 15 https://git-scm.com/about/ ‣ Branching & Merging ͷ࢓૊ΈͰɺฒߦͨ͠։ൃ͕༰қʹ ‣

    Staging Area ʹΑͬͯɺมߋΛۛຯͰ͖Δ ‣ Data Assurance ͷੑ࣭Ͱɺෳ਺ਓ։ൃ͕༰қʹ
  16. GitLab Ͱͳʹ͕Ͱ͖Δͷʁ

  17. ͦ΋ͦ΋ GitLab ͬͯԿʁ 17 GitLab is a web-based DevOps lifecycle

    tool that provides a Git- repository manager providing wiki, issue-tracking and CI/CD https://en.wikipedia.org/wiki/GitLab pipeline features https://about.gitlab.com/stages-devops-lifecycle/continuous-integration/
  18. ͦ΋ͦ΋ GitLab ͬͯԿʁ 18 GitLab is a web-based DevOps lifecycle

    tool that provides a Git- repository manager providing wiki, issue-tracking and CI/CD https://en.wikipedia.org/wiki/GitLab pipeline features https://about.gitlab.com/stages-devops-lifecycle/continuous-integration/ WIKI ISSUE MR
  19. Merge Request (MR) 19 Merge requests allow you to visualize

    and collaborate on the proposed changes to source code that exist as commits on a given Git branch Title Description Target Branch https://about.gitlab.com/
  20. Merge Request (MR) 20 Merge requests allow you to visualize

    and collaborate on the proposed changes to source code that exist as commits on a given Git branch Modified Sources https://about.gitlab.com/
  21. MR ͕Ͱ͖Δͱɺͳʹ͕خ͍͠ͷʁ 21 1. มߋՕॴΛϨϏϡʔͰ͖Δʢޙड़ʣ 2. มߋͷཧ༝/಺༰/ཤྺΛυΩϡϝϯτͱͯ͠࢒ͤΔ ͜͜ͰAΛBͯ͠Δ ཧ༝͸ԿͰ͔͢ʁ B͠ͳ͍ͱC͢Δͱ͖

    ෆ౎߹͕͋Δ͔ΒͰ͢
  22. Continuous Integration/Deployment (CI/CD) 22 Continuous Integration works by pushing small

    code chunks to your application’s code base hosted in a Git repository, and, to every push, run a pipeline of scripts to build, test, and validate the code changes before merging them into the main branch. Continuous Delivery and Deployment consist of a step further CI, deploying your application to production at every push to the default branch of the repository. https://about.gitlab.com/
  23. CI/CD ͕Ͱ͖Δͱɺͳʹ͕خ͍͠ͷʁ 23 build unit test E2E ςετ Lint ຊ൪

    deploy ؀ڥม਺ͷॻ͖׵͑ ϦϦʔε build QA ؀ڥ΁ͷ deploy ssh unit test etc etc .... ‣ ͢΂ͯख࡞ۀͰ࣮ߦ͢Δඞཁ͕͋Δ ‣ खॱΛϛεΔͱαʔϏε͕ࢭ·Δ ‣ खݩͰ build ΍ ςετ ͢Δ͕͔͔࣌ؒΔ ‣ ਫ਼ਆ͕͢ΓݮΔ.....
  24. 24 ‣ build ΍ςετͯ͠Δؒʹ։ൃ͕Ͱ͖Δ ‣ Slack ͳͲͱ࿈ܞࣦͯ͠ഊͨ͠Β௨஌ͯ͘͠ΕΔ ‣ push ͢Δ͚ͩͰίϯϐϡʔλ͕શ෦΍ͬͯ͘ΕΔ

    ‣ ࣗಈԽ࠷ߴʂ CI/CD ͕Ͱ͖Δͱɺͳʹ͕خ͍͠ͷʁ push
  25. ίʔυϨϏϡʔͬͯԿ͢Δͷʁ

  26. 26 ίʔυϨϏϡʔͬͯԿ͢Δͷʁ https://github.com/google/eng-practices/blob/master/review/index.md A code review is a process where

    someone other than the author(s) of a piece of code examines that code. At Google we use code review to maintain the quality of our code and products.
  27. 27 ίʔυϨϏϡʔͬͯԿ͢Δͷʁ A code review is a process where someone

    other than the author(s) of a piece of code examines that code. At Google we use code review to maintain the quality of our code and products. ‣ ૈ୳͠΍൷൑Λ͢ΔͷͰ͸ͳ͘ɺ ίʔυ΍ϓϩμΫτͷΫΦϦςΟΛ୲อ͢Δ৔
  28. 28 ίʔυϨϏϡʔͬͯԿ͢Δͷʁ A code review is a process where someone

    other than the author(s) of a piece of code examines that code. At Google we use code review to maintain the quality of our code and products. ‣ ૈ୳͠΍൷൑Λ͢ΔͷͰ͸ͳ͘ɺ ‣ ໾৬΍೥࣍ʹґΒͳ͍ϑϥοτͳ৔ ίʔυ΍ϓϩμΫτͷΫΦϦςΟΛ୲อ͢Δ৔
  29. 29 ίʔυϨϏϡʔͬͯԿ͢Δͷʁ A code review is a process where someone

    other than the author(s) of a piece of code examines that code. At Google we use code review to maintain the quality of our code and products. ‣ ૈ୳͠΍൷൑Λ͢ΔͷͰ͸ͳ͘ɺ ‣ ໾৬΍೥࣍ʹґΒͳ͍ϑϥοτͳ৔ ‣ ΤϯδχΞͨͪͷίϛϡχέʔγϣϯͷ৔ ίʔυ΍ϓϩμΫτͷΫΦϦςΟΛ୲อ͢Δ৔
  30. 30 ίʔυϨϏϡʔͬͯԿ͢Δͷʁ ‣ มߋͷҙਤΛਘͶΔ https://about.gitlab.com/ ͜͜ͰAΛBͯ͠Δ ཧ༝͸ԿͰ͔͢ʁ B͠ͳ͍ͱC͢Δͱ͖ ෆ౎߹͕͋Δ͔ΒͰ͢

  31. 31 ίʔυϨϏϡʔͬͯԿ͢Δͷʁ ‣ मਖ਼ͨ͠ํ͕͍͍఺ΛࢦఠΛ͢Δ https://about.gitlab.com/ Aʹ͠ͳ͍ͱBͷͱ͖ʹ ෆ౎߹ੜ͡·͢Ͷ ͔ͨ͠ʹ Aͷख๏ʹॻ͖׵͑·͢

  32. 32 ίʔυϨϏϡʔͬͯԿ͢Δͷʁ ‣ Nits: ඞਢ͡Όͳ͍͚Ͳɺ·͋ࢦఠ ‣ Ask: ७ਮʹ࣭໰ͳΜͰ͕͢ ‣ IMO:

    ࣗ෼ͷҙݟͰ͸ ‣ FYI: ຊےͱؔ܎ͳ͍͚Ͳɺ৘ใڞ༗͢Δͱ ‣ Must: मਖ਼͸ඞਢͰ͢Α ͨ·ʹ࢖͏ prefix ͨͪ ϨϏϡʔίϝϯτͷԹ౓ײΛ఻͑Δͷʹศར
  33. ·ͱΊ

  34. 34 ·ͱΊ ‣ GitLab ‣ Code Review ‣ Git ‣

    ίʔυͷΫΦϦςΟΛ্͛ΒΕΔ ‣ υΩϡϝϯτΛ࢒ͤΔ ‣ ΤϯδχΞͷίϛϡχέʔγϣϯͷ৔Ͱ͋Δ ‣ Test ͳͲΛܧଓతʹ࣮ߦͰ͖Δ ‣ Deploy ΛࣗಈԽͰ͖Δ ‣ ։ൃΛߴ଎ԽͰ͖Δ ‣ ҆શʹ։ൃΛਐΊΒΕΔΑ͏ʹͳΔ