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

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

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

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

tsuyoshi wada

March 09, 2018
Tweet

More Decks by tsuyoshi wada

Other Decks in Technology

Transcript

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

    View full-size slide

  2. ࣗݾ঺հ
    @wadackel / ΘͩͭΑ͠
    tsuyoshiwada
    https://blog.wadackel.me
    • ΠϯλʔωοτͰ྘ͷŘŕŭ΍͍ͬͯ·͢
    • ࠓ೥1݄ʹ CyberAgent, Inc ʹೖࣾ͠·ͨ͠
    • Web ϑϩϯτΤϯδχΞʹͳΓ·ͨ͠
    • ࠷ۙ Go ָ͕͍͠

    View full-size slide

  3. ࠓ೔͓࿩͢Δ͜ͱ
    • Greenkeeper ͸ศརʂ͔͠͠…
    • npm ύοέʔδͱ๻ୡͷઓ͍
    • ࣮ࡍʹӡ༻ͯ͠Έͯ
    • ·ͱΊ

    View full-size slide

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

    View full-size slide

  5. Greenkeeper
    https://greenkeeper.io

    View full-size slide

  6. Greenkeeper ͸ศར
    • ࣗಈͰ npm ύοέʔδͷߋ৽Λͯ͘͠ΕΔ
    • ߋ৽࣌ʹςετΛ࣮ߦ͠ɺύοέʔδߋ৽ʹΑͬͯίʔυ͕յΕ͍ͯͳ
    ͍͔ݕূͯ͘͠ΕΔ
    • ߋ৽ޙʹ PR ·Ͱग़ͯ͘͠ΕΔݡ͍΍ͭ
    • ࢖͍ͬͯΔϓϩδΣΫτ΋ଟ͍

    View full-size slide

  7. “͔͠͠ɺສೳͳ෺ͳͲଘࡏ͠ͳ͔ͬͨ…”

    View full-size slide

  8. ༷ʑͳཧ༝͸͋Δͱࢥ͍·͕͢…
    • όʔδϣϯΞοϓʹΑͬͯܰඍͳमਖ਼͕ඞཁʹͳΔ͜ͱ͕ଟ͍

    (Linter ܥͩͱݦஶ)
    • ςετͷ଍Γ͍ͯͳ͍෦෼͸ݕग़ෆՄɻ࣮ࡍʹίʔυ͕յΕ͍ͯͯ΋
    ؾ෇͚ͳ͍৔߹͕͋Δ…
    • 2018-03-09࣌఺Ͱ͸ Yarn Workspaces ʹະରԠ

    https://github.com/greenkeeperio/greenkeeper/issues/139

    View full-size slide

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

    View full-size slide

  10. yarn-outdated-formatter
    • $ yarn outdated ͷ݁Ռʹ CHANGELOG ΁ͷϦϯΫΛ෇͚ͯ͘ΕΔ
    • ݁Ռ͸ Markdown ΍ JSON Ͱड͚औΕΔ
    • CHANGELOG ͷࢀরͰɺมߋՕॴ͕೺ѲͰ͖Δͱ…
    • Assignee ͱ Reviewer ͷෛ୲͕ܰݮͰ͖ͯօϋοϐʔ
    • هࣄதͰ͸1ϲ݄͓͖ʹʮΞοϓσʔτσʔʯΛઃ͚͍ͯΔͱͷ͜ͱ

    View full-size slide

  11. ΋ͬͱศརʹ࢖͍͍ͨ

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  14. yarn-outdated-notifier
    yarn-outdated-formatter ͷ݁ՌΛ GitHub ͷ Personal access tokens Λ
    ࢖ͬͯ Issue ΁௨஌ͯ͘͠ΕΔ
    $ yarn outdated-notifier \
    --api-token \
    --labels \
    --assignees \
    --changelogs ./changelogs.yml

    View full-size slide

  15. ࣮ࡍʹ௨஌͞ΕΔ Issue ͸͜Μͳײ͡
    ※௨஌͞ΕΔ಺༰͸ Handlebars ͷςϯϓϨʔτͰมߋͰ͖Δ

    View full-size slide

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

    View full-size slide

  17. CircleCI
    with
    yarn-outdated-notifier

    View full-size slide

  18. # 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 Λ࡞Δ

    View full-size slide

  19. # workflows Ͱઌఔ࡞ͬͨ `job` Λݺͼग़͢
    # ҎԼ͸ɺ೔ຊ࣌ؒͷຖि༵ۚ೔ޕલ10:00ʹ௨஌ॲཧΛ։࢝͢Δྫ
    workflows:
    version: 2
    notifications:
    jobs:
    - notify_outdated
    triggers:
    cron: “0 1 * * 5”
    filters:
    branches:
    only:
    - master
    cron Ͱ job Λݺͼग़͢

    View full-size slide

  20. ఆظతʹ npm ύοέʔδΛ
    ߋ৽͢Δ౔৕͸੔ͬͨ

    View full-size slide

  21. ࣮ࡍʹӡ༻ͯ͠Έͯ

    View full-size slide

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

    View full-size slide

  23. ߋ৽࡞ۀͷ࣌ؒ͸͋Δఔ౓Ͱ۠੾Δ
    • ຖि࡞ۀ͸ߦ͏ͷͰɺޕલத΍2࣌ؒ౳ɺ۠੾Γͷྑ͍࣌ؒͰ۠੾Δ
    • ͦͷ࣌ؒʹऩ·Βͳͦ͏ͳύοέʔδ͸ผ్ Issue Λ੾ͬͯ࡞ۀʹऔΓ
    ֻ͔Δ
    • ϓϩμΫτͷՁ஋ʹ௚݁͢Δ΋ͷʹ͸ɺ૬Ԡͷ࿑ྗΛֻ͚Α͏
    • ྫ) ʮwebpack v4.x ग़ͨ͠ɺ࢖͍౗ͯ͠ΈΔ͔ʔʂʂʯ౳

    View full-size slide

  24. CI ͱ Yarn ͚ͩͰಋೖͰ͖Δͷ͸खܰ
    • Greenkeeper ͳͲͷ֎෦αʔϏεΛಋೖ͢Δͱ؅ཧର৅͕૿͑ͯखؒ
    • CI ͸ΈΜͳ࢖ͬͯΔ͠ (࢖ͬͯΔΑͶ??) ɺಋೖোน͕௿͍
    • CircleCI Λྫʹग़͚ͨ͠Ͳɺେ൒ͷ CI ͸ cron ࣋ͬͯΔ

    View full-size slide

  25. Assignee ͷઃఆ͸ݕ౼͕ඞཁ
    • ʮnpm ύοέʔδߋ৽େ޷͖ʯͱ͍͏حಛͳํ͕͍Ε͹Ұ೚
    • ͦ͏Ͱͳ͚Ε͹ɺ୲౰ϝϯόʔͰϩʔςʔγϣϯ
    • ຢ͸ϥϯμϜʹ Assignee ΛׂΓৼΓ (๻ͷνʔϜ͸͜ΕΛ࠾༻)

    View full-size slide

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

    View full-size slide

  27. ྑ͍ CHANGELOG ͸ॏཁ (એ఻)
    • Go ੡ͷ CHANGELOG δΣωϨʔλΛ࡞ͬͨ

    https://github.com/git-chglog/git-chglog
    • CHANGELOG ͸ੵۃతʹ࡞͍ͬͯ͜͏

    View full-size slide

  28. ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠

    View full-size slide