.circleci/config.yml
# PHP CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-php/ for more details
#
version: 2
environment: &environment
- SS_DATABASE_SERVER=127.0.0.1
- SS_DATABASE_USERNAME=root
- SS_DATABASE_PASSWORD=ubuntu
- SS_DATABASE_NAME=circle_test
- SS_ENVIRONMENT_TYPE=test
- SS_DEFAULT_ADMIN_USERNAME=admin
- SS_DEFAULT_ADMIN_PASSWORD=password
- DEBUGBAR_DISABLE=true
mysql: &mysql
- MYSQL_USER=toor
- MYSQL_ROOT_PASSWORD=ubuntu
- MYSQL_DATABASE=circle_test
- MYSQL_HOST=127.0.0.1
errorlog: &errorlog
name: Error log setup
command: |
echo ' ' > error.log
chmod 777 error.log
create_index_requirements: &CircleCITestIndexReqs
name: Setup Integration Pre-requisites
command: |
cp .circleci/.env.test ./.env
cp .circleci/CircleCITestIndex.phpsrc app/src/CircleCITestIndex.php
cp .circleci/TestIndexTwo.yml app/_config/search.yml
core_check: &CheckSolrCore
name: Check Solr Core - CircleCITestIndex is successfully created
command: |
RESPONSE=$(echo $(curl -I http://localhost:8983/solr/CircleCITestIndex/admin/ping | head -n1 ) | grep -o '200 OK')
if [[ $RESPONSE != '200 OK' ]]; then echo "Solr Core - CircleCITestIndex is not created"; exit 1; fi
echo "CircleCITestIndex is successfully created"
composer: &composerRequirements
name: Composer requirements
command: |
composer config --no-interaction allow-plugins.composer/installers true
composer config --no-interaction allow-plugins.silverstripe/vendor-plugin true
composer config --no-interaction allow-plugins.silverstripe/recipe-plugin true
composer config --no-interaction allow-plugins.php-http/discovery true
composer require myclabs/deep-copy:1.9.1 silverstripe/recipe-cms:^4.10 --no-progress
composer update --no-progress
composer vendor-expose
db_build: &dev_build
name: Build the database
command: |
vendor/bin/sake dev/build flush=all skipannotation=true
jobs:
solr8:
environment:
CC_TEST_REPORTER_ID: 586f7041e9f71c44946cdfe8bce27d66c6271d173ec291c2a9aa7e1b56667873
docker:
- image: ssmarco/php-solr:7.4
environment: *environment
- image: cimg/mariadb:10.8
environment: *mysql
working_directory: /var/www/html
steps:
- checkout
- run: *errorlog
- run: echo '{}' > composer.lock
- restore_cache:
keys:
- silverstripe-search-cache-v8-{{ checksum "composer.lock" }}
- silverstripe-search-cache-v8-
- run: *composerRequirements
- save_cache:
key: silverstripe-search-cache-v8-{{ checksum "composer.lock" }}
paths:
- vendor
- app
- public
- resources
- _resources
- run: *CircleCITestIndexReqs
- run: *dev_build
- run:
name: Permission changes
command: |
usermod -a -G www-data solr
groups solr
usermod -a -G solr www-data
groups www-data
chown -R solr:www-data /var/www/html
chmod -R u+rwxs,g+rwxs /var/www/html
- run:
name: Run Solr Configure
command: |
service apache2 restart
mkdir -p /var/www/html/.solr/data && chmod -R 777 /var/www/html/.solr
cp .circleci/security.json /var/www/html/.solr/data/security.json
chown -R solr:solr /var/www/html/.solr
service solr restart
su solr vendor/bin/sake dev/tasks/SolrConfigureTask
- run: su solr vendor/bin/sake dev/tasks/SolrIndexTask unittest=true
- run:
name: Run tests
command: |
set +e
su solr -s $SHELL -c 'vendor/bin/phpunit --coverage-clover=clover.xml --log-junit ./coverage/junit.xml -d memory_limit=512M tests/unit'
- run:
name: Code coverage reports
command: |
echo "---"
echo "Scrutinizer:"
echo "---"
php ocular.phar code-coverage:upload --format=php-clover clover.xml
echo "---"
echo "CodeCov:"
echo "---"
bash <(curl -s https://codecov.io/bash) -f clover.xml
echo "---"
echo "CodeClimate:"
echo "---"
./cc-test-reporter after-build --coverage-input-type clover --exit-code $?
- store_test_results:
path: /var/www/html/coverage
- store_artifacts:
path: /var/www/html/coverage
destination: phpunit
solr4:
docker:
- image: brettt89/silverstripe-web:7.1-platform
environment: *environment
- image: cimg/mariadb:10.8
environment: *mysql
working_directory: /var/www/html
steps:
- run: apt-get update;apt-get install wget default-jre apt-transport-https lsb-release netcat software-properties-common -y
- checkout
- run: *errorlog
- run: echo '{}' > composer.lock
- run: php -v
- restore_cache:
keys:
- silverstripe-search-cache-v4-{{ checksum "composer.lock" }}
- silverstripe-search-cache-v4-
- run: *composerRequirements
- save_cache:
key: silverstripe-search-cache-v4-{{ checksum "composer.lock" }}
paths:
- vendor
- app
- public
- resources
- _resources
- run: *CircleCITestIndexReqs
- run: git clone git@github.com:silverstripe-archive/silverstripe-fulltextsearch-localsolr.git localsolr
- run:
name: Start a solr4 instance
command: |
cd localsolr/server;java -jar start.jar
background: true
- run: *dev_build
- run:
name: Run Solr Configure
command: |
service apache2 restart
mkdir -p /var/www/html/.solr && chmod -R 777 /var/www/html/.solr
vendor/bin/sake dev/tasks/SolrConfigureTask
- run: *CheckSolrCore
- run: vendor/bin/sake dev/tasks/SolrIndexTask unittest=true
- run:
name: Run tests
command: |
set +e
vendor/bin/phpunit --coverage-clover=clover.xml --log-junit ./coverage/junit.xml -d memory_limit=512M tests/unit
- store_test_results:
path: /var/www/html/coverage
- store_artifacts:
path: /var/www/html/coverage
destination: phpunit
docs:
docker:
- image: circleci/php:7.4
steps:
- add_ssh_keys:
fingerprints:
- "18:12:44:3c:09:ac:67:45:f3:b8:6c:bd:df:77:97:f3"
- run:
name: Install Graphviz and yarn
command: |
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install graphviz yarn wget -y
- run:
name: Setup SSH access to github
command: |
mkdir -p ~/.ssh
touch ~/.ssh/known_hosts
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
- run:
name: Install repositories
command: |
git clone git@github.com:Firesphere/Firesphere.github.io.git . -q
git clone git@github.com:Firesphere/silverstripe-solr-compatibility.git Compatibility -q
git clone git@github.com:Firesphere/silverstripe-solr-search.git Core -q
git clone git@github.com:Firesphere/silverstripe-fluent-solr.git Fluent -q
git clone git@github.com:Firesphere/silverstripe-subsite-solr.git Subsites -q
git clone git@github.com:Firesphere/silverstripe-solr-member-permissions.git Member-Permissions -q
- run:
name: Composer
command: |
composer require phploc/phploc squizlabs/php_codesniffer -W
- run:
name: Yarn
command: |
echo '{"scripts": {"docs": "markdown-folder-to-html"}}' > package.json
yarn add markdown-folder-to-html
- run:
name: Setup git
command: |
git config --global user.name "CircleCI"
git config --global user.email circleci@casa-laguna.net
git config --global push.default simple
- run:
name: Clear out old docs
command: |
rm -rf solr* docs
- run:
name: PHP API Docs
command: |
php phpdoc.phar -t solr-api --ignore "*/tests/"
- run:
name: Generate statistic docs
command: |
cp -r ./Core/docs .
echo "Main module"
echo "\`\`\`" >> docs/16-About/03-Codebase/01-Main-stats.md
vendor/bin/phploc Core/src/ >> docs/16-About/03-Codebase/01-Main-stats.md
echo "\`\`\`" >> docs/16-About/03-Codebase/01-Main-stats.md
echo "Compatibility module"
echo "\`\`\`" >> docs/16-About/03-Codebase/02-Compatibility-stats.md
vendor/bin/phploc Compatibility/src/ >> docs/16-About/03-Codebase/02-Compatibility-stats.md
echo "\`\`\`" >> docs/16-About/03-Codebase/02-Compatibility-stats.md
echo "Permission module"
echo "\`\`\`" >> docs/16-About/03-Codebase/03-Member-permission-stats.md
vendor/bin/phploc Member-Permissions/src/ >> docs/16-About/03-Codebase/03-Member-permission-stats.md
echo "\`\`\`" >> docs/16-About/03-Codebase/03-Member-permission-stats.md
echo "Fluent module"
echo "\`\`\`" >> docs/16-About/03-Codebase/04-Fluent-stats.md
vendor/bin/phploc Fluent/src/ >> docs/16-About/03-Codebase/04-Fluent-stats.md
echo "\`\`\`" >> docs/16-About/03-Codebase/04-Fluent-stats.md
echo "Subsites module"
echo "\`\`\`" >> docs/16-About/03-Codebase/05-Subsites-stats.md
vendor/bin/phploc Subsites/src/ >> docs/16-About/03-Codebase/05-Subsites-stats.md
echo "\`\`\`" >> docs/16-About/03-Codebase/05-Subsites-stats.md
- run:
name: Markdown to HTML
command: |
yarn docs
mv _docs solr-docs
rm -rf docs solr Core Subsites Fluent Compatibility Member-Permissions
- run:
name: Commit and upload if it's Primary
command: |
case $CIRCLE_BRANCH in "primary") git add . ;; esac
case $CIRCLE_BRANCH in "primary") git commit -m "API and Doc update for Solr from CircleCI update" ;; esac
case $CIRCLE_BRANCH in "primary") git push ;; esac
- run:
name: Check the CS status of all modules
command: |
echo "Core"
vendor/bin/phpcs --standard=Core/phpcs.xml.dist Core/src
echo "Fluent"
vendor/bin/phpcs --standard=Core/phpcs.xml.dist Fluent/src
echo "Subsites"
vendor/bin/phpcs --standard=Core/phpcs.xml.dist Subsites/src
echo "Compatibility"
vendor/bin/phpcs --standard=Core/phpcs.xml.dist Compatibility/src
echo "Permissions"
vendor/bin/phpcs --standard=Core/phpcs.xml.dist Member-Permissions/src
workflows:
version: 2
dobuild:
jobs:
- solr8
# - solr4
- docs