3da7ee8796febf65ecfdcf93e03a32b3800b1ba4
[friendica.git/.git] / .github / workflows / php.yml
1 name: Testing Friendica
2 on: [push, pull_request, pull_request_review]
3
4 jobs:
5   friendica:
6     name: Friendica (PHP ${{ matrix.php-versions }})
7     runs-on: ubuntu-latest
8     env:
9       MYSQL_HOST: localhost
10       MYSQL_PORT: 3306
11       MYSQL_DATABASE: test
12       MYSQL_PASSWORD: ""
13       MYSQL_USERNAME: travis
14     services:
15       mariadb:
16         image: mariadb:latest
17         env:
18           MYSQL_ALLOW_EMPTY_PASSWORD: true
19           MYSQL_DATABASE: test
20           MYSQL_PASSWORD: ""
21           MYSQL_USERNAME: travis
22         ports:
23           - 3306/tcp
24         options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
25       redis:
26         image: redis
27         ports:
28           - 6379/tcp
29         options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
30       memcached:
31         image: memcached
32         ports:
33           - 11211/tcp
34     strategy:
35       fail-fast: false
36       matrix:
37         php-versions: ['7.2', '7.3', '7.4']
38     steps:
39       - name: Checkout
40         uses: actions/checkout@v2
41
42       - name: Setup PHP, with composer and extensions
43         uses: shivammathur/setup-php@v2
44         with:
45           php-version: ${{ matrix.php-versions }}
46           tools: pecl
47           extensions: pdo_mysql, gd, zip, opcache, ctype, pcntl, ldap, apcu, memcached, redis, imagick
48           coverage: xdebug
49           ini-values: apc.enabled=1, apc.enable_cli=1
50
51       - name: Start mysql service
52         run: sudo /etc/init.d/mysql start
53
54       - name: Validate composer.json and composer.lock
55         run: composer validate
56
57       - name: Get composer cache directory
58         id: composercache
59         run: echo "::set-output name=dir::$(composer config cache-files-dir)"
60
61       - name: Cache dependencies
62         uses: actions/cache@v2
63         with:
64           path: ${{ steps.composercache.outputs.dir }}
65           key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
66           restore-keys: ${{ runner.os }}-composer-
67
68       - name: Install dependencies
69         run: composer install --prefer-dist
70
71       - name: Copy default Friendica config
72         run: cp config/local-sample.config.php config/local.config.php
73
74       - name: Verify MariaDB connection
75         env:
76           PORT: ${{ job.services.mariadb.ports[3306] }}
77         run: |
78           while ! mysqladmin ping -h"127.0.0.1" -P"$PORT" --silent; do
79             sleep 1
80           done
81
82       - name: Setup MYSQL database
83         env:
84           PORT: ${{ job.services.mariadb.ports[3306] }}
85         run: |
86           mysql -h"127.0.0.1" -P"$PORT" -uroot -e 'CREATE DATABASE IF NOT EXISTS test;'
87           mysql -h"127.0.0.1" -P"$PORT" -uroot test < database.sql
88
89       - name: Test with Parallel-lint
90         run: vendor/bin/parallel-lint --exclude vendor/ --exclude view/asset/ .
91
92       - name: Test with phpunit
93         run: vendor/bin/phpunit --configuration tests/phpunit.xml --coverage-clover clover.xml
94         env:
95           MYSQL_HOST: localhost
96           MYSQL_PORT: 3306
97           MYSQL_DATABASE: test
98           MYSQL_PASSWORD: ""
99           MYSQL_USERNAME: root
100
101       - name: Upload coverage to Codecov
102         uses: codecov/codecov-action@v1
103         with:
104           file: clover.xml