circleci小ネタ集 / circleci_tips

circleci小ネタ集 / circleci_tips

コード改善 meetup #1 http://kaizen.connpass.com/event/31378/

6f36ff3943be908c5d2259f4aef09ea6?s=128

Jun Watanabe

May 26, 2016
Tweet

Transcript

  1. circleciখωλू 2016/05/26 ίʔυվળ meetup #1 Jun Watanabe

  2. Jun Watanabe @rela1470 • ΃ͪͺʔ6೥໨ • ORATTA, Inc Chief Engineer

    • http://rela.red/ ʘWe are hiring!ʗ
  3. ίʔυվળͱ͍͑͹ CIπʔϧ͔ͳ

  4. ઌ݄ɺ ΦϯϓϨJenkins͔Β circleciʹ׬શҠߦ͠·ͨ͠!

  5. https://speakerdeck.com/ rela1470/jenkins-kill

  6. ஻Βͳ͔ͬͨ͜ͱ + ͦͷޙࠔͬͨ͜ͱ ΍ͬͨ͜ͱ

  7. PHP 5.5 PHPUnit GitHub circleci FREE Plan

  8. ෩࿊෦(ࣾ಺੍౓) िʹ3࣌ؒձٞࣨʹ࿜ͬͯ ͻͨ͢Βۀ຿վળɾٕज़ௐࠪ ORATTA Frontier TechͷଏশΒ͍͠

  9. ෳ਺GitͷClone

  10. 1ϓϩδΣΫτ 5ͭ͘Β͍ͷgitʹ ෼͔Ε͍ͯΔ

  11. ϓϩδΣΫτͷgit഑ஔྫ multi [multi.git] //ࣗࣾϑϨʔϜϫʔΫ !system ɹ"addon ɹ#ɹ!asuka [asuka.git] //ϓϩδΣΫτຖͷಠ࣮ࣗ૷ιʔε ɹ#ɹɹ"master

    [asuka-master.git]ɹ//ΞΠςϜ౳ͷϚελʔઃఆ ɹ#ɹɹ!web [asuka-web.git]ɹ//ը૾΍Ի੠౳ ɹ!lib[lib.git] //ࣗࣾϥΠϒϥϦ
  12. Jenkins͸ Multiple SCMs Plugin

  13. circleciͰ͸Ͳ͏͢Δ͔

  14. circle.ymlͰؤுΔ

  15. git cloneͯ͠ ࣗ෼Ͱ഑ஔ͠ͳ͓͢ checkout: post: - "git clone -b ${CIRCLE_BRANCH}

    git@github.com:oratta-inc/ multi.git /home/ubuntu/multi" - "git clone -b ${CIRCLE_BRANCH} git@github.com:oratta-inc/ lib.git /home/ubuntu/multi/system/lib" - "mkdir /home/ubuntu/multi/system/addon" test: pre: - "cp -a /home/ubuntu/${CIRCLE_PROJECT_REPONAME}/ /home/ubuntu/ multi/system/addon/${CIRCLE_PROJECT_REPONAME}" - "git clone -b ${CIRCLE_BRANCH} git@github.com:oratta-inc/ asuka-master.git /home/ubuntu/multi/system/addon/asuka/master"
  16. ݖݶͲ͏ͳͬͯΔͷ?

  17. Deploy keysΛ࢖͏ͱ ౰֘1ϦϙδτϦͷΈ

  18. user keyʹࠩ͠ସ͑ͯ Ϣʔβʹඥ෇͍ͨݖݶΛऔಘ

  19. user keyʹࠩ͠ସ͑ͯ Ϣʔβʹඥ෇͍ͨݖݶΛऔಘ

  20. αϒϞδϡʔϧԽ ΍Ζ͏ͱͯ͠·͢ @ࠓ೥த͘Β͍...

  21. Ϗϧυͷखಈ࣮ߦ

  22. εέδϡʔϧϏϧυ खಈϏϧυ Ͱ͖ͳ͘ͳΔͷ?

  23. ͔ͨ͠ʹWebUI͸ͳ͍

  24. RestAPI͕͋Δ!

  25. ՝ۚػೳҎ֎͸શ෦Ͱ͖ΔΑ!

  26. branchΛࢦఆͯ͠ ৽ϏϧυΛߦ͏API curl -X POST https://circleci.com/api/v1/project/:username/:project/ tree/:branch?circle-token=:token

  27. εέδϡʔϧϏϧυ cronͰୟ͘ खಈϏϧυ खͰୟ͘

  28. ΧόϨοδूܭ

  29. ΧόϨοδूܭ͍ͨ͠ දͰݟ͍ͨ

  30. XdebugΛONʹ sed -i 's/^;//' ~/.phpenv/versions/$(phpenv global)/etc/conf.d/ xdebug.ini

  31. --coverage-html Ͱ $CIRCLE_ARTIFACTS ʹग़ྗͨ͠ΒOK

  32. ͻͱͭ໰୊͕...

  33. None
  34. None
  35. Ϗϧυʹ20෼

  36. pushͷ౓ʹ20෼଴ͪ͸
 ͕͢͞ʹࠔΔ...

  37. ۚͰԥΔͷ͸࠷ޙͷखஈ

  38. Ϗϧυ࣌ؒͷ୹ॖ

  39. ผʹPush࣌ ຖճ΍Βͳͯ͘΋ ि1͘Β͍Ͱྑ͍

  40. Ҿ਺Ͱ໌ࣔతʹ
 ͚ͨ࣌ͩ͠ ΧόϨοδूܭ

  41. ͜ΜͳγΣϧεϓϦΫτ ࡞Γ·ͨ͠ test: override: - sh test.sh if [[ -v

    RUN_COVERAGE ]] then sed -i 's/^;//' ~/.phpenv/versions/$(phpenv global)/etc/conf.d/ xdebug.ini phpunit -c phpunit.xml --coverage-html=${CIRCLE_ARTIFACTS} else phpunit -c phpunit.xml fi circle.yml test.sh
  42. XdebugΛONʹ͢Δͱ PHPUnit͕ॏ͘ͳΔ

  43. औಘ͢Δ͚࣌ͩ XdebugΛONʹ͢Δ

  44. REST APIͰbuild_parameters Λ෇༩ͯ͠Ϗϧυ curl -X POST --header "Content-Type: application/json" -d

    '{"build_parameters": {"RUN_COVERAGE": "true"}}' https:// circleci.com/api/v1/project/username/reponame/tree/branch?circle- token=hogehoge
  45. ݄༵ͷேʹ cronͰճͯ͠·͢

  46. γεςϜ؆ུԽ

  47. ͜ΜͳγΣϧεϓϦΫτ ࡞Γ·ͨ͠ test: override: - sh test.sh if [[ -v

    RUN_COVERAGE ]] then sed -i 's/^;//' ~/.phpenv/versions/$(phpenv global)/etc/conf.d/ xdebug.ini phpunit -c phpunit.xml --coverage-html=${CIRCLE_ARTIFACTS} else phpunit -c phpunit.xml fi circle.yml test.sh
  48. ࣮͸circle.yml͚ͩͰग़དྷΔ test: override: - | if [[ -v RUN_COVERAGE ]]

    then sed -i 's/^;//' ~/.phpenv/versions/$(phpenv global)/etc/ conf.d/xdebug.ini phpunit -c /home/ubuntu/multi/system/addon/$ {CIRCLE_PROJECT_REPONAME}/phpunit.xml -d memory_limit=1024M -- coverage-html=${CIRCLE_ARTIFACTS} else phpunit -c /home/ubuntu/multi/system/addon/$ {CIRCLE_PROJECT_REPONAME}/phpunit.xml -d memory_limit=1024M
  49. yamlͷϒϩοΫελΠϧ վߦΛอଘ | |+ |- վߦΛ൒֯εϖʔεʹ > >+ >- Πϯσϯτࢦఆ

    |1 >1
  50. circle.yml ͚ͩͰग़དྷΔ

  51. 1ϑΝΠϧͰ ग़དྷΔͳΒ ޾ͤ

  52. σάϨΔ͜ͱͳ͘ ׬શҠߦग़དྷ·ͨ͠(^o^)

  53. http://connpass.com/event/32338/

  54. ʘWe are hiring!ʗ http://www.oratta.net/