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

ビルドパイプラインツールをGoで作った話

Naoki Ainoya
November 30, 2014

 ビルドパイプラインツールをGoで作った話

A build pipeline tool written in go

Naoki Ainoya

November 30, 2014
Tweet

More Decks by Naoki Ainoya

Other Decks in Programming

Transcript

  1. ϏϧυύΠϓϥΠϯπʔϧΛ
    GoͰ࡞ͬͨ࿩
    GoCon 2014 Autumn
    @naokiainoya
    https://github.com/tenntenn/gopher-stickers/blob/master/png/28.png

    View full-size slide

  2. ࣗݾ঺հ
    ૬໺୩ ௚थ ainoya
    ~2013.09 mixi
    ~ݱࡏ ϦΫϧʔτςΫϊϩδʔζ APιϦϡʔγϣϯG
    ओͳ࢓ࣄ:
    ɹ ৽ٕज़ͷಋೖݕূͳͲ

    View full-size slide

  3. IUUQBUMSFDSVJUUFDIDPKQCMPH
    IUUQBJOPZBJPXBMUFS
    “ϏϧυύΠϓϥΠϯπʔϧ”

    View full-size slide

  4. πʔϧͷػೳ
    • CIͰͷϏϧυύΠϓϥΠϯͷ࣮ߦ੍ޚΛ͢Δπʔϧ
    • Jenkinsʹ͋ΔϏϧυύΠϓ

    ϥΠϯϓϥάΠϯͷ୅ସ
    • ઃఆϑΝΠϧ(YAMLܗࣜ)ʹ

    δϣϒ(࣮ߦ୯Ґ)ͷॲཧ಺༰ͱ

    δϣϒͷ࣮ߦॱংΛهड़

    View full-size slide

  5. πʔϧͷػೳ
    • CIܥαʔϏεͬΆ͍ઃఆϑΝΠϧʹ࣮ߦ಺༰ͱॱংΛهड़

    View full-size slide

  6. πʔϧͷػೳ
    • CIܥαʔϏεͬΆ͍ઃఆϑΝΠϧʹ࣮ߦ಺༰ͱॱংΛهड़

    View full-size slide

  7. πʔϧͷػೳ
    • CIܥαʔϏεͬΆ͍ઃఆϑΝΠϧʹ࣮ߦ಺༰ͱॱংΛهड़

    View full-size slide

  8. πʔϧͷػೳ
    • CIܥαʔϏεͬΆ͍ઃఆϑΝΠϧʹ࣮ߦ಺༰ͱॱংΛهड़

    View full-size slide

  9. πʔϧͷػೳ
    • CIܥαʔϏεͬΆ͍ઃఆϑΝΠϧʹ࣮ߦ಺༰ͱॱংΛهड़

    View full-size slide

  10. GoͰॻ͍ͨཧ༝
    HPSPVUJOFͰδϣϒ࣮ߦ
    DIBOOFMͰ࣮ߦ݁ՌΛ࣍
    ʹ఻͑Δ
    DIBOOFM͔Βϝοηʔδ
    ड৴ͨ͠Β࣮ߦ
    channel/goroutineͰ͍͍ײ͡Ͱॻ͚ͦ͏

    View full-size slide

  11. GoͰॻ͍ͨཧ༝
    • όΠφϦ୯ମͰ഑෍Մೳ
    • werckerͰΫϩείϯύΠϧˠ

    GitHub Releases΁ͷΞοϓϩʔυ·Ͱ

    ϫϯΫϦοΫͰ
    • motemen/ghqΛࢀߟʹ
    IUUQTHJUIVCDPNXBMUFSDEXBMUFSCMPCNBTUFSXFSDLFSZNM

    View full-size slide

  12. ͦͷଞtips
    ϓϩδΣΫτߏ੒
    • coreos/etcdΛࢀߟʹͨ͠
    • {$project-root}/${package-name}/ҎԼʹ

    .goϑΝΠϧΛ഑ஔ͍ͯ͘͠ϧʔϧͰ
    • Ϣχοτςετ΋ຊମͱಉ͡σΟϨΫτϦ഑ஔ
    • build/test͸shell scriptͰ
    https://github.com/walter-cd/walter

    View full-size slide

  13. ͦͷଞtips
    ύοέʔδ؅ཧ
    • ࠷ॳ͸submoduleͰ؅ཧ
    • ґଘ͕૿͑ͯอकͮ͠Β͘ͳͬͨ
    • ࠓ͸GodepΛར༻
    • /Godeps/Godeps.jsonʹґଘؔ܎هड़
    https://github.com/tools/godep

    View full-size slide

  14. ͦͷଞtips
    ϩάग़ྗ
    • ༻్ʹ߹͏ϩάग़ྗϥΠϒϥϦ͕ͳ͔ͬͨ
    • ଞͷϓϩδΣΫτ͸ݢฒΈࣗલͰ༻ҙ
    • golang/glogΛforkͯ͠ϩάϑΥʔϚοτ
    Λม͑ͯར༻

    View full-size slide

  15. GoͰॻ͍ͨॴײ

    View full-size slide

  16. “golang way”
    • "Is Go an object-oriented language?" 

    ɹɹɹɹɹɹɹɹɹɹɹ-- "yes and no"
    • No type hierarchy
    • Interfaces can be very lightweight



    https://golang.org/doc/faq#Is_Go_an_object-oriented_language

    View full-size slide

  17. “golang way”
    • "Share memory by communicating,

    don't communicate by sharing memory.”
    • channelͰॻ͍ͯΈΔ
    • ॻ͖ͮΒͦ͏ͩͬͨΒSync.Mutex
    IUUQTDPEFHPPHMFDPNQHPXJLJXJLJ.VUFY0S$IBOOFM
    IUUQTPOJBDPEFTXPSEQSFTTDPNDIBOOFMTWTTZODQBDLBHF

    View full-size slide

  18. ࠷ޙʹ
    • walterͱ͍͏ϏϧυύΠϓϥΠϯπʔϧΛGoͰॻ͍ͨ
    • όΠφϦ഑෍ָ͕
    • goroutine/channelͰδϣϒؒͷϝοηʔδύογϯάΛ͍͍ײ͡ʹ
    • ·ͩશવͰ͖ͯͳ͍ɽҾ͖ଓ͖ػೳڧԽΛߦ͍͖ͬͯ·͢
    • ΤϥʔϋϯυϦϯάڧԽetc..
    • YAMLܗࣜͷઃఆϑΝΠϧΛ΍Ί͍ͨ

    DSLΛGoͰͲ͏࣮૷͢Δ͔ߟ͑த

    View full-size slide