open-lms-open-source / moodle-plugin-ci

Assist with running a Moodle plugin in Travis CI
https://blackboard-open-source.github.io/moodle-plugin-ci/
GNU General Public License v3.0
42 stars 37 forks source link

Using Docker #80

Open bozoh opened 6 years ago

bozoh commented 6 years ago

travis support docker, so why not use docker with moodle-plugin-ci behat tests

here my configuration (it's use chrome browser image)

sudo: required

notifications:
  on_success: never #change #never # default: change
  on_failure: never #always # default: always

language: php

php:
  - 5.6
  - 7.0
  - 7.1
  - 7.2

addons:
  postgresql: "9.6"
  services:
    - docker

cache:
  directories:
    - $HOME/.composer/cache
    - $HOME/.npm
    - $HOME/.docker/cache

env:
  global:
    - MOODLE_START_BEHAT_SERVERS=NO
    - MOODLE_BRANCH=MOODLE_35_STABLE
    - DB=pgsql
    - DOCKER_IMAGE=selenium/standalone-chrome
    - DOCKER_TAG_VERSION=3.14.0-arsenic
    - MOODLE_CI_VER=2
    - MOODLE_DIR=/home/travis/build/moodle

matrix:
  # include:
  #   - php: 7.0
  #     env: MOODLE_BRANCH=MOODLE_33_STABLE
  # - env: MOODLE_BRANCH=MOODLE_34_STABLE MOODLE_CI_VER=2
  # - env: MOODLE_BRANCH=MOODLE_35_STABLE MOODLE_CI_VER=2
  exclude:
    - php: 5.6

before_install:
  - >
      IMAGE_FILE=image-$(echo "${DOCKER_IMAGE}" | sed  -e "s|/|-|g")-${DOCKER_TAG_VERSION}.tar;
      echo ${IMAGE_FILE};
      if [ ! -e "${HOME}/.docker/cache/${IMAGE_FILE}" ]; then
        rm -rf ${HOME}/.docker/cache/image*.tar;
        docker pull ${DOCKER_IMAGE}:${DOCKER_TAG_VERSION};
        docker save ${DOCKER_IMAGE}:${DOCKER_TAG_VERSION} -o ${HOME}/.docker/cache/${IMAGE_FILE};
      fi;
      docker load -i ${HOME}/.docker/cache/${IMAGE_FILE}

  - phpenv config-rm xdebug.ini
  - cd ../..
  - composer selfupdate
  - composer create-project -n --no-dev --prefer-dist moodlerooms/moodle-plugin-ci ci ^${MOODLE_CI_VER}
  - export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH"
  - sleep 10

install:
  - moodle-plugin-ci install
  - docker run --rm --net=host -d -p4444:4444 ${DOCKER_IMAGE}:${DOCKER_TAG_VERSION}
  - php -t ${MOODLE_DIR} -S localhost:8000 &>/tmp/www.log &
  - sleep 20s

script:
  #- moodle-plugin-ci behat --moodle=${MOODLE_DIR} --auto-rerun=0
  - moodle-plugin-ci behat --profile='chrome' --moodle=${MOODLE_DIR} --auto-rerun=0