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
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
45
Greenは本当にGreenか? - B/GデプロイとAPI自動テストで安心デプロイ
kaz29
1
200
CI/CD/IaC 久々に0から環境を作ったらこうなりました
kaz29
1
500
開発エンジニアが実践する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 × TiDD / 2026.09.05 Redmine 大阪
tokudiro
1
180
数年滞っていたダークモード対応をおよそ2週間で完了させる
chigichan24
0
730
AI Agent時代のリアーキテクチャ戦略と実践
hokaccha
9
4.8k
Jetpack Compose メカニズム
skydoves
0
450
テストを司るデーモンに会いに行く 〜隔離した仮想マシンでテストを通すまで〜
h1d3mun3
1
530
AI が書く Go コードの品質を劇的に向上させる Linter: “declscope”
mpyw
0
380
スマート反転とウェブアクセシビリティ
camiha
0
210
手動確認はもう限界 〜XCUITestでCustom URL Schemeの遷移を起動種別ごとに自動テストする〜 / Testing Custom URL Schemes with XCUITest
otouto
0
310
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
300
スマートフォンでモールス信号を送受信する 〜スマートフォンのLEDとカメラで作る光通信の設計と実装〜
atsuki_seo
0
150
WebAssembly in Android Apps 〜 WASMはJNIの夢を見るか
keiji
1
110
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
220
Featured
See All Featured
Utilizing Notion as your number one productivity tool
mfonobong
4
590
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
240
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
420
The Limits of Empathy - UXLibs8
cassininazir
1
680
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1k
4 Signs Your Business is Dying
shpigford
187
23k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
890
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
430
Making Projects Easy
brettharned
120
6.8k
Building Applications with DynamoDB
mza
96
7.2k
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