From 09aa4cc977dee5a4f8b62664902497946e71db13 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 16 May 2020 13:28:29 +0200 Subject: [PATCH] Changed travis build so that docker image publishing runs on its own separated job --- .travis.yml | 47 ++++++++++++++++++++++++++--------------------- docker/build | 1 + 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/.travis.yml b/.travis.yml index 70ba9eb0..e65db293 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,17 @@ branches: only: - /.*/ -php: - - '7.4' +jobs: + include: + - name: "Docker publish" + php: '7.4' + if: env(TRAVIS_PULL_REQUEST) = 'false' + env: + - DOCKER_PUBLISH="true" + - name: "CI" + php: '7.4' + env: + - DOCKER_PUBLISH="false" services: - docker @@ -17,32 +26,33 @@ cache: - $HOME/.composer/cache/files before_install: - - sudo ./data/infra/ci/install-docker.sh - - sudo ./data/infra/ci/install-ms-odbc.sh - - docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db_ms shlink_db shlink_db_postgres shlink_db_maria - - yes | pecl install pdo_sqlsrv swoole-4.4.18 - echo 'extension = apcu.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini - phpenv config-rm xdebug.ini || return 0 + - if [[ "${DOCKER_PUBLISH}" == 'false' ]]; then sudo ./data/infra/ci/install-docker.sh ; fi + - if [[ "${DOCKER_PUBLISH}" == 'false' ]]; then sudo ./data/infra/ci/install-ms-odbc.sh ; fi + - if [[ "${DOCKER_PUBLISH}" == 'false' ]]; then docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db_ms shlink_db shlink_db_postgres shlink_db_maria ; fi + - if [[ "${DOCKER_PUBLISH}" == 'false' ]]; then yes | pecl install pdo_sqlsrv swoole-4.4.18 ; fi install: - - composer self-update - - composer install --no-interaction --prefer-dist + - if [[ "${DOCKER_PUBLISH}" == 'false' ]]; then composer self-update ; fi + - if [[ "${DOCKER_PUBLISH}" == 'false' ]]; then composer install --no-interaction --prefer-dist ; fi before_script: - - docker-compose exec shlink_db_ms /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'Passw0rd!' -Q "CREATE DATABASE shlink_test;" + - if [[ "${DOCKER_PUBLISH}" == 'false' ]]; then docker-compose exec shlink_db_ms /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'Passw0rd!' -Q "CREATE DATABASE shlink_test;" ; fi - mkdir build - export DOCKERFILE_CHANGED=$(git diff ${TRAVIS_COMMIT_RANGE:-origin/master} --name-only | grep Dockerfile) script: - - composer ci - - if [[ ! -z "${DOCKERFILE_CHANGED}" && "${TRAVIS_PHP_VERSION}" == "7.4" && "${TRAVIS_PULL_REQUEST}" != 'false' ]]; then docker build -t shlink-docker-image:temp . ; fi + - if [[ "${DOCKER_PUBLISH}" == 'false' ]]; then composer ci ; fi + - if [[ ! -z "${DOCKERFILE_CHANGED}" && "${TRAVIS_PHP_VERSION}" == "7.4" && "${DOCKER_PUBLISH}" == "false" ]]; then docker build -t shlink-docker-image:temp . ; fi + - if [[ "${DOCKER_PUBLISH}" == 'true' ]]; then bash ./docker/build ; fi after_success: - rm -f build/clover.xml - - wget https://phar.phpunit.de/phpcov-7.0.2.phar - - phpdbg -qrr phpcov-7.0.2.phar merge build --clover build/clover.xml - - wget https://scrutinizer-ci.com/ocular.phar - - php ocular.phar code-coverage:upload --format=php-clover build/clover.xml + - if [[ "${DOCKER_PUBLISH}" == 'false' ]]; then wget https://phar.phpunit.de/phpcov-7.0.2.phar ; fi + - if [[ "${DOCKER_PUBLISH}" == 'false' ]]; then phpdbg -qrr phpcov-7.0.2.phar merge build --clover build/clover.xml ; fi + - if [[ "${DOCKER_PUBLISH}" == 'false' ]]; then wget https://scrutinizer-ci.com/ocular.phar ; fi + - if [[ "${DOCKER_PUBLISH}" == 'false' ]]; then php ocular.phar code-coverage:upload --format=php-clover build/clover.xml ; fi # Before deploying, build dist file for current travis tag before_deploy: @@ -56,11 +66,6 @@ deploy: file: "./build/shlink_${TRAVIS_TAG#?}_dist.zip" skip_cleanup: true on: + condition: "${DOCKER_PUBLISH}" == 'false' tags: true php: '7.4' - - provider: script - script: bash ./docker/build - on: - all_branches: true - condition: "${TRAVIS_PULL_REQUEST}" == 'false' - php: '7.4' diff --git a/docker/build b/docker/build index 4cc7f56a..141b0a8b 100755 --- a/docker/build +++ b/docker/build @@ -1,4 +1,5 @@ #!/bin/bash + set -e BUILDX_VER=v0.4.1