diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5bb410e6c..7501ef3df 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,30 +1,35 @@ -services: - - chill/database:latest +.test_definition: &test_definition + services: + - chill/database:latest + before_script: + - composer config github-oauth.github.com $GITHUB_TOKEN + - composer install + - cp Tests/Fixtures/App/config/parameters.gitlab-ci.yml Tests/Fixtures/App/config/parameters.yml + - php Tests/Fixtures/App/console --env=test cache:warmup + - php Tests/Fixtures/App/console doctrine:migrations:migrate --env=test --no-interaction + - php Tests/Fixtures/App/console doctrine:fixtures:load --env=test --no-interaction + stages: - build-doc - deploy-doc - test + - deploy -before_script: - - composer config github-oauth.github.com $GITHUB_TOKEN - - composer install - - cp Tests/Fixtures/App/config/parameters.gitlab-ci.yml Tests/Fixtures/App/config/parameters.yml - - php Tests/Fixtures/App/console --env=test cache:warmup - - php Tests/Fixtures/App/console doctrine:migrations:migrate --env=test --no-interaction - - php Tests/Fixtures/App/console doctrine:fixtures:load --env=test --no-interaction + test:php-5.6: - stage: test - environment: testing - image: chill/ci-image:php-5.6 - script: phpunit + stage: test + <<: *test_definition + image: chill/ci-image:php-5.6 + script: phpunit + test:php-7: - stage: test - environment: testing - image: chill/ci-image:php-7 - script: phpunit + stage: test + <<: *test_definition + image: chill/ci-image:php-7 + script: phpunit # deploy documentation api-doc-build: @@ -42,3 +47,14 @@ api-doc-build: only: - master - tags + +deploy-packagist: + stage: deploy + image: chill/ci-image:php-7 + before_script: + # test that PACKAGIST USERNAME and PACKAGIST_TOKEN variable are set + - if [ -z ${PACKAGIST_USERNAME+x} ]; then echo "Please set PACKAGIST_USERNAME variable"; exit -1; fi + - if [ -z ${PACKAGIST_TOKEN+x} ]; then echo "Please set PACKAGIST_TOKEN variable"; exit -1; fi + script: + - STATUSCODE=$(curl -XPOST -H'content-type:application/json' "https://packagist.org/api/update-package?username=$PACKAGIST_USERNAME&apiToken=$PACKAGIST_TOKEN" -d"{\"repository\":{\"url\":\"$CI_PROJECT_URL.git\"}}" --silent --output /dev/stderr --write-out "%{http_code}") + - if [ $STATUSCODE = "202" ]; then exit 0; else exit $STATUSCODE; fi