Skip to content
Snippets Groups Projects
Commit 72143825 authored by jurgenhaas's avatar jurgenhaas
Browse files

Add ci template for testing and deploying Drupal sites

parent 8ca2b5e0
No related branches found
No related tags found
Loading
stages:
- build
- prepare
- test
- deploy
.wait:
script:
- while [ ! -f /tmp/foo.txt ]; do echo "waiting..."; sleep 1; done
.cache_paths: &cache_paths
paths:
- .docker-init/
- assets/
- config/
- drush/
- files/
- settings/
- vendor/
- web/core/
- web/libraries/
- web/modules/contrib/
- web/profiles/contrib/
- web/sites/
- web/themes/contrib/
- .ahoy.yml
- .env
- docker-compose.yml
.artifact_paths: &artifact_paths
paths:
- .docker-init/
- assets/
- config/
- drush/
- files/
- settings/
- tests/
- vendor/
- web/
- .ahoy.yml
- .env
- composer.*
- docker-compose.yml
.cache_default: &cache_default
key: build-${COMPOSE_PROJECT_NAME}
<<: *cache_paths
.build:
stage: build
tags:
- default
cache:
<<: *cache_default
policy: pull-push
script:
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan gitlab.lakedrops.com >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- ssh git@gitlab.lakedrops.com
- composer install --no-interaction --no-progress
- composer lakedrops:scaffold --no-interaction
- composer lakedrops:docker4drupal --no-interaction
- docker-compose up -d
- mkdir -p files/default/files/css
- mkdir -p files/default/files/js
- mkdir -p files/default/files/languages
- mkdir -p files/default/files/translations
- chmod -R ugo+w files/default/files/
artifacts:
name: build
when: always
<<: *artifact_paths
except:
refs:
- tags
variables:
- $CI_COMMIT_MESSAGE =~ /^Merge tag /i
.dumpdb:
stage: build
tags:
- ansible
variables:
GIT_STRATEGY: none
script:
- ascr drupal-dump-db ${CI_PROJECT_PATH} ${PWD}/${CI_PROJECT_NAME}.sql
cache: {}
artifacts:
name: dbdump
when: always
paths:
- ${COMPOSE_PROJECT_NAME}.sql
only:
variables:
- $CI_COMMIT_REF_NAME == "master"
- $CI_COMMIT_MESSAGE =~ /\[re-build-db\]/i
- $FORCE_DB_UPDATE == "yes"
except:
refs:
- tags
variables:
- $CI_COMMIT_MESSAGE =~ /^Merge tag /i
.importdb:
stage: prepare
tags:
- default
variables:
GIT_STRATEGY: none
script:
- docker cp ${COMPOSE_PROJECT_NAME}.sql ${COMPOSE_PROJECT_NAME}_php_1:/var/www/html
- drush sql:drop --yes
- drush sql:query --file=../${COMPOSE_PROJECT_NAME}.sql
- drush cr
- drush updatedb
- drush config-import sync
- drush cr
only:
variables:
- $CI_COMMIT_REF_NAME == "master"
- $CI_COMMIT_MESSAGE =~ /\[re-build-db\]/i
- $FORCE_DB_UPDATE == "yes"
except:
refs:
- tags
variables:
- $CI_COMMIT_MESSAGE =~ /^Merge tag /i
dependencies:
- 'Build Site'
- 'Download DB'
.updatedb:
stage: prepare
tags:
- default
variables:
GIT_STRATEGY: none
script:
- drush cr
- drush updatedb
- drush config-import sync
- drush cr
except:
refs:
- master
- tags
variables:
- $CI_COMMIT_MESSAGE =~ /^Merge tag /i
- $CI_COMMIT_MESSAGE =~ /\[re-build-db\]/i
- $FORCE_DB_UPDATE == "yes"
dependencies:
- 'Build Site'
.codestyle:
stage: test
tags:
- default
variables:
GIT_STRATEGY: none
script:
- ahoy test phpcs -- -n --report=xml --report-file=phpcs.xml
- docker cp ${COMPOSE_PROJECT_NAME}_php_1:/var/www/html/phpcs.xml ./phpcs.xml
artifacts:
name: phpcs
when: always
paths:
- phpcs.xml
dependencies:
- 'Build Site'
except:
refs:
- tags
variables:
- $CI_COMMIT_MESSAGE =~ /^Merge tag /i
.phpunit:
stage: test
tags:
- default
variables:
GIT_STRATEGY: none
script:
- ahoy test phpunit -- --log-junit junit.xml --testdox-html testdox.html
- docker cp ${COMPOSE_PROJECT_NAME}_php_1:/var/www/html/junit.xml ./junit.xml
- docker cp ${COMPOSE_PROJECT_NAME}_php_1:/var/www/html/testdox.html ./testdox.html
artifacts:
name: phpunit
when: always
paths:
- junit.xml
- testdox.html
reports:
junit: junit.xml
dependencies:
- 'Build Site'
except:
refs:
- tags
variables:
- $CI_COMMIT_MESSAGE =~ /^Merge tag /i
.behat:
stage: test
tags:
- default
variables:
GIT_STRATEGY: none
script:
- ahoy behat update -- --no-interaction
- ahoy behat test2xml
- docker cp ${COMPOSE_PROJECT_NAME}_php_1:/var/www/html/tests/output/default.xml ./behat.xml
retry: 1
artifacts:
name: behat
when: always
paths:
- behat.xml
dependencies:
- 'Build Site'
except:
refs:
- tags
variables:
- $CI_COMMIT_MESSAGE =~ /^Merge tag /i
.backstop:
stage: test
tags:
- default
variables:
GIT_STRATEGY: none
script:
- backstop test
artifacts:
name: backstop
when: always
paths:
- config/backstop_reference
- tests/backstop/backstop_data
dependencies:
- 'Build Site'
except:
refs:
- tags
variables:
- $CI_COMMIT_MESSAGE =~ /^Merge tag /i
.deploy:
stage: deploy
tags:
- ansible
variables:
GIT_STRATEGY: none
environment:
name: $ENVIRONMENT_NAME
script:
- ascr drupal-deploy $HOST_NAME drupal_${COMPOSE_PROJECT_NAME} ${EXTRAS}
cache: {}
dependencies: []
except:
refs:
- tags
variables:
- $CI_COMMIT_MESSAGE =~ /^Merge tag /i
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment