Modular CircleCI

This commit is contained in:
Alexandre BRACH
2019-05-02 13:55:54 +02:00
parent 2c42f018bd
commit 0e8c8acc2e

View File

@@ -1,102 +1,133 @@
version: 2 version: 2.1
orbs:
aws-ecr: circleci/aws-ecr@4.0.1
jobs: jobs:
build:
working_directory: ~/alchemy-fr/Phraseanet build:
parallelism: 2
shell: /bin/bash --login
environment:
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
docker:
- image: circleci/build-image:ubuntu-14.04-XXL-upstart-1189-5614f37
command: /sbin/init
steps:
- checkout
- run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
- run:
working_directory: ~/alchemy-fr/Phraseanet working_directory: ~/alchemy-fr/Phraseanet
command: nvm install v10.12.0 && nvm alias default v10.12.0 parallelism: 2
- run: shell: /bin/bash --login
working_directory: ~/alchemy-fr/Phraseanet environment:
command: 'sudo service memcached status || sudo service memcached start; sudo CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
redis-cli ping >/dev/null 2>&1 || sudo service redis-server start; sudo CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
service mysql status || sudo service mysql start; sudo service rabbitmq-server docker:
status || sudo service rabbitmq-server start; ' - image: circleci/build-image:ubuntu-14.04-XXL-upstart-1189-5614f37
# Dependencies command: /sbin/init
# This would typically go in either a build or a build-and-test job when using workflows steps:
# Restore the dependency cache - checkout
- restore_cache: - run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
keys: - run:
# This branch if available working_directory: ~/alchemy-fr/Phraseanet
- v1-dep-{{ .Branch }}- command: nvm install v10.12.0 && nvm alias default v10.12.0
# Default branch if not - run:
- v1-dep-master- working_directory: ~/alchemy-fr/Phraseanet
# Any branch if there are none on the default branch - this should be unnecessary if you have your default branch configured correctly command: 'sudo service memcached status || sudo service memcached start; sudo
- v1-dep- redis-cli ping >/dev/null 2>&1 || sudo service redis-server start; sudo
# This is based on your 1.0 configuration file or project settings service mysql status || sudo service mysql start; sudo service rabbitmq-server
- run: echo 127.0.0.1 redis elasticsearch db rabbitmq | sudo tee -a /etc/hosts status || sudo service rabbitmq-server start; '
- run: git clone https://github.com/alanxz/rabbitmq-c # Dependencies
- run: cd rabbitmq-c && git checkout 2ca1774489328cde71195f5fa95e17cf3a80cb8a # This would typically go in either a build or a build-and-test job when using workflows
- run: cd rabbitmq-c && git submodule init && git submodule update && autoreconf -i && ./configure && make && sudo make install # Restore the dependency cache
# disabled because pear.php.net is down cause of security failure - restore_cache:
#- run: pecl channel-update pear.php.net keys:
- run: yes '' | pecl install amqp-1.9.3 # This branch if available
- run: yes '' | pecl install imagick - v1-dep-{{ .Branch }}-
- run: sudo apt-get install libzmq-dev # Default branch if not
- run: yes '' | pecl install zmq-beta - v1-dep-master-
- run: echo "extension = amqp.so" > /opt/circleci/php/$(phpenv global)/etc/conf.d/amqp.ini # Any branch if there are none on the default branch - this should be unnecessary if you have your default branch configured correctly
- run: echo "extension = zmq.so" > /opt/circleci/php/$(phpenv global)/etc/conf.d/zmq.ini - v1-dep-
- run: echo "date.timezone = UTC" > /opt/circleci/php/$(phpenv global)/etc/conf.d/timezone.ini # This is based on your 1.0 configuration file or project settings
- run: sed -i 's/^\(session.cache_limiter = \).*/\1""/' /opt/circleci/php/$(phpenv global)/etc/php.ini - run: echo 127.0.0.1 redis elasticsearch db rabbitmq | sudo tee -a /etc/hosts
- run: npm rebuild node-sass - run: git clone https://github.com/alanxz/rabbitmq-c
# This is based on your 1.0 configuration file or project settings - run: cd rabbitmq-c && git checkout 2ca1774489328cde71195f5fa95e17cf3a80cb8a
- run: composer install --no-progress --no-interaction --optimize-autoloader - run: cd rabbitmq-c && git submodule init && git submodule update && autoreconf -i && ./configure && make && sudo make install
# This is based on your 1.0 configuration file or project settings # disabled because pear.php.net is down cause of security failure
- run: node -v #- run: pecl channel-update pear.php.net
- run: npm -v - run: yes '' | pecl install amqp-1.9.3
- run: npm install - run: yes '' | pecl install imagick
- run: if [[ ! -e elasticsearch-2.3.3 ]]; then wget --no-check-certificate https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-2.3.3.tar.gz && tar -xvf elasticsearch-2.3.3.tar.gz && elasticsearch-2.3.3/bin/plugin install analysis-icu; fi - run: sudo apt-get install libzmq-dev
- run: - run: yes '' | pecl install zmq-beta
command: elasticsearch-2.3.3/bin/elasticsearch - run: echo "extension = amqp.so" > /opt/circleci/php/$(phpenv global)/etc/conf.d/amqp.ini
background: true - run: echo "extension = zmq.so" > /opt/circleci/php/$(phpenv global)/etc/conf.d/zmq.ini
# Save dependency cache - run: echo "date.timezone = UTC" > /opt/circleci/php/$(phpenv global)/etc/conf.d/timezone.ini
- save_cache: - run: sed -i 's/^\(session.cache_limiter = \).*/\1""/' /opt/circleci/php/$(phpenv global)/etc/php.ini
key: v1-dep-{{ .Branch }}-{{ epoch }} - run: npm rebuild node-sass
paths: # This is based on your 1.0 configuration file or project settings
# This is a broad list of cache paths to include many possible development environments - run: composer install --no-progress --no-interaction --optimize-autoloader
# You can probably delete some of these entries # This is based on your 1.0 configuration file or project settings
- vendor/bundle - run: node -v
- ~/virtualenvs - run: npm -v
- ~/.m2 - run: npm install
- ~/.ivy2 - run: if [[ ! -e elasticsearch-2.3.3 ]]; then wget --no-check-certificate https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-2.3.3.tar.gz && tar -xvf elasticsearch-2.3.3.tar.gz && elasticsearch-2.3.3/bin/plugin install analysis-icu; fi
- ~/.bundle - run:
- ~/.go_workspace command: elasticsearch-2.3.3/bin/elasticsearch
- ~/.gradle background: true
- ~/.cache/bower # Save dependency cache
# These cache paths were specified in the 1.0 config - save_cache:
- elasticsearch-2.3.3 key: v1-dep-{{ .Branch }}-{{ epoch }}
- node_modules paths:
- ~/.composer # This is a broad list of cache paths to include many possible development environments
# This is based on your 1.0 configuration file or project settings # You can probably delete some of these entries
- run: mysql -u ubuntu -e 'CREATE DATABASE update39_test;CREATE DATABASE ab_test;CREATE DATABASE db_test;SET @@global.sql_mode=STRICT_ALL_TABLES;SET @@global.max_allowed_packet=33554432;SET @@global.wait_timeout=999999;'; - vendor/bundle
# This is based on your 1.0 configuration file or project settings - ~/virtualenvs
- run: ./bin/developer system:uninstall -v - ~/.m2
- run: ./bin/setup system:install -v --email=test@phraseanet.com --password=test --db-host=127.0.0.1 --db-user=ubuntu --db-template=fr-simple --db-password= --databox=db_test --appbox=ab_test --server-name=http://127.0.0.1 -y; - ~/.ivy2
- run: ./bin/developer ini:setup-tests-dbs -v - ~/.bundle
- run: ./bin/console searchengine:index:create -v - ~/.go_workspace
- run: ./bin/developer phraseanet:regenerate-sqlite -v - ~/.gradle
- run: ./bin/developer phraseanet:generate-js-fixtures -v - ~/.cache/bower
# Test # These cache paths were specified in the 1.0 config
# This would typically be a build job when using workflows, possibly combined with build - elasticsearch-2.3.3
# This is based on your 1.0 configuration file or project settings - node_modules
- run: case $CIRCLE_NODE_INDEX in 0) EXIT=0; php -d memory_limit=-1 bin/phpunit --log-junit $CIRCLE_TEST_REPORTS/phpunit/junit-unit.xml --exclude-group legacy || EXIT=$?; php -d memory_limit=-1 bin/phpunit --log-junit $CIRCLE_TEST_REPORTS/phpunit/junit-legacy-no-web.xml --group legacy --exclude-group web || EXIT=$?; exit $EXIT;; 1) php -d memory_limit=-1 bin/phpunit --log-junit $CIRCLE_TEST_REPORTS/phpunit/junit-legacy-web.xml --group web ;; esac - ~/.composer
# Teardown # This is based on your 1.0 configuration file or project settings
# If you break your build into multiple jobs with workflows, you will probably want to do the parts of this that are relevant in each - run: mysql -u ubuntu -e 'CREATE DATABASE update39_test;CREATE DATABASE ab_test;CREATE DATABASE db_test;SET @@global.sql_mode=STRICT_ALL_TABLES;SET @@global.max_allowed_packet=33554432;SET @@global.wait_timeout=999999;';
# Save test results # This is based on your 1.0 configuration file or project settings
- store_test_results: - run: ./bin/developer system:uninstall -v
path: /tmp/circleci-test-results - run: ./bin/setup system:install -v --email=test@phraseanet.com --password=test --db-host=127.0.0.1 --db-user=ubuntu --db-template=fr-simple --db-password= --databox=db_test --appbox=ab_test --server-name=http://127.0.0.1 -y;
# Save artifacts - run: ./bin/developer ini:setup-tests-dbs -v
- store_artifacts: - run: ./bin/console searchengine:index:create -v
path: /tmp/circleci-artifacts - run: ./bin/developer phraseanet:regenerate-sqlite -v
- store_artifacts: - run: ./bin/developer phraseanet:generate-js-fixtures -v
path: /tmp/circleci-test-results # Test
# This would typically be a build job when using workflows, possibly combined with build
# This is based on your 1.0 configuration file or project settings
- run: case $CIRCLE_NODE_INDEX in 0) EXIT=0; php -d memory_limit=-1 bin/phpunit --log-junit $CIRCLE_TEST_REPORTS/phpunit/junit-unit.xml --exclude-group legacy || EXIT=$?; php -d memory_limit=-1 bin/phpunit --log-junit $CIRCLE_TEST_REPORTS/phpunit/junit-legacy-no-web.xml --group legacy --exclude-group web || EXIT=$?; exit $EXIT;; 1) php -d memory_limit=-1 bin/phpunit --log-junit $CIRCLE_TEST_REPORTS/phpunit/junit-legacy-web.xml --group web ;; esac
# Teardown
# If you break your build into multiple jobs with workflows, you will probably want to do the parts of this that are relevant in each
# Save test results
- store_test_results:
path: /tmp/circleci-test-results
# Save artifacts
- store_artifacts:
path: /tmp/circleci-artifacts
- store_artifacts:
path: /tmp/circleci-test-results
workflows:
version: 2
oldfashion:
jobs:
- build:
filters:
branches:
only:
- master
newfashion:
jobs:
- aws-ecr/build_and_push_image:
account-url: AWS_ACCOUNT_URL
aws-access-key-id: AWS_ACCESS_KEY_ID
aws-secret-access-key: AWS_SECRET_ACCESS_KEY
context: AWS
create-repo: true
dockerfile: Dockerfile
#profile-name: myProfileName
region: AWS_DEFAULT_REGION
repo: "${AWS_RESOURCE_NAME_PREFIX}/phraseanet"
tag: "alpha-0.1"
filters:
branches:
only:
- PHRAS-2539