Merge pull request #10251 from nupplaphil/feat/drone_phptest
Move PHP tests to Drone
This commit is contained in:
commit
1c4cc15152
3 changed files with 135 additions and 114 deletions
135
.drone.yml
135
.drone.yml
|
@ -61,3 +61,138 @@ steps:
|
||||||
commands:
|
commands:
|
||||||
- export CHANGED_FILES="$(git diff --name-status ${DRONE_COMMIT_BEFORE}..${DRONE_COMMIT_AFTER} | grep ^A | cut -f2)"
|
- export CHANGED_FILES="$(git diff --name-status ${DRONE_COMMIT_BEFORE}..${DRONE_COMMIT_AFTER} | grep ^A | cut -f2)"
|
||||||
- /check-php-cs.sh
|
- /check-php-cs.sh
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: php7.3-mariadb
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Test Friendica
|
||||||
|
image: friendicaci/php7.3:php7.3.28
|
||||||
|
environment:
|
||||||
|
MYSQL_HOST: "mariadb"
|
||||||
|
MYSQL_PORT: 3306
|
||||||
|
MYSQL_DATABASE: "test"
|
||||||
|
MYSQL_PASSWORD: "test"
|
||||||
|
MYSQL_USER: "test"
|
||||||
|
REDIS_HOST: "redis"
|
||||||
|
MEMCACHED_HOST: "memcached"
|
||||||
|
MEMCACHE_HOST: "memcached"
|
||||||
|
commands:
|
||||||
|
- composer validate
|
||||||
|
- composer install --prefer-dist
|
||||||
|
- cp config/local-sample.config.php config/local.config.php
|
||||||
|
- if ! bin/wait-for-connection $MYSQL_HOST $MYSQL_PORT 300; then echo "[ERROR] Waited 300 seconds, no response" >&2; exit 1; fi
|
||||||
|
- mysql -h$MYSQL_HOST -P$MYSQL_PORT -p$MYSQL_PASSWORD -u$MYSQL_USER $MYSQL_DATABASE < database.sql
|
||||||
|
- phpunit --configuration tests/phpunit.xml
|
||||||
|
|
||||||
|
services:
|
||||||
|
- name: mariadb
|
||||||
|
image: mariadb:latest
|
||||||
|
environment:
|
||||||
|
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
|
||||||
|
MYSQL_DATABASE: "test"
|
||||||
|
MYSQL_PASSWORD: "test"
|
||||||
|
MYSQL_USER: "test"
|
||||||
|
tmpfs:
|
||||||
|
- /var/lib/mysql
|
||||||
|
|
||||||
|
- name: memcached
|
||||||
|
image: memcached
|
||||||
|
|
||||||
|
- name: redis
|
||||||
|
image: redis
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: php7.4-mariadb
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Test Friendica
|
||||||
|
image: friendicaci/php7.4:php7.4.18
|
||||||
|
environment:
|
||||||
|
MYSQL_HOST: "mariadb"
|
||||||
|
MYSQL_PORT: 3306
|
||||||
|
MYSQL_DATABASE: "test"
|
||||||
|
MYSQL_PASSWORD: "test"
|
||||||
|
MYSQL_USER: "test"
|
||||||
|
REDIS_HOST: "redis"
|
||||||
|
MEMCACHED_HOST: "memcached"
|
||||||
|
MEMCACHE_HOST: "memcached"
|
||||||
|
XDEBUG_MODE: "coverage"
|
||||||
|
commands:
|
||||||
|
- phpenmod xdebug
|
||||||
|
- composer validate
|
||||||
|
- composer install --prefer-dist
|
||||||
|
- cp config/local-sample.config.php config/local.config.php
|
||||||
|
- if ! bin/wait-for-connection $MYSQL_HOST $MYSQL_PORT 300; then echo "[ERROR] Waited 300 seconds, no response" >&2; exit 1; fi
|
||||||
|
- mysql -h$MYSQL_HOST -P$MYSQL_PORT -p$MYSQL_PASSWORD -u$MYSQL_USER $MYSQL_DATABASE < database.sql
|
||||||
|
- phpunit --configuration tests/phpunit.xml --coverage-clover clover.xml
|
||||||
|
- name: Codecov
|
||||||
|
image: plugins/codecov
|
||||||
|
when:
|
||||||
|
repo:
|
||||||
|
- friendica/friendica
|
||||||
|
settings:
|
||||||
|
token:
|
||||||
|
from_secret: codecov-token
|
||||||
|
files:
|
||||||
|
- clover.xml
|
||||||
|
|
||||||
|
services:
|
||||||
|
- name: mariadb
|
||||||
|
image: mariadb:latest
|
||||||
|
environment:
|
||||||
|
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
|
||||||
|
MYSQL_DATABASE: "test"
|
||||||
|
MYSQL_PASSWORD: "test"
|
||||||
|
MYSQL_USER: "test"
|
||||||
|
tmpfs:
|
||||||
|
- /var/lib/mysql
|
||||||
|
|
||||||
|
- name: memcached
|
||||||
|
image: memcached
|
||||||
|
|
||||||
|
- name: redis
|
||||||
|
image: redis
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: php8.0-mariadb
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Test Friendica
|
||||||
|
image: friendicaci/php8.0:php8.0.5
|
||||||
|
environment:
|
||||||
|
MYSQL_HOST: "mariadb"
|
||||||
|
MYSQL_PORT: 3306
|
||||||
|
MYSQL_DATABASE: "test"
|
||||||
|
MYSQL_PASSWORD: "test"
|
||||||
|
MYSQL_USER: "test"
|
||||||
|
REDIS_HOST: "redis"
|
||||||
|
MEMCACHED_HOST: "memcached"
|
||||||
|
MEMCACHE_HOST: "memcached"
|
||||||
|
commands:
|
||||||
|
- composer validate
|
||||||
|
- composer install --prefer-dist
|
||||||
|
- cp config/local-sample.config.php config/local.config.php
|
||||||
|
- if ! bin/wait-for-connection $MYSQL_HOST $MYSQL_PORT 300; then echo "[ERROR] Waited 300 seconds, no response" >&2; exit 1; fi
|
||||||
|
- mysql -h$MYSQL_HOST -P$MYSQL_PORT -p$MYSQL_PASSWORD -u$MYSQL_USER $MYSQL_DATABASE < database.sql
|
||||||
|
- phpunit --configuration tests/phpunit.xml
|
||||||
|
|
||||||
|
services:
|
||||||
|
- name: mariadb
|
||||||
|
image: mariadb:latest
|
||||||
|
environment:
|
||||||
|
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
|
||||||
|
MYSQL_DATABASE: "test"
|
||||||
|
MYSQL_PASSWORD: "test"
|
||||||
|
MYSQL_USER: "test"
|
||||||
|
tmpfs:
|
||||||
|
- /var/lib/mysql
|
||||||
|
|
||||||
|
- name: memcached
|
||||||
|
image: memcached
|
||||||
|
|
||||||
|
- name: redis
|
||||||
|
image: redis
|
||||||
|
|
101
.github/workflows/php.yml
vendored
101
.github/workflows/php.yml
vendored
|
@ -1,101 +0,0 @@
|
||||||
name: Testing Friendica
|
|
||||||
on: [push, pull_request]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
friendica:
|
|
||||||
name: Friendica (PHP ${{ matrix.php-versions }})
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
services:
|
|
||||||
mariadb:
|
|
||||||
image: mariadb:latest
|
|
||||||
env:
|
|
||||||
MYSQL_ALLOW_EMPTY_PASSWORD: true
|
|
||||||
MYSQL_DATABASE: test
|
|
||||||
MYSQL_PASSWORD: test
|
|
||||||
MYSQL_USER: test
|
|
||||||
ports:
|
|
||||||
- 3306/tcp
|
|
||||||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
|
||||||
redis:
|
|
||||||
image: redis
|
|
||||||
ports:
|
|
||||||
- 6379/tcp
|
|
||||||
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
|
||||||
memcached:
|
|
||||||
image: memcached
|
|
||||||
ports:
|
|
||||||
- 11211/tcp
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
php-versions: ['7.3', '7.4', '8.0']
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Setup PHP, with composer and extensions
|
|
||||||
uses: shivammathur/setup-php@v2
|
|
||||||
with:
|
|
||||||
php-version: ${{ matrix.php-versions }}
|
|
||||||
tools: pecl, composer:v1
|
|
||||||
extensions: pdo_mysql, gd, zip, opcache, ctype, pcntl, ldap, apcu, memcached, redis, imagick, memcache
|
|
||||||
coverage: xdebug
|
|
||||||
ini-values: apc.enabled=1, apc.enable_cli=1
|
|
||||||
|
|
||||||
- name: Start mysql service
|
|
||||||
run: sudo /etc/init.d/mysql start
|
|
||||||
|
|
||||||
- name: Validate composer.json and composer.lock
|
|
||||||
run: composer validate
|
|
||||||
|
|
||||||
- name: Get composer cache directory
|
|
||||||
id: composercache
|
|
||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
|
||||||
|
|
||||||
- name: Cache dependencies
|
|
||||||
uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: ${{ steps.composercache.outputs.dir }}
|
|
||||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
|
||||||
restore-keys: ${{ runner.os }}-composer-
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: composer install --prefer-dist
|
|
||||||
|
|
||||||
- name: Setup PHPUnit 8
|
|
||||||
run: bin/dev/setup-phpunit.sh
|
|
||||||
|
|
||||||
- name: Copy default Friendica config
|
|
||||||
run: cp config/local-sample.config.php config/local.config.php
|
|
||||||
|
|
||||||
- name: Verify MariaDB connection
|
|
||||||
env:
|
|
||||||
PORT: ${{ job.services.mariadb.ports[3306] }}
|
|
||||||
run: |
|
|
||||||
while ! mysqladmin ping -h"127.0.0.1" -P"$PORT" --silent; do
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
|
|
||||||
- name: Setup MYSQL database
|
|
||||||
env:
|
|
||||||
PORT: ${{ job.services.mariadb.ports[3306] }}
|
|
||||||
run: |
|
|
||||||
mysql -h"127.0.0.1" -P"$PORT" -utest -ptest test < database.sql
|
|
||||||
|
|
||||||
- name: Test with phpunit
|
|
||||||
run: $(git rev-parse --show-toplevel)/bin/phpunit --configuration tests/phpunit.xml --coverage-clover clover.xml
|
|
||||||
env:
|
|
||||||
MYSQL_HOST: 127.0.0.1
|
|
||||||
MYSQL_PORT: ${{ job.services.mariadb.ports[3306] }}
|
|
||||||
MYSQL_DATABASE: test
|
|
||||||
MYSQL_PASSWORD: test
|
|
||||||
MYSQL_USER: test
|
|
||||||
REDIS_PORT: ${{ job.services.redis.ports[6379] }}
|
|
||||||
REDIS_HOST: 127.0.0.1
|
|
||||||
MEMCACHED_PORT: ${{ job.services.memcached.ports[11211] }}
|
|
||||||
MEMCACHE_PORT: ${{ job.services.memcached.ports[11211] }}
|
|
||||||
|
|
||||||
- name: Upload coverage to Codecov
|
|
||||||
uses: codecov/codecov-action@v1
|
|
||||||
with:
|
|
||||||
file: clover.xml
|
|
|
@ -1,13 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
PHPUNIT="$(git rev-parse --show-toplevel)/bin/phpunit"
|
|
||||||
|
|
||||||
if ! [ -x "$PHPUNIT" ]; then
|
|
||||||
echo "Install PHPUnit 8"
|
|
||||||
cd /tmp/
|
|
||||||
curl -s -O -L https://phar.phpunit.de/phpunit-8.phar
|
|
||||||
chmod +x phpunit-8.phar
|
|
||||||
mv phpunit-8.phar $PHPUNIT
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Using $PHPUNIT $($PHPUNIT --version)"
|
|
Loading…
Reference in a new issue