diff --git a/.github/workflows/php-test.yml b/.github/workflows/php-test.yml new file mode 100644 index 00000000..12e424dd --- /dev/null +++ b/.github/workflows/php-test.yml @@ -0,0 +1,143 @@ +name: PHP Codeception Tests + +on: + push: + branches: + - master + - develop + pull_request: + branches: + - master + - develop + +jobs: + tests: + name: PHP ${{ matrix.php-version }}-mysql-${{ matrix.mysql-version }}-humhub-${{ matrix.humhub-ref }} + env: + module-id: wiki + extensions: curl, intl, pdo, pdo_mysql, zip, exif, fileinfo, mbstring, gd + key: cache-v1 + + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: + - ubuntu-latest + + php-version: + - "7.2" + - "7.3" + - "7.4" + + humhub-ref: + - "develop" + - "master" + + mysql-version: + - "5.7" + + services: + mysql: + image: mysql:${{ matrix.mysql-version }} + env: + MYSQL_DATABASE: humhub_test + MYSQL_ROOT_PASSWORD: root + ports: + - 3306:3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + + steps: + - uses: actions/setup-node@v1 + + - name: Checkout HumHub Core + uses: actions/checkout@v2 + with: + repository: humhub/humhub + ref: ${{ matrix.humhub-ref }} + + - name: Checkout Module + uses: actions/checkout@v2 + with: + path: protected/modules/${{ env.module-id }} + + - name: Setup cache environment + id: cache-env + uses: shivammathur/cache-extensions@v1 + with: + php-version: ${{ matrix.php-version }} + extensions: ${{ env.extensions }} + key: ${{ env.key }} + + - name: Cache extensions + uses: actions/cache@v1 + with: + path: ${{ steps.cache-env.outputs.dir }} + key: ${{ steps.cache-env.outputs.key }} + restore-keys: ${{ steps.cache-env.outputs.key }} + + - name: Install PHP with extensions + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: ${{ env.extensions }} + ini-values: date.timezone='UTC' + + - name: Determine composer cache directory + if: matrix.os == 'ubuntu-latest' + run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Cache dependencies installed with composer + uses: actions/cache@v1 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }} + restore-keys: | + php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: Install dependencies with composer + run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi + + - name: Verify MySQL connection from host + run: | + sudo apt-get install -y mysql-client + mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -uroot -proot -e "SHOW DATABASES" + + - name: Install npm dependencies + run: npm install + + - name: Build production assets + run: grunt build-assets + + - name: Run migrations + run: php protected/humhub/tests/codeception/bin/yii migrate/up --includeModuleMigrations=1 --interactive=0 + + - name: Run installer + run: php protected/humhub/tests/codeception/bin/yii installer/auto + + - name: Rebuild search index + run: php protected/humhub/tests/codeception/bin/yii search/rebuild + + - name: Build codeception core files + run: | + cd $GITHUB_WORKSPACE/protected/humhub/tests + php ../../vendor/bin/codecept build + + - name: Run test server + run: php --server 127.0.0.1:8080 &>/tmp/phpserver.log & + + - name: Setup chromedriver + run: chromedriver --url-base=/wd/hub & + + - name: Valdiate test server + run: sleep 5 && curl --fail --head http://127.0.0.1:8080/index-test.php + + - name: Run test suite + run: | + export HUMHUB_PATH=$GITHUB_WORKSPACE + cd $GITHUB_WORKSPACE/protected/modules/${{ env.module-id }}/tests + php $GITHUB_WORKSPACE/protected/vendor/bin/codecept build + php $GITHUB_WORKSPACE/protected/vendor/bin/codecept run --env github diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index dc1fcc94..00000000 --- a/.travis.yml +++ /dev/null @@ -1,52 +0,0 @@ -language: php -sudo: enabled - -services: - - mysql - -addons: - chrome: stable - -git: - depth: 3 - -php: - - '7.1' - - '7.2' - - '7.3' - - '7.4' - -env: - global: - - HUMHUB_PATH=/opt/humhub - matrix: - - HUMHUB_VERSION=master - - HUMHUB_VERSION=v1.7.0 - - HUMHUB_VERSION=develop - -matrix: - allow_failures: - - env: HUMHUB_VERSION=develop - fast_finish: true - -cache: - directories: - - $HOME/.composer/cache - -install: - - .travis/install-dependencies.sh - - .travis/setup-humhub.sh - -before_script: - - $HOME/chromedriver --url-base=/wd/hub & - - php --server 127.0.0.1:8080 --docroot ${HUMHUB_PATH} &>/dev/null & - - sleep 5 - - curl --fail --head http://127.0.0.1:8080/index-test.php - -script: - - cd tests - - php ${HUMHUB_PATH}/protected/vendor/bin/codecept build - - php ${HUMHUB_PATH}/protected/vendor/bin/codecept run --env travis - -after_failure: - - .travis/upload-failure.sh diff --git a/.travis/install-dependencies.sh b/.travis/install-dependencies.sh deleted file mode 100755 index 9e740093..00000000 --- a/.travis/install-dependencies.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env sh - -# -e = exit when one command returns != 0, -v print each command before executing -set -ev - -# Install chomedriver -CHROME_MAIN_VERSION=`google-chrome-stable --version | sed -E 's/(^Google Chrome |\.[0-9]+ )//g'` -CHROMEDRIVER_VERSION=`curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_MAIN_VERSION"` - -curl "https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip" -O \ - && unzip -o -d $HOME chromedriver_linux64.zip \ - && chmod +x $HOME/chromedriver diff --git a/.travis/setup-humhub.sh b/.travis/setup-humhub.sh deleted file mode 100755 index 41c78da7..00000000 --- a/.travis/setup-humhub.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env sh - -# -e = exit when one command returns != 0, -v print each command before executing -set -ev - -old=$(pwd) - -mkdir ${HUMHUB_PATH} -cd ${HUMHUB_PATH} - -git clone --branch ${HUMHUB_VERSION} --depth 1 https://github.com/humhub/humhub.git . -composer install --prefer-dist --no-interaction - -npm install - -if [ "${HUMHUB_VERSION}" != 'v1.2.5' ] ; then - grunt build-assets -fi - -cd ${HUMHUB_PATH}/protected/humhub/tests - -sed -i -e "s|'installed' => true,|'installed' => true,\n\t'moduleAutoloadPaths' => ['$(dirname $old)']|g" config/common.php - -mysql -e 'CREATE DATABASE humhub_test;' -php codeception/bin/yii migrate/up --includeModuleMigrations=1 --interactive=0 -php codeception/bin/yii installer/auto -php codeception/bin/yii search/rebuild - -php ${HUMHUB_PATH}/protected/vendor/bin/codecept build