From fe9dd2e12d5f66617e8af5ad08289f9462279f47 Mon Sep 17 00:00:00 2001 From: Philipp Date: Thu, 13 May 2021 21:21:02 +0200 Subject: [PATCH 1/6] Drone & PHP tests --- .drone.yml | 153 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) diff --git a/.drone.yml b/.drone.yml index 257fe23d7..af3ff6c79 100644 --- a/.drone.yml +++ b/.drone.yml @@ -61,3 +61,156 @@ steps: commands: - export CHANGED_FILES="$(git diff --name-status ${DRONE_COMMIT_BEFORE}..${DRONE_COMMIT_AFTER} | grep ^A | cut -f2)" - /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 + - while ! mysqladmin ping -h$MYSQL_HOST -P$MYSQL_PORT --silent; do sleep 1; done + - 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: 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" + commands: + - composer validate + - composer install --prefer-dist + - cp config/local-sample.config.php config/local.config.php + - while ! mysqladmin ping -h$MYSQL_HOST -P$MYSQL_PORT --silent; do sleep 1; done + - 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 + - while ! mysqladmin ping -h$MYSQL_HOST -P$MYSQL_PORT --silent; do sleep 1; done + - 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 From f1e268ee0a10cfd801b3ad0cef3aa8b98caf39f5 Mon Sep 17 00:00:00 2001 From: Philipp Date: Sat, 15 May 2021 23:35:08 +0200 Subject: [PATCH 2/6] remove GitHub Action for PHP tests --- .github/workflows/php.yml | 101 -------------------------------------- bin/dev/setup-phpunit.sh | 13 ----- 2 files changed, 114 deletions(-) delete mode 100644 .github/workflows/php.yml delete mode 100755 bin/dev/setup-phpunit.sh diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml deleted file mode 100644 index 1f3c51812..000000000 --- a/.github/workflows/php.yml +++ /dev/null @@ -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 diff --git a/bin/dev/setup-phpunit.sh b/bin/dev/setup-phpunit.sh deleted file mode 100755 index b3884d3b7..000000000 --- a/bin/dev/setup-phpunit.sh +++ /dev/null @@ -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)" From 339624568d73ca8fc9e5ce5f5f0608de3bf36887 Mon Sep 17 00:00:00 2001 From: Philipp Date: Sat, 15 May 2021 23:44:25 +0200 Subject: [PATCH 3/6] Fixing CodeCov --- .drone.yml | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/.drone.yml b/.drone.yml index af3ff6c79..8eed7af6b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -84,17 +84,7 @@ steps: - cp config/local-sample.config.php config/local.config.php - while ! mysqladmin ping -h$MYSQL_HOST -P$MYSQL_PORT --silent; do sleep 1; done - 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 + - phpunit --configuration tests/phpunit.xml services: - name: mariadb @@ -130,6 +120,7 @@ steps: MEMCACHED_HOST: "memcached" MEMCACHE_HOST: "memcached" commands: + - phpenmod xdebug - composer validate - composer install --prefer-dist - cp config/local-sample.config.php config/local.config.php @@ -186,17 +177,7 @@ steps: - cp config/local-sample.config.php config/local.config.php - while ! mysqladmin ping -h$MYSQL_HOST -P$MYSQL_PORT --silent; do sleep 1; done - 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 + - phpunit --configuration tests/phpunit.xml services: - name: mariadb From b4edd71bb00692f5fbd20fc0d048a190cd15c938 Mon Sep 17 00:00:00 2001 From: Philipp Date: Sat, 15 May 2021 23:56:44 +0200 Subject: [PATCH 4/6] Setting XDEBUG_MODE for coverage --- .drone.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.yml b/.drone.yml index 8eed7af6b..b71a3ca97 100644 --- a/.drone.yml +++ b/.drone.yml @@ -119,6 +119,7 @@ steps: REDIS_HOST: "redis" MEMCACHED_HOST: "memcached" MEMCACHE_HOST: "memcached" + XDEBUG_MODE: "coverage" commands: - phpenmod xdebug - composer validate From aefa4d4a08e4d1063c3a2ca72760a0351587a194 Mon Sep 17 00:00:00 2001 From: Philipp Date: Sun, 16 May 2021 12:44:38 +0200 Subject: [PATCH 5/6] changed mysql connection waiting --- .drone.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.drone.yml b/.drone.yml index b71a3ca97..c6f397fd0 100644 --- a/.drone.yml +++ b/.drone.yml @@ -70,7 +70,7 @@ steps: - name: Test Friendica image: friendicaci/php7.3:php7.3.28 environment: - MYSQL_HOST: "mariadb" + MYSQL_HOST: "wrong" MYSQL_PORT: 3306 MYSQL_DATABASE: "test" MYSQL_PASSWORD: "test" @@ -82,7 +82,7 @@ steps: - composer validate - composer install --prefer-dist - cp config/local-sample.config.php config/local.config.php - - while ! mysqladmin ping -h$MYSQL_HOST -P$MYSQL_PORT --silent; do sleep 1; done + - 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 @@ -125,7 +125,7 @@ steps: - composer validate - composer install --prefer-dist - cp config/local-sample.config.php config/local.config.php - - while ! mysqladmin ping -h$MYSQL_HOST -P$MYSQL_PORT --silent; do sleep 1; done + - 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 @@ -176,7 +176,7 @@ steps: - composer validate - composer install --prefer-dist - cp config/local-sample.config.php config/local.config.php - - while ! mysqladmin ping -h$MYSQL_HOST -P$MYSQL_PORT --silent; do sleep 1; done + - 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 From 85534a74bd3ee1336fbe3085a59bffcf081b030a Mon Sep 17 00:00:00 2001 From: Philipp Date: Sun, 16 May 2021 12:51:54 +0200 Subject: [PATCH 6/6] fix php7.3 test --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index c6f397fd0..ec9963135 100644 --- a/.drone.yml +++ b/.drone.yml @@ -70,7 +70,7 @@ steps: - name: Test Friendica image: friendicaci/php7.3:php7.3.28 environment: - MYSQL_HOST: "wrong" + MYSQL_HOST: "mariadb" MYSQL_PORT: 3306 MYSQL_DATABASE: "test" MYSQL_PASSWORD: "test"