Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

Jun Watanabe @rela1470 • ΃ͪͺʔ6೥໨ • ORATTA, Inc Chief Engineer • http://rela.red/ ʘWe are hiring!ʗ

Slide 3

Slide 3 text

ίʔυվળͱ͍͑͹ CIπʔϧ͔ͳ

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

PHP 5.5 PHPUnit GitHub circleci FREE Plan

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

ෳ਺GitͷClone

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

ϓϩδΣΫτͷgit഑ஔྫ multi [multi.git] //ࣗࣾϑϨʔϜϫʔΫ !system ɹ"addon ɹ#ɹ!asuka [asuka.git] //ϓϩδΣΫτຖͷಠ࣮ࣗ૷ιʔε ɹ#ɹɹ"master [asuka-master.git]ɹ//ΞΠςϜ౳ͷϚελʔઃఆ ɹ#ɹɹ!web [asuka-web.git]ɹ//ը૾΍Ի੠౳ ɹ!lib[lib.git] //ࣗࣾϥΠϒϥϦ

Slide 12

Slide 12 text

Jenkins͸ Multiple SCMs Plugin

Slide 13

Slide 13 text

circleciͰ͸Ͳ͏͢Δ͔

Slide 14

Slide 14 text

circle.ymlͰؤுΔ

Slide 15

Slide 15 text

git cloneͯ͠ ࣗ෼Ͱ഑ஔ͠ͳ͓͢ checkout: post: - "git clone -b ${CIRCLE_BRANCH} [email protected]:oratta-inc/ multi.git /home/ubuntu/multi" - "git clone -b ${CIRCLE_BRANCH} [email protected]: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} [email protected]:oratta-inc/ asuka-master.git /home/ubuntu/multi/system/addon/asuka/master"

Slide 16

Slide 16 text

ݖݶͲ͏ͳͬͯΔͷ?

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

Ϗϧυͷखಈ࣮ߦ

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

͔ͨ͠ʹWebUI͸ͳ͍

Slide 24

Slide 24 text

RestAPI͕͋Δ!

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

ΧόϨοδूܭ

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

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

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

ͻͱͭ໰୊͕...

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

Ϗϧυʹ20෼

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

ۚͰԥΔͷ͸࠷ޙͷखஈ

Slide 38

Slide 38 text

Ϗϧυ࣌ؒͷ୹ॖ

Slide 39

Slide 39 text

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

Slide 40

Slide 40 text

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

Slide 41

Slide 41 text

͜ΜͳγΣϧεϓϦΫτ ࡞Γ·ͨ͠ 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

Slide 42

Slide 42 text

XdebugΛONʹ͢Δͱ PHPUnit͕ॏ͘ͳΔ

Slide 43

Slide 43 text

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

Slide 44

Slide 44 text

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

Slide 45

Slide 45 text

݄༵ͷேʹ cronͰճͯ͠·͢

Slide 46

Slide 46 text

γεςϜ؆ུԽ

Slide 47

Slide 47 text

͜ΜͳγΣϧεϓϦΫτ ࡞Γ·ͨ͠ 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

Slide 48

Slide 48 text

࣮͸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

Slide 49

Slide 49 text

yamlͷϒϩοΫελΠϧ վߦΛอଘ | |+ |- վߦΛ൒֯εϖʔεʹ > >+ >- Πϯσϯτࢦఆ |1 >1

Slide 50

Slide 50 text

circle.yml ͚ͩͰग़དྷΔ

Slide 51

Slide 51 text

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

Slide 52

Slide 52 text

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

Slide 53

Slide 53 text

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

Slide 54

Slide 54 text

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