Chg: Switched from travis to github actions

This commit is contained in:
buddh4 2020-11-27 12:29:43 +01:00
parent 47f4c3febd
commit 062d230d52
8 changed files with 119 additions and 120 deletions

116
.github/workflows/php-test.yml vendored Normal file
View File

@ -0,0 +1,116 @@
name: PHP Codeception Tests
on:
- pull_request
- push
jobs:
tests:
name: PHP ${{ matrix.php-version }}-mysql-${{ matrix.mysql-version }}
env:
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"
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/checkout@v2
- uses: actions/setup-node@v1
- 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: Install Grunt
run: npm install -g grunt-cli
- 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: 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: grunt test -build -env=github

View File

@ -1,42 +0,0 @@
language: php
sudo: required
services:
- mysql
addons:
chrome: stable
git:
depth: 3
cache:
directories:
- $HOME/.composer/cache
php:
- 7.1
- 7.2
- 7.3
- 7.4
matrix:
fast_finish: true
jobs:
include:
- stage: deploy
name: "Trigger build for external modules"
install: skip
script: .travis/trigger-modules.sh
if: fork = false
install:
- .travis/install-dependencies.sh
- .travis/setup-humhub.sh
script:
#- '$HOME/chromedriver --verbose --log-path=/tmp/chromedriver.log --url-base=/wd/hub &'
- '$HOME/chromedriver --url-base=/wd/hub &'
- 'php --server 127.0.0.1:8080 --docroot ${TRAVIS_BUILD_DIR} &>/tmp/phpserver.log &'
- 'sleep 5 && curl --fail --head http://127.0.0.1:8080/index-test.php'
- 'cd protected/humhub/tests'
- 'php ../../vendor/bin/codecept build'
- 'php ../../vendor/bin/codecept run --env travis'
- 'cd ../../../'
after_failure:
- .travis/upload-failure.sh
env:
global:
secure: EGSE10Ya3jf7+CVwOo2L2iTySqpCKN64VpfeXKnmwy/gPzqfGq7p+Rjc5w7E0AGQgRCUmuw6QB+oyg32qlutW8ZzS7JHtnJTWOR8kkzrkpFohDVCFNOBofn4ckd1h64MWcLoF1otNa2GQAZBT/sgdE7HxmEnbCdqESZPEGQ/Q3I=

View File

@ -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

View File

@ -1,22 +0,0 @@
#!/usr/bin/env sh
# -e = exit when one command returns != 0, -v print each command before executing
set -ev
# Install composer packages
composer install --prefer-dist --no-interaction
# Install node packages
npm install
# Build production assets
grunt build-assets
# Create mysql database
mysql -e 'CREATE DATABASE humhub_test CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'
# Run migrations, setup humhub and rebuild search index
cd ${TRAVIS_BUILD_DIR}/protected/humhub/tests
php codeception/bin/yii migrate/up --includeModuleMigrations=1 --interactive=0
php codeception/bin/yii installer/auto
php codeception/bin/yii search/rebuild

View File

@ -1,18 +0,0 @@
#!/usr/bin/env sh
# -e = exit when one command returns != 0, -v print each command before executing
set -ev
# early exit when pull request || when not master
if [ "${TRAVIS_PULL_REQUEST}" != "false" ] || [ "${TRAVIS_BRANCH}" != "master" ]; then
exit 0;
fi
# trigger build for calendar
curl -s -X POST \
https://api.travis-ci.org/repo/humhub%2Fhumhub-modules-calendar/requests \
-H 'Accept: application/json' \
-H 'Authorization: token '${AUTH_TOKEN} \
-H 'Content-Type: application/json' \
-H 'Travis-API-Version: 3' \
-d '{"request":{"branch":"master","config":{"merge_mode":"deep_merge","env":{"matrix":["HUMHUB_VERSION=master"]}}}}'

View File

@ -1,23 +0,0 @@
#!/usr/bin/env sh
# -e = exit when one command returns != 0, -v print each command before executing
set -ev
# change to protected directory
cd protected
# find _output folder and add to zip
find humhub/ -type d -name "_output" -exec zip -r --exclude="*.gitignore" failure.zip {} +
# add logs to failure.zip
zip -ur failure.zip runtime/logs || true
zip -ur failure.zip /tmp/phpserver.log || true
zip -ur failure.zip /tmp/chromedriver.log || true
# upload file
curl --upload-file ./failure.zip https://transfer.sh/humhub-travis-${TRAVIS_JOB_NUMBER}.zip
# delete zip
rm failure.zip

View File

@ -3,9 +3,9 @@
return [
'components' => [
'db' => [
'dsn' => 'mysql:host=localhost;dbname=humhub_test',
'username' => 'travis',
'password' => '',
'dsn' => 'mysql:host=127.0.0.1;dbname=humhub_test',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
'attributes' => [
PDO::ATTR_PERSISTENT => true