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