Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
CakePHPで学ぶ継続的インテグレーション ハンズオン@大阪 開発編
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Kaz Watanabe
November 01, 2014
Programming
300
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
CakePHPで学ぶ継続的インテグレーション ハンズオン@大阪 開発編
Kaz Watanabe
November 01, 2014
More Decks by Kaz Watanabe
See All by Kaz Watanabe
開発エンジニアが取り組む DevSecOps ~ GitHub Enterprise × Azure での実践~
kaz29
0
46
Greenは本当にGreenか? - B/GデプロイとAPI自動テストで安心デプロイ
kaz29
1
200
CI/CD/IaC 久々に0から環境を作ったらこうなりました
kaz29
1
510
開発エンジニアが実践するDevSecOps
kaz29
0
170
PHPCon福岡2024-Azureもなかなかいいですよ.pdf
kaz29
2
390
Azure Container Apps + Bicep 〜 こんな感じで運用しています
kaz29
3
1.3k
20220908_フロントエンドパフォーマンス改善.pdf
kaz29
2
200
PHP製のPodCast配信用WebアプリをReact+Next.jsなSSGで作り直してみた話
kaz29
3
720
バックエンドエンジニアの私がお勧めする SPAフロントエンド開発環境
kaz29
6
6.3k
Other Decks in Programming
See All in Programming
設計次第でAIコードの読む量は減らせる / designing-for-code-reading
minodriven
30
13k
AgentCore CLI で進化した AWS での AI エージェントの作り方 : 必要な機能を必要な時に
icoxfog417
PRO
4
400
MVNOの申込からeSIM開通までをiOSアプリでつなぐ- 本人確認・MNP・通信事業者基盤をまたぐ実装
satotakeshi
0
520
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
740
[2026-09-26]空論ジェネリックプロセス~テスト資産とAIで紡ぐ、再現可能なパフォーマンスチューニングの話~
tosite
0
250
難しいけど、読めた。- OSSの入口に立った話。
sts11142
0
130
モジュールの視点からSwiftを読み解く #iosdc
s_shimotori
0
290
AWSに止められる覚悟してますか?
morizo_1984
2
490
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.7k
半永久的に提供し続けられるプライベートクラウドを目指して ― 利用者の認知負荷を抑えるAPI抽象化とハードウェア世代交代の基盤設計
tomokon
0
370
巨大モノリシックアプリ モダン化大作戦
ktcryomm
1
1.2k
Security issues being discussed on Web Platforms
petamoriken
0
1.4k
Featured
See All Featured
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
1
610
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
310
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.9k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
250
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
520
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
450
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
530
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
2
2.2k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
How to Ace a Technical Interview
jacobian
280
24k
Code Review Best Practice
trishagee
74
20k
Transcript
$",&1)1ͰֶͿ ܧଓతΠϯςάϨʔγϣϯϋϯζΦϯ ։ൃฤ @DevLoveؔ 2014/11/1
WHO? • Θͨͳ͔ͣͻΖ(@kaz_29) • ߹ಉձࣾ decr (decr.jp) • PHP(CakePHP)ͰWebΞϓϦ։ൃ •
Πϯϑϥߏஙɾӡ༻ • iOSΞϓϦ։ൃ #beer #iosdev #cakephp #cat #camp! #golf #chef #vagrant
WHO?
ಈ࡞ڥ
BeHat • ϏϔΠϏΞ(ৼ)ۦಈ։ൃ (BDD:Behaviour Driven Development) • ετʔϦʔϕʔεͷςεςΟϯάϑϨʔϜϫʔΫ
BeHat 'FBUVSFͷهड़ྫ
BeHat 'FBUVSFͷ࣮ߦྫ
BeHat #%%։ൃϓϩηε
࠷ॳͷεϓϦϯτ͕ ऴΘΔॴἬϫʔϓ͠·͢
࠷ॳͷεϓϦϯτ͕ ྃͨ͠ঢ়ଶΛ࡞ ! host $ vagrant ssh develop $ cd
/var/www/application/current/app $ git checkout master $ composer install --dev
DATABASEΛMigration
DATABASEΛMigration ! $ cd /var/www/application/current/app $ Console/cake Migrations.migration run all
None
UnitTest $ cd /var/www/application/current/app $ Console/cake Test app AllTests
None
StoryTest $ cd /var/www/application/current/app $ Console/cake Bdd.story
None
JenkinsʹࠐΜͰ͍͖·͢ʂ
ͦͷલʹ… $ git update-index --add --chmod=+x Console/cake $ git add
-u $ git commit -m “cakeίϚϯυʹ࣮ߦݖΛ༩” $ git push origin master
BUILDπʔϧΛಋೖ ! — phingΛಋೖ $ cd /var/www/application/current/app $ composer require
--dev "phing/phing:~2.8"
PHINGͷઆ໌
BUILDπʔϧΛಋೖ ! — मਖ਼Λίϛοτ $ git add composer.json composer.lock $
git commit -m 'PhingΛՃ' !
BUILDͷઃఆ <?xml version="1.0" encoding="UTF-8"?> <!-- Phing build config file. @link
http://www.phing.info/ --> <project name="blogapp" default="build"> <!-- Properties --> <property name="basedir" value="${phing.dir}" /> <property name="appdir" value="${basedir}/app" /> <property name="logdir" value="${appdir}/tmp/logs" /> ! <!-- Build(1) --> <target name="build" depends="prepare,caketest"/> ! <!-- Prepare(2) --> <target name="prepare" description="Prepare for build"> <exec dir="${appdir}" executable="${appdir}/Console/cake" output="${logdir}/migration.log" checkreturn="true"> <arg line="migrations.migration" /> <arg line="run" /> <arg line="all" /> </exec> </target> ! <!-- CakePHP unit test with PHPUnit(3) --> <target name="caketest" description="Run CakePHP unit tests with PHPUnit"> <exec dir="${appdir}" executable="${appdir}/Console/cake" output="${logdir}/caketest.log" checkreturn="true"> <arg line="test" /> <arg line="app" /> <arg line="AllTests" /> </exec> </target> </project> /var/www/application/current/build.xml
BUILDπʔϧΛಋೖ ! — ϏϧυΛ࣮ߦ $ cd /var/www/application/current $ app/Vendor/bin/phing !
BUILDπʔϧΛಋೖ ! — मਖ਼Λίϛοτ $ git add build.xml $ git
commit -m ‘ϏϧυϑΝΠϧΛՃ' $ git push origin master !
BUILDπʔϧΛಋೖ
BUILDπʔϧΛಋೖ
BUILDπʔϧΛಋೖ cd ${WORKSPACE}/app composer install --dev cd ${WORKSPACE} app/Vendor/bin/phing -logger
phing.listener.DefaultLogger
ϏϧυΛ࣮ߦʂ
UnitTest݁ՌΛදࣔ͢Δ ! — build.xmlΛमਖ਼ <target name="caketest" description="Run CakePHP unit tests
with PHPUnit"> <exec dir="${appdir}" executable="${appdir}/Console/cake" output="${logdir}/caketest.log" checkreturn="true"> <arg line="test" /> <!-- ͔͜͜Β --> <arg line="--log-junit=${appdir}/reports/unittest.xml" /> <arg line="--coverage-html=${appdir}/reports" /> <arg line="--coverage-clover=${appdir}/reports/ coverage.xml" /> <!-- ͜͜·ͰՃ --> <arg line="app" /> <arg line="AllTests" /> </exec> </target>
UnitTest݁ՌΛදࣔ͢Δ ! — मਖ਼Λίϛοτ $ git add build.xml $ git
commit -m 'Ϣχοτςετͷ݁ՌΛϑΝΠϧ ʹग़ྗ' $ git push origin master
UnitTest݁ՌΛදࣔ͢Δ
UnitTest݁ՌΛදࣔ͢Δ app/reports/unittest.xml
UnitTest݁ՌΛදࣔ͢Δ
UnitTest݁ՌΛදࣔ͢Δ app/reports/ app/reports/coverage.xml मਖ਼ͨ͠Βอଘͯ͠Ϗϧυ࣮ߦ νΣοΫ͢Δ
UnitTest݁ՌΛදࣔ͢Δ
UnitTest݁ՌΛදࣔ͢Δ ConfigσΟϨΫτϦͷΧόϨοδ͕͍ʂ
UnitTest݁ՌΛදࣔ͢Δ ! — app/phpunit.xmlΛमਖ਼(ΧόϨοδͷআ֎ઃఆΛՃ) <phpunit> <filter> <blacklist> <directory suffix=".php">Plugin</directory> <directory
suffix=".php">Test</directory> <directory suffix=".php">Vendor</directory> <!-- ͔͜͜Β --> <directory suffix=".php">Config/bootstrap</directory> <file>Config/database.php</file> <-- ͜͜·ͰՃ --> </blacklist> </filter> </phpunit>
UnitTest݁ՌΛදࣔ͢Δ ! — मਖ਼Λίϛοτ $ git add app/phpunit.xml $ git
commit -m 'ΧόϨοδআ֎ରΛՃ' $ git push origin master
UnitTest݁ՌΛදࣔ͢Δ ΧΠθϯͨ͠ʂ
Behatͷ݁ՌΛදࣔ͢Δ — build.xmlΛमਖ਼ … <target name="build" depends="prepare,caketest,behat"/> … <!-- ͔͜͜Β
--> <target name="behat" description="Run CakePHP acceptance test with Behat"> <exec command="find ${appdir}/tmp -type d -print | xargs chmod 777" escape="false" /> <exec dir="${appdir}" executable="${appdir}/Console/cake" output="${logdir}/behat.log" checkreturn="true"> <arg line="Bdd.story" /> <arg line="--format=junit" /> <arg line="--out=${appdir}/reports" /> </exec> </target> <!-- ͜͜·ͰՃ -->
Behatͷ݁ՌΛදࣔ͢Δ ! — मਖ਼Λίϛοτ $ git add build.xml $ git
commit -m 'BehatςετΛՃ' $ git push origin master
Behatͷ݁ՌΛදࣔ͢Δ app/reports/*.xml ʹमਖ਼ मਖ਼ͨ͠Βอଘͯ͠Ϗϧυ࣮ߦ
Behatͷ݁ՌΛදࣔ͢Δ
੩తղੳΛ࣮ߦ͢Δ $ cd /var/www/application/current/app $ composer require --dev "cakephp/cakephp-codesniffer:0.1.*" $
composer require --dev "phpmd/phpmd:2.*" $ composer require --dev "sebastian/phpcpd:2.*"
੩తղੳΛ࣮ߦ͢Δ ! — मਖ਼Λίϛοτ $ git add composer.json composer.lock $
git commit -m 'ΠϯεϖΫγϣϯπʔϧͷՃ' $ git push origin master
੩తղੳΛ࣮ߦ͢Δ — build.xmlΛमਖ਼(1) … <!-- Properties --> <property name="basedir" value="${phing.dir}"
/> <property name="appdir" value="${basedir}/app" /> <property name="logdir" value="${appdir}/tmp/logs" /> <!-- vendorbindir Ճ --> <property name="vendorbindir" value="${appdir}/Vendor/bin" /> ! <!-- Build --> <target name="build" depends="prepare,caketest,behat,phpcs,phpmd,phpcpd"/> …
੩తղੳΛ࣮ߦ͢Δ — build.xmlΛमਖ਼(2) - PHPCodeSnifferͷઃఆΛՃ … <target name="phpcs" description="Find coding
standard violations using PHP_CodeSniffer."> <exec dir="${basedir}" executable="${vendorbindir}/phpcs" output="$ {logdir}/phpcs.log"> <arg line="--config-set" /> <arg line="installed_paths" /> <arg line="${appdir}/Vendor/cakephp/cakephp-codesniffer" /> </exec> <exec dir="${basedir}" executable="${vendorbindir}/phpcs" output="$ {logdir}/phpcs.log"> <arg line="--ignore=Test,Vendor,Plugin" /> <arg line="--report=checkstyle" /> <arg line="--report-checkstyle=${appdir}/reports/checkstyle.xml" /> <arg line="--standard=CakePHP" /> <arg line="--extensions=php" /> <arg line="${appdir}" /> </exec> </target>
੩తղੳΛ࣮ߦ͢Δ — build.xmlΛमਖ਼(3) - PHPMDͷઃఆΛՃ … <target name="phpmd" description="Perform project
mess detection using PHPMD"> <exec dir="${basedir}" executable="${vendorbindir}/phpmd" output="${logdir}/phpmd.log"> <arg line="${appdir}" /> <arg line="xml" /> <arg line="codesize,unusedcode,design,naming" /> <arg line="--exclude ${appdir}/Test,${appdir}/Vendor,$ {appdir}/Plugin" /> <arg line="--reportfile ${appdir}/reports/phpmd.xml" /> </exec> </target>
੩తղੳΛ࣮ߦ͢Δ — build.xmlΛमਖ਼(4) - PHPCPDͷઃఆΛՃ … <target name="phpcpd" description="Perform project
mess detection using PHPMD"> <exec dir="${basedir}" executable="${vendorbindir}/phpcpd" output="${logdir}/phpcpd.log"> <arg line="--exclude Vendor" /> <arg line="--exclude Plugin" /> <arg line="--exclude webroot" /> <arg line="--log-pmd ${appdir}/reports/phpcpd.xml" /> <arg line="--names *.php,*.cpt" /> <arg line="${appdir}" /> </exec> </target>
੩తղੳΛ࣮ߦ͢Δ ! — मਖ਼Λίϛοτ $ git add build.xml $ git
commit -m 'ΠϯεϖΫγϣϯͷ࣮ߦΛՃ' $ git push origin master
੩తղੳΛ࣮ߦ͢Δ app/reports/checkstyle.xml app/reports/phpmd.xml app/reports/phpcpd.xml मਖ਼ͨ͠Βอଘͯ͠Ϗϧυ࣮ߦ
੩తղੳΛ࣮ߦ͢Δ MigrationͱSchemaʹܯࠂ
੩తղੳΛ࣮ߦ͢Δ — build.xmlΛमਖ਼(5) - PHPMDͷআ֎σΟϨΫτϦՃ … <target name="phpmd" description="Perform project
mess detection using PHPMD"> <exec dir="${basedir}" executable="${vendorbindir}/phpmd" output="${logdir}/phpmd.log"> <arg line="${appdir}" /> <arg line="xml" /> <arg line="codesize,unusedcode,design,naming" /> <!-- ͜͜ʹઃఆΛՃ(,${appdir}/Config/Migration,${appdir}/Config/Schema) --> <arg line="--exclude ${appdir}/Test,${appdir}/Vendor,$ {appdir}/Plugin,${appdir}/Config/Migration,${appdir}/Config/Schema" /> <!- ͜͜·Ͱ --> <arg line="--reportfile ${appdir}/reports/phpmd.xml" /> </exec> </target>
੩తղੳΛ࣮ߦ͢Δ ! — मਖ਼Λίϛοτ $ git add build.xml $ git
commit -m 'PMDͷআ֎σΟϨΫτϦΛՃ' $ git push origin master
੩తղੳΛ࣮ߦ͢Δ ΧΠθϯͨ͠ʂ
υΩϡϝϯτΛੜ͢Δ — build.xmlΛमਖ਼(1) … <target name="build" depends=“prepare,caketest,behat,phpcs,phpmd,phpcpd,phpdoc"/> … <!—- ҎԼΛՃ
—> <target name="phpdoc" description="Generate Application Documentation using phpDocumentor"> <exec dir="${basedir}" executable="phpdoc" output="${logdir}/phpdoc.log" checkreturn="true"> <arg line="run" /> <arg line="-t ${appdir}/reports/doc" /> <arg line="-d ${appdir}/" /> <arg line="-e php" /> <arg line="-i ${appdir}/Vendor/,${appdir}/Plugin/,${appdir}/Test/,$ {appdir}/Config/" /> <arg line="-p" /> </exec> </target>
υΩϡϝϯτΛੜ͢Δ ! $ git add build.xml $ git commit -m
'υΩϡϝϯτੜͷ࣮ߦΛՃ' $ git push origin master
υΩϡϝϯτΛੜ͢Δ
υΩϡϝϯτΛੜ͢Δ ՃΛԡͯ͠ҎԼͷΑ͏ʹઃఆ app/reports/doc/ index.html API Documen
υΩϡϝϯτΛੜ͢Δ
υΩϡϝϯτΛੜ͢Δ app/Model/Post.phpʹҎԼͷ༷ʹίϝϯτΛՃ <?php App::uses('AppModel', 'Model'); ! /** * Post Model
* * ϒϩάهࣄ༻ϞσϧͰ͢ * * @copyright php_ci_book * @link https://github.com/phpcibook/blogapp/blob/master/app/Model/Post.php * @since 1.0 * @auther ࡞ऀͷ໊લ <
[email protected]
> * */ class Post extends AppModel { …
υΩϡϝϯτΛੜ͢Δ app/Model/Post.phpʹҎԼͷ༷ʹίϝϯτΛՃ class Post extends AppModel { ! /** *
Ұཡදࣔ࣌ͷλΠτϧʹ༻͢ΔΧϥϜ໊ * * @var string */ public $displayField = 'title'; ! /** * όϦσʔγϣϯϧʔϧ * * @var array */ public $validate = [
υΩϡϝϯτΛੜ͢Δ ! $ git add app/Model/Post.php $ git commit -m
'DocBlockίϝϯτΛՃ' $ git push origin master मਖ਼ͨ͠Βอଘͯ͠Ϗϧυ࣮ߦ
υΩϡϝϯτΛੜ͢Δ
ຊ൪ڥʹDEPLOY͢Δ
ຊ൪ڥʹDEPLOY͢Δ $ vagrant ssh deploy $ ssh-keygen อଘॴ,ύεϑϨʔζೖྗ(ۭͰվߦͰ) $ cat
~/.ssh/id_rsa.pub ! ެ։伴Λίϐʔ
ຊ൪ڥʹDEPLOY͢Δ Add deploy keyΛΫϦοΫͯ͠ެ։伴ΛՃ
ຊ൪ڥʹDEPLOY͢Δ $ cd /var/www/application/current $ mkdir deploy $ cd deploy
$ cap install ! — .gitignoreʹҎԼΛՃ deploy/config/deploy/production.php CapistranoͷDeployεΫϦϓτͷͻͳܗΛ࡞
ຊ൪ڥʹDEPLOY͢Δ deploy/config/deploy/production.php ! <?php ! Environment::configure('production', true, [ 'MYSQL_DB_HOST' =>
'localhost', 'MYSQL_USERNAME' => 'webapp', 'MYSQL_PASSWORD' => 'passw0rd', 'MYSQL_DB_NAME' => 'blog', 'MYSQL_PREFIX' => '', 'debug' => 0, ], function() { }); ຊ൪αʔόʔ༻ͷઃఆϑΝΠϧΛՃ
ຊ൪ڥʹDEPLOY͢Δ $ cd /var/www/application/current/deploy/config/deploy $ vim production.rb ! server '192.168.33.200',
roles: %w{web app db}, user: 'vagrant', ssh_options: { password: fetch(:password) }, cake_env: "production", app_config:'production.php', group: 'vagrant' Deployઌͷઃఆ
ຊ൪ڥʹDEPLOY͢Δ $ cd /var/www/application/current/deploy/ $ vim reploy.rb ! — 5ߦͷϦϙδτϦURLΛ֤ࣗमਖ਼
set :repo_url, '
[email protected]
:phpcibook/blogapp.git' # (2) DeployεΫϦϓτΛमਖ਼ ϑΝΠϧͷৄࡉ stypi_ deploy.rbࢀর
ຊ൪ڥʹDEPLOY͢Δ $ cd /var/www/application/current/deploy/ $ cap production deploy Please enter
Server password: (): vagrant
ຊ൪ڥʹDEPLOY͢Δ $ cd /var/www/application/current/deploy/ $ cap production deploy Please enter
Server password: (): vagrant
։ൃฤ Fin @kaz_29