.circleci/config.ymlのphpの場合のデフォルトファイル
以下、CircleCIでphpの場合、.circleci/config.ymlのversion2のデフォルトです。試行錯誤の書き換えが多いため、コメントを追加してデフォルトを残します。
– image について、circleci/php:latest に変えることが多いです。
# PHP CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-php/ for more details
#
version: 2
jobs: # a collection of steps
build: # runs not using Workflows must have a `build` job as entry point
docker: # run the steps with Docker
# Specify the version you desire here
- image: circleci/php:7.1-node-browsers # ...with this image as the primary container; this is where all `steps` will run
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# Using the RAM variation mitigates I/O contention
# for database intensive operations.
# - image: circleci/mysql:5.7-ram
#
# - image: redis:2.8.19
steps: # a set of executable commands
- checkout # special step to check out source code to working directory
- run: sudo apt update # PHP CircleCI 2.0 Configuration File# PHP CircleCI 2.0 Configuration File sudo apt install zlib1g-dev libsqlite3-dev
- run: sudo docker-php-ext-install zip
# Download and cache dependencies
- restore_cache: # special step to restore the dependency cache if `composer.lock` does not change
keys:
# "composer.lock" can be used if it is committed to the repo
- v1-dependencies-{{ checksum "composer.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: composer install -n --prefer-dist
- save_cache: # special step to save the dependency cache with the `composer.lock` cache key template
key: v1-dependencies-{{ checksum "composer.json" }}
paths:
- ./vendor
- restore_cache: # special step to restore the dependency cache if `package.json` does not change
keys:
- node-v1-{{ checksum "package.json" }}
- node-v1-
- run: yarn install
- save_cache: # special step to save the dependency cache with the `package.json` cache key template
key: node-v1-{{ checksum "package.json" }}
paths:
- node_modules
# prepare the database
- run: touch storage/testing.sqlite
- run: php artisan migrate --env=testing --database=sqlite_testing --force
# run tests with phpunit or codecept
#- run: ./vendor/bin/phpunit
- run: ./vendor/bin/codecept build
- run: ./vendor/bin/codecept run
# See https://circleci.com/docs/2.0/deployment-integrations/ for deploy examples