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

効果的な静的解析の CI導入パターンを求めて / Great static analysis with CI

効果的な静的解析の CI導入パターンを求めて / Great static analysis with CI

F075c5dfe92334b5031d4da5dc0c9251?s=128

Yuichi Sugiyama

December 11, 2020
Tweet

Transcript

  1. ޮՌతͳ੩తղੳͷ CIಋೖύλʔϯΛٻΊͯ PHPConference 2020 αΠϘ΢ζגࣜձࣾɹਿࢁ ༞Ұ @oogFranz #phpcon #track2

  2. Whoami • ਿࢁ ༞Ұ @oogFranz • αΠϘ΢ζ6೥໨ΤϯδχΞ • େاۀ޲͚άϧʔϓ΢ΣΞGaroon࡞ͬͯΔ •

    ෳۀδϟζϛϡʔδγϟϯ@MASHݭָஂ • ϦϞʔτϫʔΫͷӨڹͰ඘͕ੜ͑ͨ 
  3. MASH meets GHIBLI JAZZ • https://youtu.be/ZEtTwGen3fI • δϒϦۂͷδϓγʔδϟζΞϨϯδCD • ੋඇ͓ങ͍ٻΊ͍ͩ͘͞ʂ

    
  4. αΠϘ΢ζ Garoon ͷද޲͖આ໌ • େن໛޲͚ͷάϧʔϓ΢ΣΞ • ੜ࢈ੑɾνʔϜϫʔΫ޲্ͷࢧԉ 

  5. αΠϘ΢ζ Garoon ͷཪଆઆ໌ • PHPͱMySQLͰͰ͖ͯΔWebΞϓϦέʔγϣϯ • ։ൃ19೥໨ • PHP͸ 4͔Β7.4ʹʢPHP

    8.0Ҡߦ΋ਐΊͯͧ͘ʂʣ • PHPͷίʔυ͸180ສߦ͘Β͍ 
  6. αΠϘ΢ζ Garoon ͷཪଆઆ໌ • PHPͱMySQLͰͰ͖ͯΔWebΞϓϦέʔγϣϯ • ։ൃ19೥໨ • PHP͸ 4͔Β7.4ʹʢPHP

    8.0Ҡߦ΋ਐΊͯͧ͘ʂʣ • PHPͷίʔυ͸180ສߦ͘Β͍  ͳ͔ͳ͔ϨΨγʔʂ
  7. ϨΨγʔʹཱͪ޲͔͓͏ʂ ϨΨγʔίʔυΛ៉ྷʹͯ͠΍Δʂ ·ͣ͸طଘ࣮૷ΛΑ͘ಡΜͰΈΑ͏ʂ 

  8. খੴʹͭ·ͣ͘ ܕએݴ΋ PHPDoc΋ͳͯ͘ίʔυ͕௥͑ͳ͍ɻɻɻ Ҿ਺ʹΑͬͯ͸յΕΔϝιου͕͋Δɻɻɻ ͜͜ͷίʔυͣͬͱಡΜͰ͚ͨͲɺ ͦ΋ͦ΋୭΋ݺͼग़ͯ͠ͳ͍ɻɻɻʁ 

  9. খੴʹͭ·ͣ͘ ܕએݴ΋ PHPDoc΋ͳͯ͘ίʔυ͕௥͑ͳ͍ɻɻɻ Ҿ਺ʹΑͬͯ͸յΕΔϝιου͕͋Δɻɻɻ ͜͜ͷίʔυͣͬͱಡΜͰ͚ͨͲɺ ͦ΋ͦ΋୭΋ݺͼग़ͯ͠ͳ͍ɻɻɻʁ  ຊ࣭తͳ໰୊ʢઃܭͳͲʣʹͨͲΓண͘લʹɺ খ͞ͳ໰୊͕ؾʹͳͬͯίʔυϦʔσΟϯά͕ਐ·ͳ͍

  10. ϨΨγʔʹཱͪ޲͔͏ɺͦͷؒʹ΋ • ৽͍͠ίʔυ͕ͲΜͲΜ૿͍͑ͯ͘ • طଘίʔυΛ౿ऻ͞ΕΔͷͰɺ ͭ·͖ͮ΍͍͢ίʔυ͕૿͑Δ • ϝϯόʔʹΑͬͯεΩϧࠩ΋͋Δ 

  11. ϨΨγʔʹཱͪ޲͔͏ɺͦͷؒʹ΋ • ৽͍͠ίʔυ͕ͲΜͲΜ૿͍͑ͯ͘ • طଘίʔυΛ౿ऻ͞ΕΔͷͰɺ ͭ·͖ͮ΍͍͢ίʔυ͕૿͑Δ • ϝϯόʔʹΑͬͯεΩϧࠩ΋͋Δ  খੴ͕૿͑ͳ͍Α͏ʹɺͤΊͯ৽نίʔυ͸៉ྷʹ͍ͨ͠

  12. খੴΛ·ͣर͏ɾখੴΛ૿΍͞ͳ͍ • খ͍͞໰୊͕ଟ͍ͱখ͍͞໰୊Ͱؾ͕ࢄΔ • খ͍͞໰୊Λ͋Β͔͡ΊݮΒ͢ɾ૿΍͞ͳ͍ ͜ͱͰΑΓॏେͳ໰୊ʹऔΓ૊Έ΍͘͢ͳΔ 

  13. খੴΛ·ͣर͏ɾখੴΛ૿΍͞ͳ͍ • খ͍͞໰୊͕ଟ͍ͱখ͍͞໰୊Ͱؾ͕ࢄΔ • খ͍͞໰୊Λ͋Β͔͡ΊݮΒ͢ɾ૿΍͞ͳ͍ ͜ͱͰΑΓॏେͳ໰୊ʹऔΓ૊Έ΍͘͢ͳΔ ੩తղੳπʔϧΛ$*ʹ૊ΈೖΕΑ͏ʂ 

  14. ࠓ೔ͷͬ͘͟Γ࿩ • ੩తղੳͷ CI ΛΑ͘͢Δ࿩ • CIࢹ఺த৺ • ੩తղੳࣗମΛΑ͘͢Δ࿩΋աڈʹ͠·ͨ͠ 

    https://speakerdeck.com/oogfranz/how-to-make-your-static-analysis-strong
  15. ੩తղੳͱ͸ʁ • ίʔυΛ࣮ߦͤͣʹߦ͏ݕূ • ͭ·͖ͮͦ͏ͳখੴΛissueͱͯ͠ݟ͚ͭͯ͘ΕΔ • όάʹͳΓͦ͏ͳίʔυɺո͍͠ίʔυͷݕ஌ • ʢ͍͍ͩͨʣૣ͍ •

    ʢ͍͍ͩͨʣࣗಈԽ͕͠΍͍͢ 
  16. ͲΜͳখੴɾissueΛݟ͚ͭͯ͘ΕΔʁ • ܕͷෆ੔߹ • ଘࡏ͠ͳ͍ϝιουͷݺͼग़͠ • ഑ྻͰͳ͍஋ʢboolean, nullͳͲʣ΁ͷ഑ྻΞΫηε • ෆཁίʔυ

    
  17.  ੲͷPHPʹ͋Γ͕ͪɺࣦഊͨ͠Βfalse

  18.  ੲͷPHPʹ͋Γ͕ͪɺࣦഊͨ͠Βfalse falseʹͳ͍ͬͯΔͱɺҙਤͤͣ΍ΒΕΔ

  19.  ੲͷPHPʹ͋Γ͕ͪɺࣦഊͨ͠Βfalse falseʹͳ͍ͬͯΔͱɺҙਤͤͣ΍ΒΕΔ ੩తղੳπʔϧ͕ڭ͑ͯ͘ΕΔʂ

  20. ςετ͕ͳ͍ϨΨγʔͰ΋ • ੩తղੳπʔϧ͸ςετίʔυ͕ͳͯ͘΋ಋೖՄೳ • ϓϩμΫτʹʢ΄΅ʣΑΒͣɺಋೖՄೳ • ϨΨγʔϓϩμΫτ͸ԟʑʹͯ͠ςετίʔυ͕ͳ͍ • ςετίʔυ͕ͳͯ͘΋όά΍໰୊Λݟ͚ͭΒΕΔ 

  21. ςετ͕ͳ͍ϨΨγʔͰ΋ • ੩తղੳπʔϧ͸ςετίʔυ͕ͳͯ͘΋ಋೖՄೳ • ϓϩμΫτʹʢ΄΅ʣΑΒͣɺಋೖՄೳ • ϨΨγʔϓϩμΫτ͸ԟʑʹͯ͠ςετίʔυ͕ͳ͍ • ςετίʔυ͕ͳͯ͘΋όά΍໰୊Λݟ͚ͭΒΕΔ 

    ੩తղੳπʔϧΛ$*ʹಋೖ͠Α͏ʂ
  22. Q. CIಋೖ͕ͳͥେࣄ͔ʁ 

  23. Q. CIಋೖ͕ͳͥେࣄ͔ʁ • શϝϯόʔ͕࠷௿ݶͷΫΥϦςΟͰίʔυΛॻ͚Δ • ϑΟʔυόοΫϧʔϓ͕୹͘ͳΔ 

  24. ϑΟʔυόοΫϧʔϓͱ͸ʁ • ΤϯδχΞɾϓϩμΫτͷԿΒ͔ͷ׆ಈʹɺ ϑΟʔυόοΫΛಘͯɺ੡඼ʹ൓ө͢ΔαΠΫϧ • e.g. • ੡඼ΛϦϦʔεͯ͠ސ٬ͷ൓ԠΛݟΔ • ॻ͍ͨίʔυΛϚχϡΞϧςετ͢Δ

    • ίʔυϨϏϡʔΛ͢Δ 
  25. ϑΟʔυόοΫϧʔϓͷ֊૚ IUUQTXXXBHJMFDPOOFDUJPODPNBSUJDMFVTJOHGFFECBDLMPPQTCPPTUEFWFMPQNFOUMJGFDZDMFTΑΓҾ༻ 

  26. ϑΟʔυόοΫϧʔϓͷ௕͞ • ϑΟʔυόοΫ͸ૣ͚Ε͹ૣ͍΄Ͳྑ͍ • ੩తղੳͷCI͸΋ͬͱ΋୹͍ϧʔϓͰ ϑΟʔυόοΫΛಘΒΕΔ • ίϛοτ୯ҐͰ੩తղੳͷ݁ՌΛϑΟʔυόοΫ͠Α͏ 

  27. ϑΟʔυόοΫͷ࣭ • ͙͢ʹϑΟʔυόοΫ͕དྷΔͷͰϑΟʔυόοΫͷ࣭͕େࣄ • ཧղɺमਖ਼͸༰қʹ • ݟա͝͞Εͳ͍Α͏ʹ • ա৒ʹͳΒͳ͍Α͏ʹ •

    Ͱ΋ෆ଍͠ͳ͍Α͏ʹ 
  28. ϑΟʔυόοΫͷ࣭ • ͙͢ʹϑΟʔυόοΫ͕དྷΔͷͰϑΟʔυόοΫͷ࣭͕େࣄ • ཧղɺमਖ਼͸༰қʹ • ݟա͝͞Εͳ͍Α͏ʹ • ա৒ʹͳΒͳ͍Α͏ʹ •

    Ͱ΋ෆ଍͠ͳ͍Α͏ʹ  $*ಋೖ͢Δ͚ͩͰ΋Ғ͍͕ɺ ϑΟʔυόοΫΛҙࣝͯ͠ಋೖ͠Α͏ʂ
  29. ΍ͬͯΈͨ

  30. Psalm • https://psalm.dev/ • ʢͨͿΜʣαʔϜ /sάːm, sɑ:lm/ ͱൃԻ͢Δ • ࢍඒՎɺ੟Վɺࢻฤͱݴ͏ҙຯ

    • vimeo͕։ൃ • ઃఆϑΝΠϧ͸XML 
  31. ਘৗ͡Όͳ͍issue਺ 

  32. ਘৗ͡Όͳ͍issue਺  ղੳ݁ՌΛॖখදࣔͨ͠΋ͷʢҰ෦ʣ

  33. Phan • https://github.com/phan/phan • ʢͨͿΜʣϑΝϯ(/fan/)ͱൃԻ͢Δ • ར༻ʹphp-astͷ֦ு͕ඞཁ • ઃఆϑΝΠϧ͸PHPϑΝΠϧ •

    Etsyࣾͷ։ൃ͕ݩ 
  34. ਘৗ͡Όͳ͍issue਺ 

  35. ਘৗ͡Όͳ͍issue਺ ղੳ݁ՌΛॖখදࣔͨ͠΋ͷʢҰ෦ʣ 

  36. ਘৗ͡Όͳ͍issue਺ • ͦΕ·Ͱ੩తղੳͰอޢ͞Ε͍ͯͳ͍ίʔυ͸ جຊతʹແ਺ͷissue͕ใࠂ͞ΕΔ • ·ͱ΋ʹऔΓ߹͏ͱ৺͕ંΕΔ 

  37. ਘৗ͡Όͳ͍issue਺ • ͦΕ·Ͱ੩తղੳͰอޢ͞Ε͍ͯͳ͍ίʔυ͸ جຊతʹແ਺ͷissue͕ใࠂ͞ΕΔ • ·ͱ΋ʹऔΓ߹͏ͱ৺͕ંΕΔ  େྔͷJTTVFΛ͍ͳͭͭ͠ɺ ੩తղੳͷϝϦοτΛಘΔ࢓૊Έ͕ඞཁ

  38. େྔͷissueʹཱͪ޲͔͏ • ੩తղੳπʔϧʹ͸ಛఆͷissueΛແࢹ͢Δɺ ઃఆʢignore, suppressʣ͕༻ҙ͞Ε͍ͯΔ • ͜ΕΛར༻ͯ͠ΈΔ 

  39. Psalm  https://psalm.dev/docs/running_psalm/dealing_with_code_issues/#config-suppression

  40. Psalm  https://psalm.dev/docs/running_psalm/dealing_with_code_issues/#config-suppression type="suppress"Ͱ ཈੍ ϑΝΠϧ΍σΟϨΫτϦͱ͍ͬͨ୯ҐͰࢦఆՄೳ

  41. Phan 

  42. Phan  suppress_issue_typesͰࢦఆ

  43. PHPStan 

  44. PHPStan • https://github.com/phpstan/phpstan • ݱঢ়ͰҰ൪ਓؾͷ੩తղੳπʔϧ • ઃఆϑΝΠϧ͸.neonͱ͍͏yamlͷΑ͏ͳϑΝΠϧ • pro൛͕͋ΔʢओʹWeb UIʣ

    
  45. PHPStan  ΤϥʔϝοηʔδΛਖ਼نදݱͰࢦఆ ϑΝΠϧɾσΟϨΫτϦͰର৅Λࢦఆ

  46. ͻͱ·ͣsuppress • ੩తղੳͷCIΛಋೖ͢Δ͜ͱΛ࠷༏ઌ͢ΔͳΒ͋Γ • ͙͢ʹ࣏ͤͳ͍ΤϥʔΛ͢΂ͯಥͬࠐΊ͹ɺ CIͰΤϥʔʹͳΒͳ͘ͳΔ 

  47. suppressͷ໰୊఺ • suppressͷϧʔϧ͸େຯ͔ɺෳࡶʹͳΔɻ • େຯͳઃఆ͸ɺϓϩμΫτશମʹద༻͞ΕΔͨΊɺ ৽نͷίʔυͷ੩తղੳ͕ऑ·ͬͯ͠·͏ • ෳࡶͳϧʔϧ͸ద༻ൣғͷमਖ਼ͳͲ͕ඇৗʹେม 

  48. suppressϧʔϧͷϝϯςφϯε • suppress͞ΕΔൣғ͸গͳ͍ͨ͘͠ • suppressͷϧʔϧ͸γϯϓϧʹ͍ͨ͠ ʢର৅ϑΝΠϧɺσΟϨΫτϦɺͳͲʣ 

  49. suppressϧʔϧͷϝϯςφϯε • suppress͞ΕΔൣғ͸গͳ͍ͨ͘͠ • suppressͷϧʔϧ͸γϯϓϧʹ͍ͨ͠ ʢର৅ϑΝΠϧɺσΟϨΫτϦɺͳͲʣ  ࣗಈͰTVQQSFTTϧʔϧ͕ߋ৽͞ΕΔͱخ͍͠

  50. suppressϧʔϧͷϝϯςφϯε • suppress͞ΕΔൣғ͸গͳ͍ͨ͘͠ • suppressͷϧʔϧ͸γϯϓϧʹ͍ͨ͠ ʢର৅ϑΝΠϧɺσΟϨΫτϦɺͳͲʣ  ࣗಈͰTVQQSFTTϧʔϧ͕ߋ৽͞ΕΔͱخ͍͠ ੩తղੳπʔϧͷCBTFMJOF $*πʔϧͷΩϟογϡ

    ͷ૊Έ߹ΘͤͰղܾʂ
  51. baselineͷಋೖ • baseline: suppress ruleΛࣗಈੜ੒͢Δػೳ • طଘͷissueΛه࿥͠ɺ੩తղੳ࣌ʹ͸ ه࿥͞ΕͨissueΛແࢹ͢Δ • 

    $ vendor/bin/psalm --save-baseline baseline.xml $ vendor/bin/phan --save-baseline baseline.php $ vendor/bin/phpstan analyse --generate-baseline phpstan-baseline.neon
  52. CIͷΩϟογϡ • GitHub Actions, CircleCIͱ͍ͬͨCIπʔϧʹ͸ աڈͷδϣϒ΍ଞͷδϣϒͷσʔλΛΩϟογϡ͠ɺ ࠶ར༻͢Δ࢓૊Έ͕͋Δ • ΩʔͱϑΝΠϧΛࢦఆͯ͠อଘ •

    ΩʔΛ෦෼Ұகͯ͠औಘͤ͞Δ͜ͱͰɺ աڈͷδϣϒͷσʔλΛར༻Ͱ͖Δ 
  53. উखʹڧ͘ͳΔ੩తղੳ 1. ίϛοτͷͨͼʹɺbaselineΛར༻ͯ͠ ੩తղੳΛ࣮ߦ͢Δ 2. issue͕ͳ͚Ε͹ɺbaselineΛߋ৽͢Δ 3. ࣍ͷίϛοτͰ͸৽͍͠baselineΛར༻ͯ͠ɺ ੩తղੳΛߦ͏ 

  54. উखʹڧ͘ͳΔ੩తղੳͷྫ • CircleCI + Phan ͷྫ • ଞͷCIπʔϧʢGitHub ActionsͳͲʣ΍ ଞͷ੩తղੳπʔϧʢPHPStan,

    PsalmͳͲʣͰ΋ Ԡ༻Մೳʢͷ͸ͣʣ 
  55. baselineΛར༻ͯ͠੩తղੳ  phan-load-baseline: docker: - image: docker-registory.cybozu.private/phan:X.Y.Z steps: - checkout

    - restore_cache: name: Restore baseline keys: - v1-phan-baseline-{{ .BRANCH }}- - v1-phan-baseline-develop- - run: name: Phan command: | if [[ -f ~/phan_baseline.php ]]; then phan ./ --load-baseline ~/phan_baseline.php fi
  56. baselineΛར༻ͯ͠੩తղੳ  phan-load-baseline: docker: - image: docker-registory.cybozu.private/phan:X.Y.Z steps: - checkout

    - restore_cache: name: Restore baseline keys: - v1-phan-baseline-{{ .BRANCH }}- - v1-phan-baseline-develop- - run: name: Phan command: | if [[ -f ~/phan_baseline.php ]]; then phan ./ --load-baseline ~/phan_baseline.php fi CIʢCircleCIʣͷΩϟογϡ͔Β baselineΛऔಘ
  57. baselineΛར༻ͯ͠੩తղੳ  phan-load-baseline: docker: - image: docker-registory.cybozu.private/phan:X.Y.Z steps: - checkout

    - restore_cache: name: Restore baseline keys: - v1-phan-baseline-{{ .BRANCH }}- - v1-phan-baseline-develop- - run: name: Phan command: | if [[ -f ~/phan_baseline.php ]]; then phan ./ --load-baseline ~/phan_baseline.php fi ։ൃதϒϥϯνʹbaseline͕ ͋Ε͹ͦΕΛར༻
  58. baselineΛར༻ͯ͠੩తղੳ  phan-load-baseline: docker: - image: docker-registory.cybozu.private/phan:X.Y.Z steps: - checkout

    - restore_cache: name: Restore baseline keys: - v1-phan-baseline-{{ .BRANCH }}- - v1-phan-baseline-develop- - run: name: Phan command: | if [[ -f ~/phan_baseline.php ]]; then phan ./ --load-baseline ~/phan_baseline.php fi ։ൃதϒϥϯνʹbaseline͕ ͳ͚Ε͹developϒϥϯνΛར༻
  59. baselineΛར༻ͯ͠੩తղੳ  phan-load-baseline: docker: - image: docker-registory.cybozu.private/phan:X.Y.Z steps: - checkout

    - restore_cache: name: Restore baseline keys: - v1-phan-baseline-{{ .BRANCH }}- - v1-phan-baseline-develop- - run: name: Phan command: | if [[ -f ~/phan_baseline.php ]]; then phan ./ --load-baseline ~/phan_baseline.php fi ੩తղੳΛ࣮ߦʢ͜͜Ͱ͸Phanʣ
  60. baselineΛར༻ͯ͠੩తղੳ  phan-load-baseline: docker: - image: docker-registory.cybozu.private/phan:X.Y.Z steps: - checkout

    - restore_cache: name: Restore baseline keys: - v1-phan-baseline-{{ .BRANCH }}- - v1-phan-baseline-develop- - run: name: Phan command: | if [[ -f ~/phan_baseline.php ]]; then phan ./ --load-baseline ~/phan_baseline.php fi baseline͕ݟ͔ͭΒͳ͍࣌͸Skip
  61. baselineΛར༻ͯ͠੩తղੳ  phan-load-baseline: docker: - image: docker-registory.cybozu.private/phan:X.Y.Z steps: - checkout

    - restore_cache: name: Restore baseline keys: - v1-phan-baseline-{{ .BRANCH }}- - v1-phan-baseline-develop- - run: name: Phan command: | if [[ -f ~/phan_baseline.php ]]; then phan ./ --load-baseline ~/phan_baseline.php fi Ωϟογϡʹอଘ͞Ε͍ͯͨbaselineΛ ར༻ͯ͠੩తղੳΛ࣮ߦ
  62. baselineΛߋ৽͢Δ  phan-save-baseline: docker: - image: docker-registory.cybozu.private/phan:X.Y.Z steps: - checkout

    - run: name: Save Phan baseline command: | set +e phan ./ --save-baseline ~/phan_baseline.php exit 0 - save_cache: key: v1-phan-baseline-{{ .BRANCH }}-{{ .Revision }} paths: ~/phan_baseline.php
  63. phan-save-baseline: docker: - image: docker-registory.cybozu.private/phan:X.Y.Z steps: - checkout - run:

    name: Save Phan baseline command: | set +e phan ./ --save-baseline ~/phan_baseline.php exit 0 - save_cache: key: v1-phan-baseline-{{ .BRANCH }}-{{ .Revision }} paths: ~/phan_baseline.php baselineΛߋ৽͢Δ  baselineΛ࡞੒
  64. phan-save-baseline: docker: - image: docker-registory.cybozu.private/phan:X.Y.Z steps: - checkout - run:

    name: Save Phan baseline command: | set +e phan ./ --save-baseline ~/phan_baseline.php exit 0 - save_cache: key: v1-phan-baseline-{{ .BRANCH }}-{{ .Revision }} paths: ~/phan_baseline.php baselineΛߋ৽͢Δ  ੩తղੳπʔϧʹΑͬͯ͸issue͕ଘࡏ͢Δ ͱऴྃίʔυ͕1Λฦ͢ͷͰέΞ͕ඞཁ
  65. phan-save-baseline: docker: - image: docker-registory.cybozu.private/phan:X.Y.Z steps: - checkout - run:

    name: Save Phan baseline command: | set +e phan ./ --save-baseline ~/phan_baseline.php exit 0 - save_cache: key: v1-phan-baseline-{{ .BRANCH }}-{{ .Revision }} paths: ~/phan_baseline.php baselineΛߋ৽͢Δ  baselineΛΩϟογϡʹอଘ
  66. baselineͷϦηοτ • ੩తղੳπʔϧͷόʔδϣϯΞοϓͳͲͰ baselineΛϦηοτ͍͕ͨ࣌͋͠Δ • ΩϟογϡͷΩʔ໊Λมߋ͢Δ  - save_cache: key:

    v1-phan-baseline-{{ .BRANCH }}-{{ .Revision }} paths: ~/phan_baseline.php - save_cache: key: v2-phan-baseline-{{ .BRANCH }}-{{ .Revision }} paths: ~/phan_baseline.php ΩϟογϡΩʔ໊Λߋ৽͢Δ
  67. ੩తղੳ͕উखʹڧ͘ͳΔʂ

  68. ΋ͬͱ੩తղੳΛΑ͍ͨ͘͠ʂ

  69. • ϑΟʔυόοΫΛվળ͢Δ  ͞ΒʹνʔϜͷ੩తղੳମݧΛΑ͘͢ΔTips ཧղ༰қʹ͢Δ ϑΟʔυόοΫΛૣ͘͢Δ ݎ࿚ʹ͢Δ

  70. • ϑΟʔυόοΫΛվળ͢Δ  ͞ΒʹνʔϜͷ੩తղੳମݧΛΑ͘͢ΔTips ཧղ༰қʹ͢Δ ϑΟʔυόοΫΛૣ͘͢Δ ݎ࿚ʹ͢Δ

  71. ੩తղੳʹ͔͔Δ࣌ؒΛ୹͘͢Δ • CIͰ஗͍ͱ͜ΖʢϘτϧωοΫʣΛվળ͢Δ • ϑΟʔυόοΫϧʔϓ͸ૣ͚Ε͹ૣ͍΄Ͳྑ͍ • GaroonͰ͸ • git clone

    • ੩తղੳͷ࣮ߦ • ͕஗͔ͬͨ 
  72. git cloneΛૣ͘͢Δ • ௕͘։ൃ͍ͯ͠ΔϓϩμΫτͰ͸git clone͕஗͍ • →shallow cloneΛ͢Δʢ࠷৽ίϛοτ͚ͩऔಘ͢Δʣ • Garoonͩͱ໿6ഒૣ͘ͳΔʢ25.2

    ඵ → 4.0 ඵʣ  $ git clone --depth=1 --branch ${CIRCLE_BRANCH} \ --single-branch ${CIRCLE_REPOSITORY_URL}
  73. ੩తղੳʹ͔͔Δ࣌ؒΛ୹͘͢Δ • ࠩ෼ͷ͋ͬͨϑΝΠϧ͚ͩ੩తղੳΛ͔͚Δ • →shallow cloneΛ͍ͯ͠Δͱ git diff ͕Ͱ͖ͳ͍ •

    ผͷํ๏ͰdiffΛऔಘ͢Δ • →GitHub ͷϓϧϦΫऔಘ APIΛ࢖͏ 
  74. ϓϧϦΫऔಘ GitHub API  $curl -H "Authorization: token ${GITHUB_API_TOKEN}" \

    -H 'Accept: application/vnd.github.v3.diff' \
 https://github.dev.cybozu.co.jp/api/v3/repos/garoon/garoon/pulls/14386 diff --git a/source/page/master/sample.php b/source/page/master/sample.php index b644b6edbf5..03624413a6a 100644 --- a/source/page/master/sample.php +++ b/source/page/master/sample.php @@ -1,3 +1,4 @@ +echo "diff test"
  75. ϓϧϦΫऔಘ GitHub API  $curl -H "Authorization: token ${GITHUB_API_TOKEN}" \

    -H 'Accept: application/vnd.github.v3.diff' \
 https://github.dev.cybozu.co.jp/api/v3/repos/garoon/garoon/pulls/14386 diff --git a/source/page/master/sample.php b/source/page/master/sample.php index b644b6edbf5..03624413a6a 100644 --- a/source/page/master/sample.php +++ b/source/page/master/sample.php @@ -1,3 +1,4 @@ +echo "diff test" media typeͷࢦఆͰdiff͕औΕΔ https://docs.github.com/en/free-pro-team@latest/rest/overview/media-types#commits-commit-comparison-and-pull-requests
  76.  $curl -H "Authorization: token ${GITHUB_API_TOKEN}" \ -H 'Accept: application/vnd.github.v3.diff'

    \
 https://github.dev.cybozu.co.jp/api/v3/repos/garoon/garoon/pulls/14386 diff --git a/source/page/master/sample.php b/source/page/master/sample.php index b644b6edbf5..03624413a6a 100644 --- a/source/page/master/sample.php +++ b/source/page/master/sample.php @@ -1,3 +1,4 @@ +echo "diff test" ࡶʹ +++ ͱϑΝΠϧ֦ுࢠΛgrep͢Ε͹ɺ ੩తղੳର৅ͷϑΝΠϧ͕औಘͰ͖Δ https://docs.github.com/en/free-pro-team@latest/rest/overview/media-types#commits-commit-comparison-and-pull-requests ϓϧϦΫऔಘ GitHub API
  77. ੩తղੳʹ͔͔Δ࣌ؒΛ୹͘͢Δ • Phan͸ͦ΋ͦ΋ಛఆϑΝΠϧͷΈͷ෼ੳ͕Ͱ͖ͳ͍ • Psalm͸cacheDirectoryΛࢦఆͯ͠ɺ ࣮ߦ݁ՌΛΩϟογϡɺ--diff ΦϓγϣϯΛ࢖͏ํ͕ྑͦ͞͏ • PHPStan΍PHP Code

    Sniffer (ίʔσΟϯάن໿ͷνΣοΫ πʔϧ)Ͱ༗ޮ 
  78. • ϑΟʔυόοΫΛվળ͢Δ  ͞ΒʹνʔϜͷ੩తղੳମݧΛΑ͘͢ΔTips ཧղ༰қʹ͢Δ ϑΟʔυόοΫΛૣ͘͢Δ ݎ࿚ʹ͢Δ

  79. ൃੜͨ͠issueΛΘ͔Γ΍͘͢͢Δ • CIʹΤϥʔϝοηʔδΛಡΈʹ͍͘ͷ͸ΊΜͲ͍͘͞ 

  80. reviewdog  • issueͷग़ͨͱ͜ΖʹࣗಈͰίϝϯτΛ͚ͭͯ͘ΕΔ https://github.com/reviewdog/reviewdog

  81. reviewdog  • issueͷग़ͨͱ͜ΖʹࣗಈͰίϝϯτΛ͚ͭͯ͘ΕΔ https://github.com/reviewdog/reviewdog GitHub EnterpriseͰ͸API token͕ඞཁ APIൃߦऀͷΞΠίϯ͕ग़ΔͷͰ νʔϜϝϯόʔ͔ΒݏΘΕ΍͍͢

  82. botΞΧ΢ϯτ • ਓʹ௚઀ౖΒΕΔΑΓ͸ɺbotʹౖΒΕΔํ͕·ͩϚγ • botΞΧ΢ϯτΛ࡞ͬͯӡ༻͍ͯ͠Δ • GitHubͩͱɺreviewdogͷΞΠίϯ͕ॻ͖ࠐΜͰ͘ΕΔͷͰ҆৺

  83. • ϑΟʔυόοΫΛվળ͢Δ  ͞ΒʹνʔϜͷ੩తղੳମݧΛΑ͘͢ΔTips ཧղ༰қʹ͢Δ ϑΟʔυόοΫΛૣ͘͢Δ ݎ࿚ʹ͢Δ

  84. issueΛϝΠϯϒϥϯνʹऔΓࠐ·ͳ͍ • GitHub ͷ Branch protection rulesΛ͔ͭ͏ 

  85. issueΛϝΠϯϒϥϯνʹऔΓࠐ·ͳ͍ • GitHub ͷ Branch protection rulesΛ͔ͭ͏  CIͷνΣοΫΛϚʔδલʹඞਢʹ͢Δ

  86. issueΛϝΠϯϒϥϯνʹऔΓࠐ·ͳ͍ • GitHub ͷ Branch protection rulesΛ͔ͭ͏  ඞਢͷCIδϣϒΛબͿ

  87. issueΛϝΠϯϒϥϯνʹऔΓࠐ·ͳ͍ • GitHub ͷ Branch protection rulesΛ͔ͭ͏  ඞਢͷCIδϣϒΛબͿ

  88. issueΛϝΠϯϒϥϯνʹऔΓࠐ·ͳ͍ • GitHub ͷ Branch protection rulesΛ͔ͭ͏  ඞਢͷCIδϣϒΛબͿ $*͕௨Βͳ͍ͱϚʔδͰ͖ͳ͍ʂ

  89. ·ͱΊ • ੩తղੳͷCIಋೖͰϨΨγʔʹཱͪ޲͔͓͏ʂ • ϑΟʔυόοΫϧʔϓΛҙࣝͯ͠ɺCIΛಋೖ͠Α͏ʂ • baselineͰ੩తղੳͷϝϯςφϯείετΛԼ͛Α͏ʂ • খٕΛͨ͘͞Μ࢖ͬͯɺ੩తղੳͷମݧΛΑ͘͠Α͏ʂ