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

CircleCI 2.0 を使い倒そう / phpcon kansai 2018 circlc...

CircleCI 2.0 を使い倒そう / phpcon kansai 2018 circlci docker

PHPカンファレンス関西 2018 CircleCI 2.0 を使い倒そうというタイトルでトークしたものです

TAKAHASHI Kunihiko

July 14, 2018
Tweet

More Decks by TAKAHASHI Kunihiko

Other Decks in Technology

Transcript

  1. DJSDMFDJDPOpHZNM version: 2 jobs: build: docker: - image: circleci/php:7.1-apache-browsers -

    image: circleci/mysql:5.7 steps: - checkout - restore_cache: keys: - composer-{{ arch }}—{{ checksum "composer.lock" }} - run: composer install - save_cache: key: composer-{{ arch }}—{{ checksum "composer.lock" }} paths: - ~/.composer/cache - run: ./vendor/bin/phpcs —standard=PSR2 ./app - run: mkdir ~/phpunit - run: ./vendor/bin/phpunit --log-junit ~/phpunit/junit.xml - store_test_results: path: ~/phpunit - store_artifacts: path: ~/phpunit
  2. DJSDMFDJDPOpHZNM version: 2 jobs: build: docker: - image: circleci/php:7.1-apache-browsers -

    image: circleci/mysql:5.7 steps: - checkout - restore_cache: keys: - composer-{{ arch }}—{{ checksum "composer.lock" }} - run: composer install - save_cache: key: composer-{{ arch }}—{{ checksum "composer.lock" }} paths: - ~/.composer/cache - run: ./vendor/bin/phpcs —standard=PSR2 ./app - run: mkdir ~/phpunit - run: ./vendor/bin/phpunit --log-junit ~/phpunit/junit.xml - store_test_results: path: ~/phpunit - store_artifacts: path: ~/phpunit
  3. DJSDMFDJDPOpHZNM version: 2 jobs: build: docker: - image: circleci/php:7.1-apache-browsers -

    image: circleci/mysql:5.7 steps: - checkout - restore_cache: keys: - composer-{{ arch }}—{{ checksum "composer.lock" }} - run: composer install - save_cache: key: composer-{{ arch }}—{{ checksum "composer.lock" }} paths: - ~/.composer/cache - run: ./vendor/bin/phpcs —standard=PSR2 ./app - run: mkdir ~/phpunit - run: ./vendor/bin/phpunit --log-junit ~/phpunit/junit.xml - store_test_results: path: ~/phpunit - store_artifacts: path: ~/phpunit
  4. DJSDMFDJDPOpHZNM version: 2 jobs: build: docker: - image: circleci/php:7.1-apache-browsers -

    image: circleci/mysql:5.7 steps: - checkout - restore_cache: keys: - composer-{{ arch }}—{{ checksum "composer.lock" }} - run: composer install - save_cache: key: composer-{{ arch }}—{{ checksum "composer.lock" }} paths: - ~/.composer/cache - run: ./vendor/bin/phpcs —standard=PSR2 ./app - run: mkdir ~/phpunit - run: ./vendor/bin/phpunit --log-junit ~/phpunit/junit.xml - store_test_results: path: ~/phpunit - store_artifacts: path: ~/phpunit
  5. SVO ✓ίϚϯυΛ࣮ߦ͢Δ΋ͷͩ ͕ɺ࣮ߦը໘Ͱදࣔ͢Δจࣈ ྻΛઃఆͰ͖Δ - run: ./vendor/bin/phpunit --log-junit ~/phpunit/junit.xml -

    run: name: run tests command: ./vendor/bin/phpunit --log-junit ~/phpunit/junit.xml - run: name: run tests command: | ./vendor/bin/phpunit --log-junit ~/phpunit/junit.xml
  6. ෳ਺ͷ%PDLFSΠϝʔδΛ࢖͏ ✓EPDLFSFYFDVUPSͷઃఆͰෳ਺ͷΠϝʔδΛࢦఆ͢Δ ✓ͭ໨ʹࢦఆͨ͠Πϝʔδ͕ϓϥΠϚϦΠϝʔδʹͳΓɺ TUFQTҎ߱ͷίϚϯυ͸ͦͷΠϝʔδʹର࣮ͯ͠ߦ͞ΕΔ ✓ͦͷଞͷίϯςφͷϓϩηεʹ͸ɺ ϙʔτ൪ ߸ ͰΞΫηεͰ͖Δ version: 2

    jobs: build: docker: - image: php:7.1-apache - image: circleci/mysql:5.7 environment: MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: test_app MYSQL_USER: test MYSQL_PASSWORD: test - image: redis:3.2
  7. DJSDMFDJDPOpHZNM version: 2 jobs: phpcs: ... test: ... deploy: ...

    workflows: version: 2 phpcs_test_deploy_workflow: jobs: - phpcs - test: requires: - phpcs - deploy filters: branches: only: - master requires: - test
  8. DJSDMFDJDPOpHZNM version: 2 jobs: daily_job: ... workflows: version: 2 cron_workflow:

    triggers: - schedule: cron: “0 18 * * *” filters: branches: only: - develop jobs: - daily_job
  9. 7.ͱͷҧ͍ )8 04 )ZQFSWJTPS )8 )8 04 04 "QBDIF 3FEJT

    1)1 "QQT )8 04 .Z42- 7. )8 04 %PDLFS&OHJOF "QBDIF 3FEJT 1)1 "QQT .Z42- %PDLFS
  10. %PDLFSͷಈ࡞ Registry image container docker image pull docker image push

    docker container run docker container commit Dockerfile docker image build docker container exec
  11. %PDLFSpMFͱCVJMEํ๏ FROM php:7.2-cli RUN pecl install xdebug-2.6.0 \ && docker-php-ext-enable

    xdebug docker build -t kunit/php:7.2-cli . docker run -it --rm kunit/php:7.2-cli php -v docker run -it --rm php:7.2-cli php -v