Share
Embed
Git & GitLab & コードレビューって? / about Git, GitLab, CodeReview
Study Slide for Git Newbie
Taiju Aoki
February 21, 2020
Transcript
34 slides
-
ࢲ୭ʁ 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 Git GitLabɺίʔυϨϏϡʔͷʮ֓೦ʯ Λ͑Δ͜ͱ͕త ʢৄࡉͳίϚϯυͷୟ͖ํͳͲઆ໌͠ͳ͍ʣ ‣ Git ͬͯԿ͕خ͍͠ͷʁ
‣ GitLab ͰԿ͕Ͱ͖Δͷʁ ‣ ίʔυϨϏϡʔͬͯԿΛ͢Δͷʁ -
લఏ݅ 4 υϯυϯ࣭ͪ͠Ό͍ͬͯͩ͘͞ʂ ‣ Ұํతͳߨٛ͡Όͳ͍Ͱ͢ ؒҧͬͯͨΒڭ͍͑ͯͩ͘͞ʂ ‣ blue ·ͩۦ͚ग़͠ͷΤϯδχΞͰ͢ ଞͷҙݟ͍ͬͺ͍͋Δͱࢥ͍·͢
‣ ઈରతͳՁج४Ͱͳ͍Ͱ͢ ΤϯδχΞֶͼଓ͚Δ͕࢟ඞཁͩͱࢥ͍·͢ ‣ ͜ͷษڧձΛͷ͖͔͚ͬʹ͍ͯͩ͘͠͞ -
ͦͦ 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/ -
ͦͦ 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 -
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 -
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 -
Branching & Merging 10 ͠ Master branch ҰຊͰӡ༻͢Δͱʁ 1. Ͳͷ
commit ·Ͱ͕ຊ൪ڥʹσϓϩΠ͞Ε͍ͯΔ͔ෆ໌ 2. ۓٸमਖ਼൛ΛϦϦʔε͢Δͱ͖ʹɺະ QA ͷͷ͕ࠞ͡Δ etc etc .... 3. ϨϏϡʔΛ͢Δͷ͕͍͠ ͷΫΦϦςΟΛ୲อͰ͖ͳ͍ʂ -
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 -
Staging Area 12 ‣ Working Directory ‣ Staging Area ‣
Repository มߋΛ֬ఆ͢Δલͷஈ֊͕ଘࡏ͢Δ (commit) ཤྺʹ͢/͞ͳ͍มߋΛબͰ͖Δ https://git-scm.com/about/staging-area commit ͷཻΛ؆୯ʹௐͰ͖Δ -
Data Assurance 13 commit ͨ͠༰ͦͷͷ͕อ࣋͞ΕΔ ޙʑมߋ͢Δ͜ͱ͕ʢࣄ্࣮ʣෆՄೳ 1. Project ༰Λ commit
ͳ͠ʹมߋ͢Δ͜ͱ͕ෆՄ 2. ୭͕ clone ͯ͠ಉ݁͡ՌʹͳΔ 3. ྺ࢙Λશʹอ࣋͢ΔʢVersion Controlʣ https://git-scm.com/about/info-assurance -
Data Assurance 14 commit ͨ͠༰ͦͷͷ͕อ࣋͞ΕΔ ޙʑมߋ͢Δ͜ͱ͕ʢࣄ্࣮ʣෆՄೳ 1. Project ༰Λ commit
ͳ͠ʹมߋ͢Δ͜ͱ͕ෆՄ 2. ୭͕ clone ͯ͠ಉ݁͡ՌʹͳΔ 3. ྺ࢙Λશʹอ࣋͢ΔʢVersion Controlʣ ෳਓͰͷ։ൃ͕ඇৗʹ༰қ https://git-scm.com/about/info-assurance -
Git ͬͯͳʹ͕خ͍͠ͷʁ 15 https://git-scm.com/about/ ‣ Branching & Merging ͷΈͰɺฒߦͨ͠։ൃ͕༰қʹ ‣
Staging Area ʹΑͬͯɺมߋΛۛຯͰ͖Δ ‣ Data Assurance ͷੑ࣭Ͱɺෳਓ։ൃ͕༰қʹ -
ͦͦ 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/ -
ͦͦ 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 -
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/ -
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/ -
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/ -
CI/CD ͕Ͱ͖Δͱɺͳʹ͕خ͍͠ͷʁ 23 build unit test E2E ςετ Lint ຊ൪
deploy ڥมͷॻ͖͑ ϦϦʔε build QA ڥͷ deploy ssh unit test etc etc .... ‣ ͯ͢ख࡞ۀͰ࣮ߦ͢Δඞཁ͕͋Δ ‣ खॱΛϛεΔͱαʔϏε͕ࢭ·Δ ‣ खݩͰ build ςετ ͢Δ͕͔͔࣌ؒΔ ‣ ਫ਼ਆ͕͢ΓݮΔ..... -
24 ‣ build ςετͯ͠Δؒʹ։ൃ͕Ͱ͖Δ ‣ Slack ͳͲͱ࿈ܞࣦͯ͠ഊͨ͠Β௨ͯ͘͠ΕΔ ‣ push ͢Δ͚ͩͰίϯϐϡʔλ͕શ෦ͬͯ͘ΕΔ
‣ ࣗಈԽ࠷ߴʂ CI/CD ͕Ͱ͖Δͱɺͳʹ͕خ͍͠ͷʁ push -
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 ίʔυϨϏϡʔͬͯԿ͢Δͷʁ 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 ίʔυϨϏϡʔͬͯԿ͢Δͷʁ 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 ίʔυϨϏϡʔͬͯԿ͢Δͷʁ 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. ‣ ૈ୳͠൷Λ͢ΔͷͰͳ͘ɺ ‣ ৬࣍ʹґΒͳ͍ϑϥοτͳ ‣ ΤϯδχΞͨͪͷίϛϡχέʔγϣϯͷ ίʔυϓϩμΫτͷΫΦϦςΟΛ୲อ͢Δ -
32 ίʔυϨϏϡʔͬͯԿ͢Δͷʁ ‣ Nits: ඞਢ͡Όͳ͍͚Ͳɺ·͋ࢦఠ ‣ Ask: ७ਮʹ࣭ͳΜͰ͕͢ ‣ IMO:
ࣗͷҙݟͰ ‣ FYI: ຊےͱؔͳ͍͚Ͳɺใڞ༗͢Δͱ ‣ Must: मਖ਼ඞਢͰ͢Α ͨ·ʹ͏ prefix ͨͪ ϨϏϡʔίϝϯτͷԹײΛ͑Δͷʹศར -
34 ·ͱΊ ‣ GitLab ‣ Code Review ‣ Git ‣
ίʔυͷΫΦϦςΟΛ্͛ΒΕΔ ‣ υΩϡϝϯτΛͤΔ ‣ ΤϯδχΞͷίϛϡχέʔγϣϯͷͰ͋Δ ‣ Test ͳͲΛܧଓతʹ࣮ߦͰ͖Δ ‣ Deploy ΛࣗಈԽͰ͖Δ ‣ ։ൃΛߴԽͰ͖Δ ‣ ҆શʹ։ൃΛਐΊΒΕΔΑ͏ʹͳΔ