Slide 1

Slide 1 text

2023-07-25 CloudNative Days Fukuoka 2023 ϓϨΠϕϯτ ςετͷߴ଎Խͱ඼࣭อূͷୈҰา
 GitHub ActionsͱRSpecͷجຊೖ໳ ࢁԼխਓ

Slide 2

Slide 2 text

• ࢁԼ խਓ • όοΫΤϯυΤϯδχΞ • ॴଐ: גࣜձࣾϚωʔϑΥϫʔυ • GitHub: @M-Yamashita01 • Twitter: @M_Yamashii ࣗݾ঺հ

Slide 3

Slide 3 text

• GitHubʹΑΔ։ൃऀମݧͷௐࠪ݁Ռ • ஗͍ςετͷվળ • Parallel tests gemʹΑΔςετͷߴ଎Խ • CodecovΛ࢖ͬͨΧόϨοδՄࢹԽ • Flaky TestͷൃੜͱରԠ Chapter

Slide 4

Slide 4 text

GitHubʹΑΔ։ൃऀମݧͷௐࠪ݁Ռ Survey reveals AI’s impact on the developer experience,
 Inval Shani, GitHub Sta ff https://github.blog/2023-06-13-survey-reveals-ais-impact-on-the-developer-experience/

Slide 5

Slide 5 text

>we wanted to get a better understanding from developers
 about how new tools—and current work fl ows—are impacting
 the overall developer experience. ৽͍͠πʔϧ΍ݱࡏͷϫʔΫϑϩʔ͕։ൃऀͷମݧશମʹͲͷΑ͏ͳ ӨڹΛٴ΅͍ͯ͠Δ͔ʹ͍ͭͯɺ։ൃऀͷཧղΛਂΊ͍ͨͱߟ͑ͨɻ Survey reveals AI’s impact on the developer experience,
 Inval Shani, GitHub Sta ff https://github.blog/2023-06-13-survey-reveals-ais-impact-on-the-developer-experience/

Slide 6

Slide 6 text

͜ͷௐࠪ݁Ռͷ͏ͪͷ1ͭ

Slide 7

Slide 7 text

>What developers spend the most time on daily ։ൃऀ͕೔ʑ࠷΋࣌ؒΛඅ΍͍ͯ͠Δ͜ͱ Survey reveals AI’s impact on the developer experience,
 Inval Shani, GitHub Sta ff https://github.blog/2023-06-13-survey-reveals-ais-impact-on-the-developer-experience/

Slide 8

Slide 8 text

Survey reveals AI’s impact on the developer experience,
 Inval Shani, GitHub Sta ff https://github.blog/2023-06-13-survey-reveals-ais-impact-on-the-developer-experience/

Slide 9

Slide 9 text

Survey reveals AI’s impact on the developer experience,
 Inval Shani, GitHub Sta ff https://github.blog/2023-06-13-survey-reveals-ais-impact-on-the-developer-experience/

Slide 10

Slide 10 text

> Notably, developers say they spend the same amount of time
 waiting for builds and tests as they do writing new code. ։ൃऀ͕৽͍͠ίʔυΛॻ͘ͷͱಉ͚ͩ͡ͷ࣌ؒΛ Ϗϧυ΍ςετͷͨΊʹඅ΍͍ͯ͠Δ Survey reveals AI’s impact on the developer experience,
 Inval Shani, GitHub Sta ff https://github.blog/2023-06-13-survey-reveals-ais-impact-on-the-developer-experience/

Slide 11

Slide 11 text

ςετ଎౓ͷվળ͸։ൃऀͷ࣌ؒΛ࡞Γग़͢ ↓ ։ൃऀମݧͷ޲্ʹͭͳ͕Δ

Slide 12

Slide 12 text

ࢲ͕ग़ձͬͨ஗͍ςετͷվળ

Slide 13

Slide 13 text

• GitHubʹΑΔௐࠪ݁Ռ • ஗͍ςετͷվળ • Parallel tests gemʹΑΔςετͷߴ଎Խ • CodecovΛ࢖ͬͨΧόϨοδՄࢹԽ • Flaky TestͷൃੜͱରԠ Chapter

Slide 14

Slide 14 text

CI؀ڥͱςετͷঢ়ଶ

Slide 15

Slide 15 text

• GitHub ActionsΛ࢖༻ͨ͠ϫʔΫϑϩʔߏஙࡁΈ • GitHub-hosted runnerΛ࢖༻ • ݹΊͷRailsόʔδϣϯͰ࡞੒͞Εͨίʔυ • RSpecΛ࢖༻ CI؀ڥ

Slide 16

Slide 16 text

• ςετ࣮ߦ߹ܭ࣌ؒɿ30෼ʙ40෼ • ςετ࣮ߦํ๏ɿ௚ྻςετ • ςετέʔεͷϥϯμϜ࣮ߦɿͳ͠ • ΧόϨοδଌఆɿͳ͠ վળલͷঢ়ଶ

Slide 17

Slide 17 text

ςετ͕஗͘
 ίʔυͷ໢ཏੑ΋෼͔Βͳ͍

Slide 18

Slide 18 text

վળʹ޲͚ͨௐࠪ

Slide 19

Slide 19 text

• ϘτϧωοΫͱͳ͍ͬͯΔςετͱվળ༨஍ • ࢖༻Ͱ͖Δվળ޻਺ͱରԠ վળʹ޲͚ͨௐࠪ

Slide 20

Slide 20 text

• RSpecʹ͸஗͍ςετΛग़ྗͰ͖ΔΦϓγϣϯʢ—pro fi le xʣ͕͋Δ ϘτϧωοΫͷςετͷݕ஌

Slide 21

Slide 21 text

ݕ஌ͨ͠஗͍ςετͷվળΛݕ౼

Slide 22

Slide 22 text

ϘτϧωοΫͷςετ͸վળͰ͖Δ͔ʁ ཧղ͕೉͍͠
 ςετίʔυ ςετର৅ͷ
 ίʔυ͕ෳࡶ ςετίʔυͷ
 ໢ཏ۩߹ͷఔ౓͕ෆ໌

Slide 23

Slide 23 text

ϘτϧωοΫͷςετ͸վળͰ͖Δ͔ʁ ཧղ͕೉͍͠
 ςετίʔυ ςετର৅ͷ
 ίʔυ͕ෳࡶ ςετίʔυͷ
 ໢ཏ۩߹ͷఔ౓͕ෆ໌ վળͰ͖Δ͔΋͠Εͳ͍͕ɺ·ͱ·ͬͨ࣌ؒͱଟ͘ͷ޻਺͕ඞཁ

Slide 24

Slide 24 text

• ϘτϧωοΫͱͳ͍ͬͯΔςετͱվળ༨஍ • ࢖༻Ͱ͖Δվળ޻਺ͱରԠ վળʹ޲͚ͨௐࠪ

Slide 25

Slide 25 text

࢖༻Ͱ͖Δվળ޻਺ͱରԠ ཧ૝ ݱ࣮ ޻਺ ·ͱ·ͬͨ޻਺Λ࢖༻Մೳ গͳ͍޻਺Λ࢖༻Մೳ
 (ຊདྷͷλεΫͷ๣ΒͰ࣮ࢪ) ରԠ ϦϑΝΫλϦϯάʹΑΔվળ
 (௕ظతͳ඼࣭ͱ଎౓ͷ޲্) πʔϧΛ࢖༻ͨ͠ςετߴ଎Խ

Slide 26

Slide 26 text

࢖༻Ͱ͖Δվળ޻਺ͱରԠ ཧ૝ ݱ࣮ ޻਺ ·ͱ·ͬͨ޻਺Λ࢖༻Մೳ গͳ͍޻਺Λ࢖༻Մೳ
 (ຊདྷͷλεΫͷ๣ΒͰ࣮ࢪ) ରԠ ϦϑΝΫλϦϯάʹΑΔվળ
 (௕ظతͳ඼࣭ͱ଎౓ͷ޲্) πʔϧΛ࢖༻ͨ͠ςετߴ଎Խ

Slide 27

Slide 27 text

πʔϧΛ࢖༻ͨ͠ςετͷߴ଎Խ

Slide 28

Slide 28 text

• Minitest • Rails 6Ҏ߱ͷฒྻςετػೳ • parallel-tests gem ߴ଎Խख๏ͷީิҰཡ

Slide 29

Slide 29 text

• Minitest • →RSpecΛ࢖͍ͬͯΔͨΊର৅֎ • Rails 6Ҏ߱ͷฒྻςετػೳ • →࢖༻தͷRailsόʔδϣϯ͸6ະຬ • parallel_tests gem • →࠾༻ ߴ଎Խख๏ͷީิൺֱ

Slide 30

Slide 30 text

grosser/parallel_tests

Slide 31

Slide 31 text

• CPUͷ࿦ཧίΞΛ࢖ͬͨฒྻԽ • ϑΝΠϧαΠζ΋͘͠͸࣮ߦ࣌ʹΑΓςετϑΝΠϧΛ෼ׂ • ίΞ͝ͱʹಠཱͨ͠σʔλϕʔεΛ࢖༻ͨ͠ςετ • ಋೖ͕γϯϓϧ parallel_tests

Slide 32

Slide 32 text

parallel_testsͷಋೖ

Slide 33

Slide 33 text

• Gem fi leʹ௥Ճ • database.ymlʹ؀ڥม਺௥Ճ parallel_testsͷಋೖ1

Slide 34

Slide 34 text

• GitHub ActionsϫʔΫϑϩʔʹ
 parallel_testsίϚϯυΛ௥Ճ parallel_testsͷಋೖ2

Slide 35

Slide 35 text

parallel_testsͰ࢖༻͢ΔίΞ਺ݕ౼

Slide 36

Slide 36 text

• GitHub Actions͕ఏڙ͍ͯ͠ΔLinuxͷσϑΥϧτͷίΞ਺͸2ͭ • ͓ۚͷྗͰϥϯφʔͷϚγϯεϖοΫڧԽʹΑΔίΞ਺૿Ճ΋Մೳ ࢖༻ՄೳͳίΞ਺ About larger runners https://docs.github.com/en/actions/using-github-hosted-runners/about-larger-runners

Slide 37

Slide 37 text

• ϩʔΧϧʹͯ2ίΞͱ16ίΞͷ଎౓ൺֱΛͨ͠ͱ͜Ζɺ਺෼ఔ౓ͷࠩ • ݪҼΛௐࠪͰ͖͓ͯΒͣอཹ • ͨͩɺίΞ਺ʹԠͯ͡ςετ͕࣌ؒ1/2ɺ1/4ͱ୹ॖ͞ΕΔΑ͏Ͱ͸ͳͦ͞͏ ίΞ਺ΛͲ͜·Ͱ૿΍͔͢ʁ~଎౓ൺֱฤ~

Slide 38

Slide 38 text

• parallel_testsͰ͸֤ίΞͷςετ
 ऴྃ࣌ʹࣦഊͨ͠ςετ಺༰Λ
 දࣔ͢Δ
 ͨͩ͠ɺଞͷςετ࣮ߦதͷ৔߹
 ϩά͕ྲྀΕͯ͠·͏ • ࠷ޙͷαϚϦʔʹ͸ςετࣦഊ਺
 ͷΈදࣔ ίΞ਺ΛͲ͜·Ͱ૿΍͔͢ʁ~ը໘දࣔฤ~ ίΞ਺΍ςετࣦഊ਺૿ՃʹԠͯ͡ɺϩά୳ࡧʹख͕͔͔ͬͯ͠·͏

Slide 39

Slide 39 text

2ίΞͰे෼ͦ͏

Slide 40

Slide 40 text

parallel_testsΛ࢖༻ͨ͠ςετ࣮ߦ݁Ռ 10෼ʙ15෼ఔ౓ʹ୹ॖ 🎉 30෼ʙ40෼͔͔͍ͬͯͨςετ

Slide 41

Slide 41 text

• GitHubʹΑΔௐࠪ݁Ռ • ஗͍ςετͷվળ • Parallel tests gemʹΑΔςετͷߴ଎Խ • CodecovΛ࢖ͬͨΧόϨοδՄࢹԽ • Flaky TestͷൃੜͱରԠ Chapter

Slide 42

Slide 42 text

ίʔυΧόϨοδ > ιϑτ΢ΣΞςετͷਐḿΛද͢ई౓ͷҰͭͰɺςετର৅ͷιʔείʔυͷ ͏ͪɺͲͷఔ౓ͷׂ߹ͷίʔυ͕ςετ͞Ε͔ͨΛද͢΋ͷɻ ςετΧόϨοδ ʲtest coverageʳ ίʔυΧόϨοδ / code coverage
 IT༻ޠࣙయ e-Words https://e-words.jp/w/%E3%83%86%E3%82%B9%E3%83%88%E3%82%AB%E3%83%90%E3%83%AC%E3%83%83%E3%82%B8.html

Slide 43

Slide 43 text

ΧόϨοδͳ͠ ↓ ίʔυ͕ςετͰΧόʔ͞Ε͍ͯΔ͔෼͔Βͳ͍ ↓ मਖ਼ΛͨΊΒ͏

Slide 44

Slide 44 text

ՄࢹԽ͔Β࢝ΊΑ͏

Slide 45

Slide 45 text

ΧόϨοδՄࢹԽπʔϧ

Slide 46

Slide 46 text

• Codecov্ͰίʔυΧόϨοδͷଌఆ΍දࣔɺमਖ਼લޙͷΧόϨοδΛ෼ੳ ͯ͘͠ΕΔαʔϏε • Pull Requestʹमਖ਼લޙͷΧόϨοδΛίϝϯτͱͯ͠දࣔ͢Δ Codecov Codecov https://about.codecov.io/

Slide 47

Slide 47 text

• GitHubͱCodecovͱͷ
 ࿈ܞΛઃఆʢৄࡉ͸ׂѪʣ • Gem fi leɺspec_helper.rbʹ௥ه Codecovͷಋೖ1

Slide 48

Slide 48 text

• GitHub ActionsϫʔΫϑϩʔʹ
 codecov/codecov-actionͷ
 εςοϓΛ௥Ճ Codecovͷಋೖ2

Slide 49

Slide 49 text

ΧόϨοδදࣔྫ

Slide 50

Slide 50 text

໢ཏ཰ɺ100%Λҡ࣋ͨ͘͠ͳΓ·͢ΑͶ

Slide 51

Slide 51 text

਺஋ʹͩ͜ΘΔ͜ͱ͸
 ͋·Γ͓͢͢Ί͠·ͤΜ

Slide 52

Slide 52 text

> ໢ཏ཰͸ϓϩμΫγϣϯɾίʔυ͕࣮ߦ͞Εͨ͜ͱΛ͚ࣔͩ͢Ͱɺ࣮ߦ݁Ռ͕ ֬ೝ͞Εͨ͜ͱΛอূ͢ΔΘ͚Ͱ͸ͳ͍
 ɾɾɾதུɾɾɾ
 > ໢ཏ཰͸ςετɾίʔυͷ࣭͕ѱ͍͜ͱΛ൑அ͢Δͷʹ͸ޮՌ͕͋ΔͷͰ͢ ͕ɺςετɾίʔυͷ࣭͕ྑ͍͜ͱΛ൑அ͢Δʹ͸޲͍͍ͯ·ͤΜɻ ΧόϨοδͱͷ޲͖߹͍ํ ୯ମςετͷߟ͑ํ/࢖͍ํ,
 Vladimir Khorikov,ਢాஐ೭,
 P17ɺP19

Slide 53

Slide 53 text

ΧόϨοδ͸໨҆ͱͯ͠࢖͍ ࣭ͷྑ͍ίʔυΛ࡞ΔͨΊͷ଍͕͔Γͱ͢Δ

Slide 54

Slide 54 text

• GitHubʹΑΔௐࠪ݁Ռ • ஗͍ςετͷվળ • Parallel tests gemʹΑΔςετͷߴ଎Խ • CodecovΛ࢖ͬͨΧόϨοδՄࢹԽ • Flaky TestͷൃੜͱରԠ Chapter

Slide 55

Slide 55 text

Flaky TestͷൃੜͱରԠ

Slide 56

Slide 56 text

Flaky Test Flaky Tests at Google and How We Mitigate Them
 John Micco https://testing.googleblog.com/2016/05/ fl aky-tests-at-google-and-how-we.html

Slide 57

Slide 57 text

> We de fi ne a " fl aky" test result as a test that exhibits both a passing and a failing result with the same code. ࢲͨͪ͸ɺ" fl aky" ςετ݁ՌΛɺಉ͡ίʔυͰ߹֨ͱෆ߹֨ͷ྆ํͷ ݁ՌΛࣔ͢ςετͱఆ͍ٛͯ͠·͢ɻ Flaky Tests at Google and How We Mitigate Them
 John Micco https://testing.googleblog.com/2016/05/ fl aky-tests-at-google-and-how-we.html

Slide 58

Slide 58 text

ͭ·Γɺِཅੑ

Slide 59

Slide 59 text

> ɾϓϩμΫγϣϯɾίʔυʹજΉ໰୊Λղܾ͠Α͏ͱ͢Δ։ൃऀͷೳྗͱҙࢥ ΛऑΊͯ͠·͏ɻͳͥͳΒ։ൃऀ͸ӕͷܯࠂ(ςετͷؒҧࣦͬͨഊ)ʹ׳Εͯ͠ ·͍ɺͦͷܯࠂʹ஫ҙΛ෷Θͳ͘ͳͬͯ͠·͏͔ΒͰ͋Δɻ
 ɾςετΛ৴པͰ͖ΔηʔϑςΟɾωοτͱͯ͠ݟΔ͜ͱ͕Ͱ͖ͳ͘ͳΓɺͦ ͷςετ΁ͷ৴པੑ͕ࣦΘΕΔ͜ͱʹͳΔɻ ِཅੑͷ໰୊఺ ୯ମςετͷߟ͑ํ/࢖͍ํ,
 Vladimir Khorikov,ਢాஐ೭,
 P129

Slide 60

Slide 60 text

ࠓճͷέʔε

Slide 61

Slide 61 text

• parallel_tests࠾༻ʹΑΓɺςετॱ͕มΘΔ͜ͱ͕ଟ͘ͳͬͨ • ίʔυमਖ਼࣌ʹશؔ͘܎ͳ͍ςετ͕མͪΔΑ͏ʹͳͬͨ • ࠶࣮ߦ͢Δͱύε͢Δ͜ͱ͕͋Δ Flaky Testͷൃੜ

Slide 62

Slide 62 text

ൃݟͨ͠Flaky Testͷ֓ཁ • ࢦఆ೔࣌Λ࣋ͭϨίʔυ࡞੒ • UTCͷࢦఆ೔࣌Ҏલͷ
 ϨίʔυΛऔಘ͢Δςετ • ผςετͰλΠϜκʔϯ͕
 มߋ͞Ε͓ͯΓࣦഊ

Slide 63

Slide 63 text

• ࠜຊݪҼͰ͋ΔλΠϜκʔϯมߋՕॴͷൃݟ͸ࠔ೉ • ผςετʹґଘ͢Δͭ͘ΓΛ΍ΊΔ • ೔࣌Λ࢖͏ςετͰ͸ɺtravel_toͰ೔࣌ࢦఆͷӨڹൣғΛہॴԽ͢Δ Flaky Test΁ͷରԠ

Slide 64

Slide 64 text

Flaky Test΁ͷରԠ • ࢦఆͨ͠೔࣌Λ࡞੒ • travel_toΛ࢖͍ɺͦͷ೔࣌Λ
 ΋ͱʹͯ͠ϨίʔυΛ࡞੒͠ɺ
 ςετΛ࣮ߦ

Slide 65

Slide 65 text

·ͱΊ

Slide 66

Slide 66 text

• ஗͍ςετʹର͠ɺςετߴ଎ԽͱΧόϨοδՄࢹԽΛಋೖ • Flaky Test΁ͷରԠํ๏ • ࠓճ঺հͨ͠಺༰͸଎౓ͱ඼࣭޲্ͷ࢝·ΓͰ͋ΔͨΊ
 ϑΟʔυόοΫΛ΋ͱʹ࣭ͨ͠ͷྑ͍ίʔυ࡞੒ʹͭͳ͛Δ͜ͱ ·ͱΊ

Slide 67

Slide 67 text

͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ

Slide 68

Slide 68 text

• Survey reveals AI’s impact on the developer experience • ςετΧόϨοδ • ୯ମςετͷߟ͑ํ/࢖͍ํ • Codecov • Flaky Tests at Google and How We Mitigate Them ࢀߟࢿྉ