Yarn + CI + GitHub で挑む npm パッケージの定期更新

Yarn + CI + GitHub で挑む npm パッケージの定期更新

Greenkeeper を使わない npm パッケージの更新戦略について提案です

Dc696687bae442425a220771df158346?s=128

tsuyoshi wada

March 09, 2018
Tweet

Transcript

  1. Yarn + CI + GitHub Ͱ௅Ή npm ύοέʔδͷఆظߋ৽ 2018-03-09 /

    Gotanda.js #10 @wadackel
  2. ࣗݾ঺հ @wadackel / ΘͩͭΑ͠ tsuyoshiwada https://blog.wadackel.me • ΠϯλʔωοτͰ྘ͷŘŕŭ΍͍ͬͯ·͢ • ࠓ೥1݄ʹ

    CyberAgent, Inc ʹೖࣾ͠·ͨ͠ • Web ϑϩϯτΤϯδχΞʹͳΓ·ͨ͠ • ࠷ۙ Go ָ͕͍͠
  3. ࠓ೔͓࿩͢Δ͜ͱ • Greenkeeper ͸ศརʂ͔͠͠… • npm ύοέʔδͱ๻ୡͷઓ͍ • ࣮ࡍʹӡ༻ͯ͠Έͯ •

    ·ͱΊ
  4. ೔ʑߋ৽͞Εଓ͚Δ npm ύοέʔδͱ օ͞Μ͸Ͳ͏ઓ͍ͬͯ·͔͢ʁ

  5. Greenkeeper https://greenkeeper.io

  6. Greenkeeper ͸ศར • ࣗಈͰ npm ύοέʔδͷߋ৽Λͯ͘͠ΕΔ • ߋ৽࣌ʹςετΛ࣮ߦ͠ɺύοέʔδߋ৽ʹΑͬͯίʔυ͕յΕ͍ͯͳ ͍͔ݕূͯ͘͠ΕΔ •

    ߋ৽ޙʹ PR ·Ͱग़ͯ͘͠ΕΔݡ͍΍ͭ • ࢖͍ͬͯΔϓϩδΣΫτ΋ଟ͍
  7. “͔͠͠ɺສೳͳ෺ͳͲଘࡏ͠ͳ͔ͬͨ…”

  8. ༷ʑͳཧ༝͸͋Δͱࢥ͍·͕͢… • όʔδϣϯΞοϓʹΑͬͯܰඍͳमਖ਼͕ඞཁʹͳΔ͜ͱ͕ଟ͍
 (Linter ܥͩͱݦஶ) • ςετͷ଍Γ͍ͯͳ͍෦෼͸ݕग़ෆՄɻ࣮ࡍʹίʔυ͕յΕ͍ͯͯ΋ ؾ෇͚ͳ͍৔߹͕͋Δ… • 2018-03-09࣌఺Ͱ͸

    Yarn Workspaces ʹະରԠ
 https://github.com/greenkeeperio/greenkeeper/issues/139
  9. ͦ͜Ͱ…

  10. ͪ͜Βͷهࣄ http://developer.hatenastaff.com/entry/2017/06/06/163000

  11. yarn-outdated-formatter • $ yarn outdated ͷ݁Ռʹ CHANGELOG ΁ͷϦϯΫΛ෇͚ͯ͘ΕΔ • ݁Ռ͸

    Markdown ΍ JSON Ͱड͚औΕΔ • CHANGELOG ͷࢀরͰɺมߋՕॴ͕೺ѲͰ͖Δͱ… • Assignee ͱ Reviewer ͷෛ୲͕ܰݮͰ͖ͯօϋοϐʔ • هࣄதͰ͸1ϲ݄͓͖ʹʮΞοϓσʔτσʔʯΛઃ͚͍ͯΔͱͷ͜ͱ
  12. ΋ͬͱศརʹ࢖͍͍ͨ

  13. yarn-outdated-formatter ͷ ݁ՌΛ GitHub Issue ΁ ఆظతʹ௨஌͢Δͱ΋ͬͱϋοϐʔ

  14. ͱ͍͏Θ͚Ͱ… yarn-outdated-formatter ͷ݁ՌΛ GitHub Issue ΁ʮ͍͍ײ͡ʯʹ௨஌͠ ͯ͘ΕΔ؆୯ͳπʔϧΛ࡞ͬͨ yarn-outdated-notifier https://github.com/tsuyoshiwada/yarn-outdated-notifier

  15. yarn-outdated-notifier yarn-outdated-formatter ͷ݁ՌΛ GitHub ͷ Personal access tokens Λ ࢖ͬͯ

    Issue ΁௨஌ͯ͘͠ΕΔ $ yarn outdated-notifier \ --api-token <your_token> \ --labels <label_name> \ --assignees <assignee_name> \ --changelogs ./changelogs.yml
  16. ࣮ࡍʹ௨஌͞ΕΔ Issue ͸͜Μͳײ͡ ※௨஌͞ΕΔ಺༰͸ Handlebars ͷςϯϓϨʔτͰมߋͰ͖Δ

  17. yarn-outdated-notifier ͸ ௨஌ػೳ͚ͩΛ࣋ͭ ఆظతͳ௨஌͸ CI ͷ cron Λ࢖͏ͱָ

  18. CircleCI with yarn-outdated-notifier

  19. # GITHUB_API_TOKEN ͸ Environment Variables ʹ௥Ճ͓ͯ͘͠ job: notify_outdated: docker: -

    image: circleci/node:9.3 working_directory: ~/repo steps: - checkout - yarn - run: yarn outdated-notifier --api-token $GITHUB_API_TOKEN ௨஌༻ͷ job Λ࡞Δ
  20. # workflows Ͱઌఔ࡞ͬͨ `job` Λݺͼग़͢ # ҎԼ͸ɺ೔ຊ࣌ؒͷຖि༵ۚ೔ޕલ10:00ʹ௨஌ॲཧΛ։࢝͢Δྫ workflows: version: 2

    notifications: jobs: - notify_outdated triggers: cron: “0 1 * * 5” filters: branches: only: - master cron Ͱ job Λݺͼग़͢
  21. ఆظతʹ npm ύοέʔδΛ ߋ৽͢Δ౔৕͸੔ͬͨ

  22. ࣮ࡍʹӡ༻ͯ͠Έͯ

  23. िҰͷߋ৽࡞ۀ͕ྑͦ͞͏ • ݄Ұͩͱɺґଘ͢Δύοέʔδ͕ଟ͍৔߹ʹߋ৽͕ඃΔ • ࡞ۀස౓͕ଟ͚Ε͹ɺҰ౓ʹൃੜ͢Δߋ৽࡞ۀͷෛ୲͕ܰݮ͞ΕΔ • ͨͩ͠ɺଟ͗͢Δͷ͸ਏ͍ɻिҰ͘Β͍͕ஸ౓͍͍ • िҰ͕͠ΜͲ͍ or

    ύοέʔδ͕গͳ͘ඞཁੑ͕ബ͍ͳΒִिͰ΋OK
  24. ߋ৽࡞ۀͷ࣌ؒ͸͋Δఔ౓Ͱ۠੾Δ • ຖि࡞ۀ͸ߦ͏ͷͰɺޕલத΍2࣌ؒ౳ɺ۠੾Γͷྑ͍࣌ؒͰ۠੾Δ • ͦͷ࣌ؒʹऩ·Βͳͦ͏ͳύοέʔδ͸ผ్ Issue Λ੾ͬͯ࡞ۀʹऔΓ ֻ͔Δ • ϓϩμΫτͷՁ஋ʹ௚݁͢Δ΋ͷʹ͸ɺ૬Ԡͷ࿑ྗΛֻ͚Α͏

    • ྫ) ʮwebpack v4.x ग़ͨ͠ɺ࢖͍౗ͯ͠ΈΔ͔ʔʂʂʯ౳
  25. CI ͱ Yarn ͚ͩͰಋೖͰ͖Δͷ͸खܰ • Greenkeeper ͳͲͷ֎෦αʔϏεΛಋೖ͢Δͱ؅ཧର৅͕૿͑ͯखؒ • CI ͸ΈΜͳ࢖ͬͯΔ͠

    (࢖ͬͯΔΑͶ??) ɺಋೖোน͕௿͍ • CircleCI Λྫʹग़͚ͨ͠Ͳɺେ൒ͷ CI ͸ cron ࣋ͬͯΔ
  26. Assignee ͷઃఆ͸ݕ౼͕ඞཁ • ʮnpm ύοέʔδߋ৽େ޷͖ʯͱ͍͏حಛͳํ͕͍Ε͹Ұ೚ • ͦ͏Ͱͳ͚Ε͹ɺ୲౰ϝϯόʔͰϩʔςʔγϣϯ • ຢ͸ϥϯμϜʹ Assignee

    ΛׂΓৼΓ (๻ͷνʔϜ͸͜ΕΛ࠾༻)
  27. ·ͱΊ

  28. • ໪࿦ʮ͜Εܾͧఆ൛ʂʯͱ͍͏ํ๏Ͱ͸ͳ͍ • ֤νʔϜʹ͋ͬͨ޲͖߹͍ํΛ໛ࡧ͠ • npm ύοέʔδͷߋ৽ͱటष͘ઓ͏ඞཁ͕͋Δ • ͥͻօ͞Μͷઓ͍ํΛڭ͍͑ͯͩ͘͞ʂ

  29. ྑ͍ CHANGELOG ͸ॏཁ (એ఻) • Go ੡ͷ CHANGELOG δΣωϨʔλΛ࡞ͬͨ
 https://github.com/git-chglog/git-chglog

    • CHANGELOG ͸ੵۃతʹ࡞͍ͬͯ͜͏
  30. ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠